Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file reading

Status
Not open for further replies.

gambino

Technical User
Oct 1, 2002
11
DE
hello peeps can someone help me with a problem i'm writing a prgramm in procomm plus 32 that has 4 pulldown windows and te content of the 4 pulldown windows are in a textfile(i've done this so that it's easy to make changes when you want to add something)..it succeeded me to fill the 1ste pulldown window i'm using [navigatiesystemen]en [/navigatiesystemen] and i give orders to display everything whats between [navigatiesystemen] and [/navigatiesystemen] in pull down window 1.

so this is what i want:
when you have chosen one of the navigationsystemen in pulldown window 1, then the script should open the targetsfile that is assigned to that navigationsystem. for example if you have chosen hvm3 in the 1ste pulldown window it should display in pulldown window 2 what's between [hmv3] and [/hvm3]and if roadrunner is chosen in pulldown window 1 it should display in pull down window 2 what's between [roadrunner] and [/roadrunner]....
if i add something i 'll do it in the textfile so for example if i want to add a navigationsystem hvm4... so all i have to do is adding between [navigationsystems] and [/navigationsystems]the word hvm4 and add betweeen [targets] and [/targets] the word [hvm4] and [/hvm4] and in [hvm4] and [/hvm4] ill puts the testnames .....and that is then atomatically changed in the script

i've tried to do it myself but with no results...
here i'll give you my script file and the textfile i've made so far
i've not assigned the casses yet.
i've wrote a script with fulllist but i wanted to use a textfile so i'm overwriting the fulllist file( i hope you know what i mean). i mean that i must delte fulllist=.... and stuff it was from the old scriptfile

SCRIPTFILE:

func Fgets_FR : string ; opens function and gives a string back.
param integer bestand ; parameter integer bestand.
string resultstring="" ; string to contain resultstring, declare to be an emty string.
string temp ; string to contain temp.
integer endofline =0 ; integer to contain endofline.
integer karakter ; integer to contain karakter.
integer carret = 13 ; integer to contain carret.

while endofline==0 ; loop while.
if feof 0 ; if end of file.
endofline=1 ; endofline.
else
fgetc bestand karakter ; get karakter from bestand file.
if karakter==carret ; is karakter is equal to carret(13) then end of line.
endofline=1
else
if karakter>32 & karakter<127
strset temp 0 karakter 1 ; coverts an integer to a ascii string.
strcat resultstring temp ; concat. resultstring to temp.
endif
endif
endif
endwhile
return resultstring
endfunc

proc main
string Fname = &quot;H:/voorbeeld.txt&quot; ; File name to be opened.
string FullList1
string FullList2
string Items ; Item selected from list.
string Items1
string Items2
string LineBuffer ; Line read from file.
string searchstring
string inhoudbox1 = &quot;&quot;
string inhoudbox2 = &quot;&quot;
integer Event
integer eindbereikt =0


searchstring = &quot;[NAVIGATIESYSTEMEN]&quot; ; declares searchstring
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring ; if searchstring is equal to linebuffer
searchstring = &quot;[/NAVIGATIESYSTEMEN]&quot; ; declares searchstring
while eindbereikt == 0
if feof 0
eindbereikt=1
else
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring
eindbereikt=1
else
strcat inhoudbox1 LineBuffer ; concat. inhoudbox1 to linebuffer
strcat inhoudbox1 &quot;,&quot; ; ends line with a &quot;,&quot;
endif
endif
endwhile
exitwhile
endif
endwhile
fclose 0
else
errormsg &quot;Kan file niet vinden `&quot;%s`&quot;.&quot; Fname ;kan file niet vinden
endif

termmsg inhoudbox1 ; shows inhoudbox1 on terminal


;the script whats above here is what i wrote new and whats beneeth(down) here is the old fullist script but the size of the comboboxen and dialogbox and text are good for the new script. so what's beneeth must be changed. but i want to solve my problems first and then change what's beneeth(down)

; Display a dialog box with a list of stuff to choose from.
FullList1 = &quot;TARGETS,AN,BMW,VOLVO,ENZOVOORTS&quot;
FullList2 = &quot;TESTS,fantest,audiotest,cdtest,beeldtest&quot;
Items = &quot;NAVIGATIEMODELLEN&quot; ; Set default item.
Items1 = &quot;TARGETS&quot;
Items2 = &quot;TESTS&quot;
dialogbox 0 1 16 676 379 2 &quot;Test Software&quot;
combobox 1 10 24 139 329 DROPDOWNLIST inhoudbox1 Items
combobox 2 172 24 139 329 DROPDOWNLIST Fulllist2 Items1
combobox 3 343 24 139 329 DROPDOWNLIST FullList2 Items2
combobox 4 522 23 139 329 DROPDOWNLIST FullList2 Items2
text 5 43 6 74 11 &quot;Navigatiemodellen&quot; left
text 6 224 6 34 10 &quot;Targets&quot; left
text 7 406 5 30 14 &quot;Tests&quot; left
text 8 570 4 45 12 &quot;Testcases&quot; left
enddialog




while 1

dlgevent 0 Event ; Get dialog event.

switch Event ; Evaluate the event.
case 0 ; No event occurred.
endcase
case 1 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items
endcase
case 2 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items1
endcase
case 3 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase
case 4 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase

default ; Exit method selected.
exitwhile ; Exit the while loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.
endproc



TEXTFILE:
this is the textfile that i use so the content of this textfile must be displayed in the pull down windows


[NAVIGATIESYSTEMEN]
ROADRUNNER
HVM3
FIETS
[/NAVIGATIESYSTEMEN]
[TARGETS]
[ROADRUNNER]
BMW COLOR, BMW-COLOR.TXT
BMW MONO, BMW-MONO.TXT
BMW OCN, BMW-OCN.TXT
AN COLOR, AN-COLOR.TXT
AN MONO, AN-MONO.TXT
AN RADNAV, AN-RADNAV.TXT
[/ROADRUNNER]
[HVM3]
OPEL, OPEL.TXT
AUDI C6, AUDI-C6.TXT
AUDI ELISA, AUDI-ELISA.TXT
[/HVM3]
[/TARGETS]

 
my english is not so good but can you help me by changing it in my script file so that i can understad it better....thx you
 
Hello,

As far as Parsing the Data between the [ROADRUNNER] -
[/ROADRUNNER] and [HVM3] - [/HVM3] the following may help you out. I took your Output and made several copies in a NAV.txt file. The following script creates 2 Files and the Data is sent to those Files.

Proc Main
string sLine
string RS = &quot;[ROADRUNNER]&quot;
string RE = &quot;[`092ROADRUNNER]&quot;
string HS = &quot;[HVM3]&quot;
string HE = &quot;[`092HVM3]&quot;

fopen 0 &quot;C:\Files\NAV.txt&quot; Read Text
fopen 1 &quot;C:\Files\Road.txt&quot; Create Text
fopen 2 &quot;C:\Files\HVM3.txt&quot; Create Text
while not feof 0
fgets 0 sLine
if strfind sLine RS
while 1
fputs 1 sline
fgets 0 sLine
if strfind sLine RE
exitwhile
endif
endwhile
endif
if strfind sLine HS
while 1
fputs 2 sLine
fgets 0 sLine
if strfind sLine HE
exitwhile
endif
endwhile
endif
endwhile
fclose 0
fclose 1
fclose 2
Endproc

Hank
 
OK, I wasn't able to get to this as soon as I had hoped, but here is what I came up with tonight. Note, I edited the text file so that it looked like this:

[NAVIGATIESYSTEMEN]
ROADRUNNER
HVM3
FIETS
[/NAVIGATIESYSTEMEN]
[TARGETS]
[ROADRUNNER]
BMW COLOR
BMW MONO
BMW OCN
AN COLOR
AN MONO
AN RADNAV
[/ROADRUNNER]
[HVM3]
OPEL
AUDI C6
AUDI ELISA
[/HVM3]
[/TARGETS]

I removed the text files from the list because the commas would interfere with the listbox contents that I was building while reading the file. If you need to parse the text files out for another listbox in your dialog, then I would recommand using another character that you won't normally be using (say, an asterisk or similar character) to divide the different fields. You could then create a function that reads each line of the text file and uses the strtok command to break each line into its separate fields.

The main change I made was to take Hank's script and create a function called GetList from that, such that it would search the text file for the selection you made. All text between the beginning and ending tags are added to one string using the strcat command, with a comma separating each item. This is handy because comma-delimited items in a string is what the dialog box commands are expecting. When the end tag was read, the constructed string is returned and set in the value of Fulllist2, and the dialog control is updated. This causes the data to appear in the second listbox.

