Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 11 of 11
  1. #1
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73

    Multiple IF statements

    Hey everyone. What I'm trying to do is create a button that when clicked:

    a)prompts the user to enter a password(using Dialog.Input not PasswordInput)

    b)Generates an MD5 string for the password and compares it with 7 other MD5 strings

    c)depending on the MD5 string returned, performs a specific action

    d)if the MD5 generated by the user input does not match any of the 7 other strings, pops up a message telling them the password was incorrect.

    I accomplished a, b and c with relative ease, but the use of multiple "if" statements disallows me to use an "else" statement(or so I think is the problem). The reason for this is to install specific language files onto the users computer for my app. For security reasons, only specific users should be able to install/use specific language files and creating an install for each language would be a giant pain in the butt. The files will be stored in pw-protected ZIP's. I know this isnt the most secure thing in the world, but most of the users arent all that computer literate so its good enough for our purposes.

    the script is below, note at this time with successful password input I only bring up a dialog box telling me which was entered. This is just for testing purposes. Also for testing purposes, I have only made if statements for 4 of the 7.
    function lang_pw()
    -- the MD5 strings for passwords by language
    French_MD5 = "2ed6ab3d9b07c9a2f8ef51e913fae686"
    Italian_MD5 = "6b74b87b7e2b049604ad96c59c36b42f"
    Spanish_MD5 = "90ef5e6d211ded4e06dda0d265649e2b"
    Russian_MD5 = "b8003391845c34bae900086c90656b3e"
    Polish_MD5 = "880388188c719d0de116ce411919fb2f"
    German_MD5 = "be66863ed1ecaf17935914f3ad5f2485"
    Port_MD5 = "337f9174218c70f5a663cc2e24032898"
    -- prompt the user to enter password
    user_password = Dialog.Input("Password", "Please enter the password provided to you:");

    -- Calculate MD5 from user password
    user_password_md5 = Crypto.MD5DigestFromString(user_password);

    -- Compare the users password with language passwords
    if user_password_md5 == French_MD5 then French_Install = Dialog.Message("French!", "You have entered the french pw", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end
    if user_password_md5 == Italian_MD5 then Italian_Install = Dialog.Message("Italian!", "You have entered the Italian password", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end
    if user_password_md5 == Spanish_MD5 then Spanish_Install = Dialog.Message("Spanish!", "You have entered the Spanish password", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end
    if user_password_md5 == Russian_MD5 then Russian_Install = Dialog.Message("Russian!", "You have entered the Russian password", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end
    end

  2. #2
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Use elseif:

    Code:
    if YourConditon1 then
    	--first condition
    elseif YourCondition2 then
    	--second condition
    elseif YourCondition3 then
    	--third condition
    else
    	--anything else
    end

  3. #3
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    73
    ahhhh, i knew this had to be really simple. Im just really really new to scripting in general. Thanks alot Worm.

  4. #4
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    No problem. It can be a bumpy ride sometimes when you're starting out. The road smoothes out dramatically after you driven for a while
    Last edited by Worm; 12-29-2005 at 02:33 PM.

  5. #5
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    And especially when you have "smoothers" along the way to help you.... Right Worm?

    Yossi

  6. #6
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Ya mon! Fer Sure

  7. #7
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Quote Originally Posted by Worm
    Ya mon! Fer Sure
    Hey! That's my own personal dialect. You dun'did stolenz it furm me!

    Intrigued

  8. #8
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    Switch Function

    Quote Originally Posted by Worm
    Use elseif:

    Code:
    if YourConditon1 then
    	--first condition
    elseif YourCondition2 then
    	--second condition
    elseif YourCondition3 then
    	--third condition
    else
    	--anything else
    end
    Worm,

    Don't we have the switch-case-break condition function? I can't find examples on it.

    Any leads?

  9. #9
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Nothing like that in LUA. I've looked and found some functions that do essentially the same, but it was just as easy to use If/ElseIf

  10. #10
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    Web Server Engine

    Quote Originally Posted by Worm
    Nothing like that in LUA. I've looked and found some functions that do essentially the same, but it was just as easy to use If/ElseIf
    Hi,

    Thank you for pointing out clearly.

    By the way, I tested your LuaCom Web Server engine. Will it grow and morphed into a PHP5 Engine in AMS suite?

  11. #11
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Not on my watch... I was only playing around with a new toy Brett gave us. More trying to figure out how it worked rather than make a "real" app.

Similar Threads

  1. playing Multiple video files in a LOOP
    By Stan Hamers in forum AutoPlay Media Studio 5.0
    Replies: 11
    Last Post: 05-21-2005, 02:14 PM
  2. Playing Multiple Video Files in Sequence
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 09-26-2003, 11:10 AM
  3. Spanning Content Across Multiple CD's
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 09-22-2003, 03:38 PM
  4. HOWTO: Make an Install that Spans Multiple CD-ROMs
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-11-2002, 03:36 PM
  5. Default text in edit field - Multiple edit screen
    By Romahe in forum Setup Factory 6.0
    Replies: 1
    Last Post: 12-18-2001, 01:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts