hexagon logo

Import static data from textfile (fast hack)

Proof of concept.

Contents of data.txt:
Article: 988893
Description: pistons
Nr. Lot: 838384


How pc-dimis can import only the data "988893" , "pistons" and "838384
" from this file??


Code for reading:
FPTR       =FILE/OPEN,C:\Documents and Settings\CS-FC-SDE-S-PCID254\Desktop\data.txt,READ
            ASSIGN/ROW1=""
            ASSIGN/ROW2=""
            ASSIGN/ROW3=""
V1         =FILE/READLINE,FPTR,{ROW1}
V1         =FILE/READLINE,FPTR,{ROW2}
V1         =FILE/READLINE,FPTR,{ROW3}
            FILE/CLOSE,FPTR,KEEP
            ASSIGN/ROW1=ROW1-"Article: "
            ASSIGN/ROW2=ROW2-"Description: "
            ASSIGN/ROW3=ROW3-"Nr. Lot: "


Note that the contents of the three rows must match the static string that we are deleting from the line we read, otherwise it will not work. If you change the "Article: " to anything else, you must also change the "ROW1-"Article: " to match your change. This applies of course to the ROW2 and ROW3 contents as well.

An easy hack with no string verification or any of the fancy stuff. It builds on the fact that the source file "data.txt" only contains three rows with data that is interesting for us and these are the three first rows in the source file.
Parents Reply Children
No Data