Hopefully this will give you some ideas on where to take your script, but feel free to ask more questions!

func Fgets_FR : string ; opens function and gives a string back.
param integer bestand ; parameter integer bestand.
string resultstring=&quot;&quot; ; string to contain resultstring, declare to be an emty string.
string temp ; string to contain temp.
integer endofline =0 ; integer to contain endofline.
integer karakter ; integer to contain karakter.
integer carret = 13 ; integer to contain carret.

while endofline==0 ; loop while.
if feof 0 ; if end of file.
endofline=1 ; endofline.
else
fgetc bestand karakter ; get karakter from bestand file.
if karakter==carret ; is karakter is equal to carret(13) then end of line.
endofline=1
else
if karakter>32 & karakter<127
strset temp 0 karakter 1 ; coverts an integer to a ascii string.
strcat resultstring temp ; concat. resultstring to temp.
endif
endif
endif
endwhile
return resultstring
endfunc

func GetList : string
param string sChoice
string sSearch1 = &quot;[]&quot;
string sSearch2 = &quot;[/]&quot;
string sResult = &quot;&quot;, sLine

strinsert sSearch1 sChoice 1
strinsert sSearch2 sCHoice 2

fopen 0 &quot;C:\voorbeeld.txt&quot; Read Text
while not feof 0
fgets 0 sLine
if strfind sLine sSearch1
fgets 0 sLine
while 1
strcat sResult sLine
fgets 0 sLine
if strfind sLine sSearch2
exitwhile
endif
strcat sResult &quot;,&quot;
endwhile
endif
endwhile
fclose 0
return sResult
endfunc

proc main
string Fname = &quot;c:\voorbeeld.txt&quot; ; File name to be opened.
string FullList1
string FullList2
string Items ; Item selected from list.
string Items1
string Items2
string LineBuffer ; Line read from file.
string searchstring
string inhoudbox1 = &quot;&quot;
string inhoudbox2 = &quot;&quot;
integer Event
integer eindbereikt =0


searchstring = &quot;[NAVIGATIESYSTEMEN]&quot; ; declares searchstring
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring ; if searchstring is equal to linebuffer
searchstring = &quot;[/NAVIGATIESYSTEMEN]&quot; ; declares searchstring
while eindbereikt == 0
if feof 0
eindbereikt=1
else
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring
eindbereikt=1
else
strcat inhoudbox1 LineBuffer ; concat. inhoudbox1 to linebuffer
strcat inhoudbox1 &quot;,&quot; ; ends line with a &quot;,&quot;
endif
endif
endwhile
exitwhile
endif
endwhile
fclose 0
else
errormsg &quot;Kan file niet vinden `&quot;%s`&quot;.&quot; Fname ;kan file niet vinden
endif

termmsg inhoudbox1 ; shows inhoudbox1 on terminal


;the script whats above here is what i wrote new and whats beneeth(down) here is the old fullist script but the size of the comboboxen and dialogbox and text are good for the new script. so what's beneeth must be changed. but i want to solve my problems first and then change what's beneeth(down)

; Display a dialog box with a list of stuff to choose from.
FullList1 = &quot;TARGETS,AN,BMW,VOLVO,ENZOVOORTS&quot;
FullList2 = &quot;TESTS,fantest,audiotest,cdtest,beeldtest&quot;
Items = &quot;NAVIGATIEMODELLEN&quot; ; Set default item.
Items1 = &quot;TARGETS&quot;
Items2 = &quot;TESTS&quot;
dialogbox 0 1 16 676 379 2 &quot;Test Software&quot;
combobox 1 10 24 139 329 DROPDOWNLIST inhoudbox1 Items
combobox 2 172 24 139 329 DROPDOWNLIST Fulllist2 Items1
combobox 3 343 24 139 329 DROPDOWNLIST FullList2 Items2
combobox 4 522 23 139 329 DROPDOWNLIST FullList2 Items2
text 5 43 6 74 11 &quot;Navigatiemodellen&quot; left
text 6 224 6 34 10 &quot;Targets&quot; left
text 7 406 5 30 14 &quot;Tests&quot; left
text 8 570 4 45 12 &quot;Testcases&quot; left
enddialog




while 1

