View previous topic :: View next topic |
Author |
Message |
SK Newbie
Joined: 29 Dec 2003 Posts: 14
|
Posted: Sat Jan 10, 2004 4:08 pm Post subject: "match" function bug? |
|
|
Here is the situation:
I have 4 files named 1.txt, 2.txt, 11.txt, 12.txt
and here is the program code:
Code: |
title Match
inifile open,@path(%0)\file.ini
dialog create,Match,-1,0,200,65
dialog add,combo,Com1,5,5,190,25
dialog add,button,But1,35,5,190,,Close
dialog show
list create,1
list filelist,1,@path(%0)\Files\*.txt
repeat
%A = @next(1)
if %A
list add,Com1,@name(%A)
end
until @null(%A)
list close,1
%A = @match(Com1,@iniread(main,history))
:EvLoop
wait event
goto @event()
:But1Button
:Close
inifile write,main,history,@item(Com1)
exit
|
when i choose "2", and than closing the program, the next time i open it, 'match' function returns "12" instead of "2"...
I know it's posible to resolve this problem by renaming file 2.txt > 02.txt
... But functon should MATCH the string as following from its name. _________________ SK |
|
Back to top |
|
|
Vic D'Elfant Past Contributor
Joined: 26 Jun 2002 Posts: 673 Location: The Netherlands
|
Posted: Sat Jan 10, 2004 4:35 pm Post subject: |
|
|
You've got to put an @equal loop after the @match function... see the code below:
Code: |
title Match
inifile open,@path(%0)\file.ini
dialog create,Match,-1,0,200,65
dialog add,combo,Com1,5,5,190,25
dialog add,button,But1,35,5,190,,Close
dialog show
list create,1
list filelist,1,@path(%0)\Files\*.txt
repeat
%A = @next(1)
if %A
list add,Com1,@name(%A)
end
until @null(%A)
list close,1
while @match(Com1,@iniread(main,history))
if @equal(@item(Com1), @iniread(main, history))
%A = 1
end
wend
:EvLoop
wait event
goto @event()
:But1Button
:Close
inifile write,main,history,@item(Com1)
exit
|
I think this should work (I had no time to test it, though)
Best regards,
Vic _________________ phpBB Development Team |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Jan 10, 2004 7:15 pm Post subject: |
|
|
One other note here...
Always seek your list to index 0 before using @match(). If you don't, it
will seek from the index that the list is currently set to. If it has found a
match and you want to continue to look for another match of the same
name, then do not seek back to 0 again, just keep going. But if you
need to match different name after the first match, then seek to 0 index
again.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
SK Newbie
Joined: 29 Dec 2003 Posts: 14
|
Posted: Sat Jan 10, 2004 11:14 pm Post subject: |
|
|
Thank you guys for help! _________________ SK |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|