|
|
|||||||
Hello all. I am new to KiXtart scripting so I have a basic question/problem... First here is the code: Code: If InGroup("Group1") $Out = "Forced database to: Kroon Users" $x = WriteLine (9 , $tab + $Out + @CRLF ) $dbini = ReadProfileString($datafile, "Databases","Group1") $basisshare = $datashare + "\map\map1" EndIf If InGroup("Group2") $Out = "Forced database to: Kroon dealerdatabase" $x = WriteLine (9 , $tab + $Out + @CRLF ) $dbini = ReadProfileString($datafile, "Databases","Group2") $basisshare = $datashare + "\map\map2" $usergroup = "Usergroup" $Force = "CT70" Else $Out = "Forced database to: Kroon Users/Kroon dealerdatabase - No Permissions!!!" $x = WriteLine (9 , $tab + $Out + @CRLF ) $Out = "Rolling back ini update (if any)." $x = WriteLine (9 , $tab + $Out + @CRLF ) $error = WriteProfileString ($userfile, "Stations", $StationUsers[$FirstEmpty,1], " ") If $error <> 0 $Out = "Error writing to " + $userfile + ", quitting script" $x = WriteLine (9 , $tab + $Out + @CRLF ) EndIf Goto End EndIf As you can see there are 2 IF statements. Now the script doesn't execute as I want it to. Users only member of the Group1 do not connect to the right database because the 2nd IF statement is also executed and because they are not member of Group2 they are forced to End.(because of the Goto End statement. I have little programming experience and in other languages you could use the ELSEIF statement. That way there would be more options to use. But in KiXtart the ELSEIF doesn't work...(or I am programming it the wrong way). Is there another way to handle this problem? Do I need to use a SELECT here to get the right group for the users? I hope you understand what I am trying to explain. Thanks in advance. Daeseleer |
||||||||
|
|
|||||||
As I asked in my previous post I have tried to do it with a SELECT. I have tested it and it seems to work fine! Is it a correct way to use? Or are there other better options? Best regards, Daeseleer |
||||||||
|
|
|||||||
Yes, Select is the appropriate choice - it's like a multiple if statement, but only one choice is made. The thing to keep in mind with Select is the proper ordering of the comparisons. You might also need to employ AND or OR logic, so it takes a bit of extra planning. Glenn |
||||||||
|
|
|||||||
Kix does not have and ElseIf statement but it does have an Else statement so you could do something like shown below. Code: If $x = "1" ;Do stuff Else ;Do other stuff EndIf |
||||||||
|
|
|||||||
Indeed, But, in my case, if u need more then 2 options the IF-ELSE-ENDIF is not enough. Thanks for your replies. Daeseleer |
||||||||
|
|
|||||||
Select is the way to go... but else if is an option, just not with elseif Code: If $x = "1" ;Do stuff Else if $y= 1 ;Do other stuff else ;Do fun stuff endif EndIf |
||||||||
|
|
|||||||
And even Allen's example can also be placed within a SELECT CASE making it quite versatile scripting. |