dlgevent 0 Event ; Get dialog event.

switch Event ; Evaluate the event.
case 0 ; No event occurred.
endcase
case 1 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items
Fulllist2 = GetList(Items)
dlgupdate 0 2
endcase
case 2 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items1
endcase
case 3 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase
case 4 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase

default ; Exit method selected.
exitwhile ; Exit the while loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.
endproc aspect@aspectscripting.com
 
thx for you help guys i've tried it myself and i've accomplised to fill the fist 2 pull down windows...and i'm working with the 3de window this is the script file i made to fill in the fist 2 pull down windows:
string inhoudbox1 =&quot;&quot; ; global varialbe
string inhoudbox2 =&quot;&quot;
string inhoudbox3 =&quot;&quot;
string inhoudbox4 =&quot;&quot;
string Items1
string Items2
string Items3
string Items4

func Fgets_FR : string ; opens function and gives a string back.
param integer bestand ; parameter integer bestand.
string resultstring=&quot;&quot; ; string to contain resultstring, declare to be an emty string.
string temp ; string to contain temp.
integer endofline =0 ; integer to contain endofline.
integer karakter ; integer to contain karakter.
integer carret = 13 ; integer to contain carret.

while endofline==0 ; loop while.
if feof 0 ; if end of file.
endofline=1 ; endofline.
else
fgetc bestand karakter ; get karakter from bestand file.
if karakter==carret ; is karakter is equal to carret(13) then end of line.
endofline=1
else
if karakter>32 & karakter<127
strset temp 0 karakter 1 ; coverts an integer to a ascii string.
strcat resultstring temp ; concat. resultstring to temp.
endif
endif
endif
endwhile
return resultstring
endfunc

proc drawdialog

dialogbox 0 1 16 676 379 2 &quot;Test Software&quot;
combobox 1 10 24 139 329 DROPDOWNLIST inhoudbox1 Items1
combobox 2 172 24 139 329 DROPDOWNLIST inhoudbox2 Items2
combobox 3 343 24 139 329 DROPDOWNLIST inhoudbox3 Items3
combobox 4 522 23 139 329 DROPDOWNLIST inhoudbox4 Items4
text 5 43 6 74 11 &quot;Navigatiemodellen&quot; left
text 6 224 6 34 10 &quot;Targets&quot; left
text 7 406 5 30 14 &quot;Tests&quot; left
text 8 570 4 45 12 &quot;Testcases&quot; left
enddialog
endproc



proc main

string Fname = &quot;H:/voorbeeld.txt&quot; ; File name to be opened.
string LineBuffer ; Line read from file.
string searchstring
integer Event
integer eindbereikt =0


searchstring = &quot;[NAVIGATIESYSTEMEN]&quot; ; declares searchstring
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring ; if searchstring is equal to linebuffer
searchstring = &quot;[/NAVIGATIESYSTEMEN]&quot; ; declares searchstring
while eindbereikt == 0
if feof 0
eindbereikt=1
else
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring
eindbereikt=1
else
strcat inhoudbox1 LineBuffer ; concat. inhoudbox1 to linebuffer
strcat inhoudbox1 &quot;,&quot; ; ends line with a &quot;,&quot;
endif
endif
endwhile
exitwhile
endif
endwhile
fclose 0
else
errormsg &quot;Kan file niet vinden `&quot;%s`&quot;.&quot; Fname ;kan file niet vinden
endif

termmsg inhoudbox1 ; displays inhoudbox1 on terminal

drawdialog ()

while 1

dlgevent 0 Event ; Get dialog event.

switch Event ; Evaluate the event.
case 0 ; No event occurred.
endcase
case 1 ; Check box item selected.
inhoudbox2= &quot;&quot; ; empty inhoudbox2
searchstring = &quot;[TARGETS]&quot; ; declares searchstring
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring ; if searchstring is equal to linebuffer
searchstring = &quot;[&quot;
strcat searchstring Items1
strcat searchstring &quot;]&quot;
usermsg &quot;%s&quot; searchstring ; declares searchstring
while not feof 0
LineBuffer = fgets_FR (0)
if strcmp Linebuffer searchstring
searchstring = &quot;[/&quot;
strcat searchstring Items1
strcat searchstring &quot;]&quot;
eindbereikt=0
while eindbereikt ==0
if feof 0
eindbereikt =1
else
LineBuffer =fgets_FR (0)
if strcmp LineBuffer searchstring
eindbereikt =1
else
strcat inhoudbox2 LineBuffer
strcat inhoudbox2 &quot;,&quot;
endif
endif
endwhile
exitwhile
endif
endwhile
exitwhile
endif
endwhile
fclose 0
else
errormsg &quot;Kan file niet vinden `&quot;%s`&quot;.&quot; Fname ;kan file niet vinden
endif

