forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


"match" function bug?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
SK
Newbie


Joined: 29 Dec 2003
Posts: 14

PostPosted: Sat Jan 10, 2004 4:08 pm    Post subject: "match" function bug? Reply with quote

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"... Shocked
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
View user's profile Send private message Send e-mail
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Sat Jan 10, 2004 4:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Jan 10, 2004 7:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
SK
Newbie


Joined: 29 Dec 2003
Posts: 14

PostPosted: Sat Jan 10, 2004 11:14 pm    Post subject: Reply with quote

Thank you guys for help!
_________________
SK
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group