If it equals?

Klaus Major k_major at os.surf2000.de
Thu Aug 22 12:22:01 EDT 2002


Bonsoir Yves, hi Josh and Trevor,

>> One more thing I forgot to mention. I would like to include the Coded
>> Password on the same line of the Name. How would I retrieve the 
>> password
>> after the person has entered his name, and make sure it is the correct
>> password? Thanks!
>
> If you have two items per line then just set the itemDelimiter to 
> whatever seperates them. Then we comparing the username and password 
> you can say:
>
> repeat i = 1 to the number of lines in myFile
>   if loginname is equal to item 1 of line i of myFile then
>     if password is equal to item 2 of line i of myFile then
>       -- password is good
>       exit repeat
>     else
>       -- password is bad
>     end if
>   else
>     -- bad login name
>   end if
> end repeat
>
> Trevor DeVore


as usual, a repeat loop with "for each" will be incredibly faster.

Just in case the userbase will grow you could script:
(Presumed that the lines are in this format: username TAB coded password)

...
set the itemdel to TAB
repeat for each line l in myFile
    if item 1 of l is the_user then
     put item 2 of l into the_password
     exit repeat
   end if
ask "Please enter more money ehmm your password"
if it is the_password then
   do_the_right_thing
end if
...

"for each" can process up to thousands of lines in a fraction of a 
second !
No foolin' ;-)

Hope that helps...


Regards

Klaus Major
k_major at os.surf2000.de




More information about the Use-livecode mailing list