termmsg inhoudbox2

drawdialog ()


endcase
case 2 ; Check box item selected.


usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase
case 3 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items3
endcase
case 4 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items4
endcase

default ; Exit method selected.
exitwhile ; Exit the while loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.
endproc

it works how i want it and it's easy to make changes in it....so i'm now working with the 3de pull down window that works the same as the first and second window only when there is a choise made in pulldonw window 2 for example bmw-color that then the script opens bmw-color.txt, and when bmw-mono is chosen bmw-mono.txt is open i know it's easy to realise but i'm looking for the most simple sollution


thx alot for you're help guys
 
it works how i want it and it's easy to make changes in it....so i'm now working with the 3de pull down window that works the same as the first and second window only when there is a choise made in pulldonw window 2 for example bmw-color that then the script opens bmw-color.txt, and when bmw-mono is chosen bmw-mono.txt is open i know it's easy to realise but i'm looking for the most simple sollution

can you give me some examples.........so i can see which one is the most simple......

thx knob for you're answer i see that you're script file works the same as mine but you're is shorter in text..i didn't thought of it to use a function( it's much simpler
)
 
string fname2

i put this in case 2
Fname2 = &quot;H:/&quot;
strcat Fname2 Items2
strcat Fname2 &quot;.txt&quot;

searchstring = &quot;[BMWCOLORTEST]&quot; ; declares searchstring
if fopen 1 Fname2 READ TEXT ; Open file for read only.
while not feof 1 ; Loop while not end of file.
LineBuffer = fgets_FR (1)
termmsg &quot;`r`n&quot;
termmsg &quot;`r`n&quot;
termmsg LineBuffer
termmsg &quot;`r`n&quot;
if strcmp LineBuffer searchstring ; if searchstring is equal to linebuffer
searchstring = &quot;[/BMWCOLORTEST]&quot; ; declares searchstring
while eindbereikt == 0
if feof 1
eindbereikt=1
else
LineBuffer = fgets_FR (1)
if strcmp LineBuffer searchstring
eindbereikt=1
else
strcat inhoudbox3 LineBuffer ; concat. inhoudbox1 to linebuffer
strcat inhoudbox3 &quot;,&quot; ; ends line with a &quot;,&quot;
endif
endif
endwhile
exitwhile
endif
endwhile
fclose 1
else
errormsg &quot;Kan file niet vinden `&quot;%s`&quot;.&quot; Fname2 ;CANNOT FIND FILE
endif
dlgupdate 0 3
termmsg inhoudbox3 ; shows inhoudbox1 on terminal






usermsg &quot;`&quot;%s`&quot; selected!&quot; Fname2

I MADE A FILE BMW-COLOR.TXT ZO WHEN YOU CHOOSE ROADRUNNER IN 1STE WINDOW AND BMW-COLOR IN 2 WINDOW IT MUST OPEN BWM-COLOR IN 3DE WINDOW...BUT IT GIVES AN ERROR
ERROR4:STRING LENGHT LIMIT EXCEEDED
AND I CAN'T RESOLVE THE ERROR . and i've used termmsg so i can see in the terminal .but it displays the textfile verry strange

THIS IS MY BMW-COLOR.TXT:

[BMWCOLORTESTS]
DVD/IDE-READ-TEST
DVD/IDE-ACCESS-TIME-TEST
DVD/IDE-DATA-TRANSFER-RATE-TEST
[/BMWCOLORTESTS]

[TESTS]
[DVD/IDE-READ-TEST]
NUMBER-OF-ITERATIONS =
RESERVED =
NUMBER-OR-RETRIES =
TIME-OUT-IN-SEC =
DATA-TRANSFER-MODE =00(MODE-0-DMA),10(MODE-1-DMA), 20(MODE-2-DMA), 01(MODE-0-PIO), 11(MODE-1-PIO), 21(MODE-2-PIO)
TEST-CONTINUE =00(NO), 01(YES)
TEST-CD =01(CARIN), 02(ABEX-TDR-840), 03(SIEMENS-VDO-ATOMOTIVE-ROADRUNNER)
[/DVD/IDE-READ-TEST]

[DVD/IDE-ACCESS-TIME-TEST]
ITERATIONS =
RESERVED =
RESERVED =
TIME-OUT-IN-SEC =
TEST-CONTINUE =00(NO), 01(YES)
TEST-CD =01(CARIN), 03(ABEX-TDR-840), 03(SIEMENS-VDO-ATOMOTIVE-ROADRUNNER)
[/DVD/IDE-ACCESS-TIME-TEST]

[DVD/IDE-DATA-TRANSFER-RATE-TEST]
NUMBER-OF-SECTORS-TO-READ =
RESERVED =
NUMBER-OR-RETRIES =
GLOBAL-TIME-OUT-IN-SEC =
PIO-DATA-TRANSFER-MODE =01(MODE-0-PIO), 11(MODE-1-PIO), 21(MODE-2-PIO)
RESERVED =
TEST-CD =01(CARIN), 02(ABEX-TDR-840), 03(SIEMENS-VDO-ATOMOTIVE-ROADRUNNER)
[/DVD/IDE-DATA-TRANSFER-RATE-TEST]
[/TEST]

does someone knoow how i can resolve this?
 
Hello,

I've seen this with STRCAT before. You may want to use STRFMT to see if this results the Issue.

Hank
 
Here is the latest script I came up with. It's based on the last script I posted instead of your latest version since I didn't have enough time to go through what you had written. Hopefully you can take what I wrote and modify it to use in your framework.

The first thing I did was modify the text file so it looks like this:

[NAVIGATIESYSTEMEN]
ROADRUNNER
HVM3
FIETS
[/NAVIGATIESYSTEMEN]
[TARGETS]
[ROADRUNNER]
BMW COLOR*BMW-COLOR.TXT
BMW MONO*BMW-MONO.TXT
BMW OCN*BMW-OCN.TXT
AN COLOR*AN-COLOR.TXT
AN MONO*AN-MONO.TXT
AN RADNAV*AN-RADNAV.TXT
[/ROADRUNNER]
[HVM3]
OPEL*OPEL.TXT
AUDI C6*AUDI-C6.TXT
AUDI ELISA*AUDI-ELISA.TXT
[/HVM3]
[/TARGETS]

I added the asterisk instead of the commas that divided the fields earlier so I could key off the asterisk using the strtok command. Take a look at the GetList2 and GetList3 functions to see how I use strtok to parse the lines of data from the text file and get the field I'm interested in. The script below will let you fill out values in the first three listboxes. Now I'm not sure exactly what you want to appear in the third list box. I currently display the name of the different text files, and I'm assuming that the contents of the text file selected in listbox 3 should appear in listbox 4. Is that right?

func Fgets_FR : string ; opens function and gives a string back.
param integer bestand ; parameter integer bestand.
string resultstring=&quot;&quot; ; string to contain resultstring, declare to be an emty string.
string temp ; string to contain temp.
integer endofline =0 ; integer to contain endofline.
integer karakter ; integer to contain karakter.
integer carret = 13 ; integer to contain carret.

while endofline==0 ; loop while.
if feof 0 ; if end of file.
endofline=1 ; endofline.
else
fgetc bestand karakter ; get karakter from bestand file.
if karakter==carret ; is karakter is equal to carret(13) then end of line.
endofline=1
else
if karakter>32 & karakter<127
strset temp 0 karakter 1 ; coverts an integer to a ascii string.
strcat resultstring temp ; concat. resultstring to temp.
endif
endif
endif
endwhile
return resultstring
endfunc

func GetList2 : string
param string sChoice
string sSearch1 = &quot;[]&quot;
string sSearch2 = &quot;[/]&quot;
string sResult = &quot;&quot;, sLine
string sTemp

strinsert sSearch1 sChoice 1
strinsert sSearch2 sCHoice 2

fopen 0 &quot;C:\voorbeeld.txt&quot; Read Text
while not feof 0
fgets 0 sLine
if strfind sLine sSearch1
fgets 0 sLine
while 1
strtok sTemp sLine &quot;*&quot; 1
strcat sResult sTemp
fgets 0 sLine
if strfind sLine sSearch2
exitwhile
endif
strcat sResult &quot;,&quot;
endwhile
endif
endwhile
fclose 0
return sResult
endfunc

func GetList3 : string
param string sChoice
string sSearch1 = &quot;[]&quot;
string sSearch2 = &quot;[/]&quot;
string sResult = &quot;&quot;, sLine
string sTemp

strinsert sSearch1 sChoice 1
strinsert sSearch2 sChoice 2

fopen 0 &quot;C:\voorbeeld.txt&quot; Read Text
while not feof 0
fgets 0 sLine
if strfind sLine sSearch1
fgets 0 sLine
while 1
strtok sTemp sLine &quot;*&quot; 2
strcat sResult sTemp
fgets 0 sLine
if strfind sLine sSearch2
exitwhile
endif
strcat sResult &quot;,&quot;
endwhile
endif
endwhile
fclose 0
return sResult
endfunc

proc main
string Fname = &quot;c:\voorbeeld.txt&quot; ; File name to be opened.
string FullList1
string FullList2
string Fulllist3
string Items ; Item selected from list.
string Items1
string Items2
string LineBuffer ; Line read from file.
string searchstring
string inhoudbox1 = &quot;&quot;
string inhoudbox2 = &quot;&quot;
integer Event
integer eindbereikt =0


searchstring = &quot;[NAVIGATIESYSTEMEN]&quot; ; declares searchstring
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring ; if searchstring is equal to linebuffer
searchstring = &quot;[/NAVIGATIESYSTEMEN]&quot; ; declares searchstring
while eindbereikt == 0
if feof 0
eindbereikt=1
else
LineBuffer = fgets_FR (0)
if strcmp LineBuffer searchstring
eindbereikt=1
else
strcat inhoudbox1 LineBuffer ; concat. inhoudbox1 to linebuffer
strcat inhoudbox1 &quot;,&quot; ; ends line with a &quot;,&quot;
endif
endif
endwhile
exitwhile
endif
endwhile
fclose 0
else
errormsg &quot;Kan file niet vinden `&quot;%s`&quot;.&quot; Fname ;kan file niet vinden
endif

termmsg inhoudbox1 ; shows inhoudbox1 on terminal


;the script whats above here is what i wrote new and whats beneeth(down) here is the old fullist script but the size of the comboboxen and dialogbox and text are good for the new script. so what's beneeth must be changed. but i want to solve my problems first and then change what's beneeth(down)

; Display a dialog box with a list of stuff to choose from.
FullList1 = &quot;TARGETS,AN,BMW,VOLVO,ENZOVOORTS&quot;
FullList2 = &quot;TESTS,fantest,audiotest,cdtest,beeldtest&quot;
Items = &quot;NAVIGATIEMODELLEN&quot; ; Set default item.
Items1 = &quot;TARGETS&quot;
Items2 = &quot;TESTS&quot;
dialogbox 0 1 16 676 379 2 &quot;Test Software&quot;
combobox 1 10 24 139 329 DROPDOWNLIST inhoudbox1 Items
combobox 2 172 24 139 329 DROPDOWNLIST Fulllist2 Items1
combobox 3 343 24 139 329 DROPDOWNLIST FullList3 Items2
combobox 4 522 23 139 329 DROPDOWNLIST FullList2 Items2
text 5 43 6 74 11 &quot;Navigatiemodellen&quot; left
text 6 224 6 34 10 &quot;Targets&quot; left
text 7 406 5 30 14 &quot;Tests&quot; left
text 8 570 4 45 12 &quot;Testcases&quot; left
enddialog




while 1

dlgevent 0 Event ; Get dialog event.

switch Event ; Evaluate the event.
case 0 ; No event occurred.
endcase
case 1 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items
Fulllist2 = GetList2(Items)
dlgupdate 0 2
endcase
case 2 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items1
Fulllist3 = GetList3(Items)
dlgupdate 0 3
endcase
case 3 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase
case 4 ; Check box item selected.
usermsg &quot;`&quot;%s`&quot; selected!&quot; Items2
endcase

default ; Exit method selected.
exitwhile ; Exit the while loop.
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy the dialog box.
endproc aspect@aspectscripting.com
 
yes knob that was what i mean thx hankm3 and knob for you're suggestions and help..it helped me a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top