Jump to content

Returning Multiple Values


James
 Share

Recommended Posts

Hey,

How can I return all these values in one message box?

Func DisplayOptions()
    $Option1 = GUICtrlRead($CDesktopShortcut)
    $Option2 = GUICtrlRead($RMainEXE)
    $Option3 = GUICtrlRead($SPasswordDialog)
    $Option4 = GUICtrlRead($DUSBWrongPassword)
    If $Option1 = $GUI_CHECKED Then
        Return "Desktop Shortcut on plugin!" & @CRLF
    EndIf
    If $Option2 = $GUI_CHECKED Then
        Return "Run Main.exe" & @CRLF
    EndIf
    If $Option3 = $GUI_CHECKED Then
        Return "Display password box" & @CRLF
    EndIf
    If $Option4 = $GUI_CHECKED Then
        Return "Wipe USB contents on wrong password" & @CRLF
    EndIf
EndFunc   ;==>DisplayOptions

-James

Link to comment
Share on other sites

Hi,

is this what you mean ?????? Johannes

MsgBox(4096, 'Info', _DisplayOptions)

Func _DisplayOptions()
    $sReturn=""
    $Option1 = GUICtrlRead($CDesktopShortcut)
    $Option2 = GUICtrlRead($RMainEXE)
    $Option3 = GUICtrlRead($SPasswordDialog)
    $Option4 = GUICtrlRead($DUSBWrongPassword)
    If $Option1 = $GUI_CHECKED Then  $sReturn = $sReturn & "Desktop Shortcut on plugin!" & @CRLF
    If $Option2 = $GUI_CHECKED Then  $sReturn = $sReturn &  "Run Main.exe" & @CRLF
    If $Option3 = $GUI_CHECKED Then  $sReturn = $sReturn & "Display password box" & @CRLF
    If $Option4 = $GUI_CHECKED Then  $sReturn = $sReturn & "Wipe USB contents on wrong password" & @CRLF
    Return $sReturn
EndFunc ;==>DisplayOptions
Edited by jlorenz1

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Link to comment
Share on other sites

Hello

I think that the need is to display all option checked.

Func DisplayOptions()
    $Option1 = GUICtrlRead($CDesktopShortcut)
    $Option2 = GUICtrlRead($RMainEXE)
    $Option3 = GUICtrlRead($SPasswordDialog)
    $Option4 = GUICtrlRead($DUSBWrongPassword)
    local $msg_return=""
    If $Option1 = $GUI_CHECKED Then
        $msg_return&="Desktop Shortcut on plugin!" & @CRLF
    EndIf
    If $Option2 = $GUI_CHECKED Then
        $msg_return="Run Main.exe" & @CRLF
    EndIf
    If $Option3 = $GUI_CHECKED Then
        $msg_return&="Display password box" & @CRLF
    EndIf
    If $Option4 = $GUI_CHECKED Then
        $msg_return&="Wipe USB contents on wrong password" & @CRLF
    EndIf
    Return $msg_return
EndFunc  ;==>DisplayOptions
Link to comment
Share on other sites

Even easier would be returning a array. Where you create a 2d array where it looks something like this.

$array[x][0] = "text you are looking for"

$array[x][1] = true/false

then out of the function you create something to check if value is true / false.

something like this:

...


$var = DisplayOptions(GUICtrlRead($CDesktopShortcut),GUICtrlRead($RMainEXE),GUICtrlRead($SPasswordDialog),GUICtrlRead($DUSBWrongPassword))
For $x = 0 to UBound($var) -1
    If $var[$x][1] = True
        ConsoleWrite($var[$x][0] & @CRLF)
    EndIf
Next

Func DisplayOptions($Option1,$Option2,$Option3,$Option4)
    
    Local $msg_return[4][2]
    $msg_return[0][0] = "Desktop Shortcut on plugin!"
    $msg_return[0][1] = False
    $msg_return[1][0] = "Run Main.exe"
    $msg_return[1][1] = False
    $msg_return[2][0] = "Display password box"
    $msg_return[2][1] = False
    $msg_return[3][0] = "Wipe USB contents on wrong password"
    $msg_return[3][1] = False
    
    If $Option1 = $GUI_CHECKED Then
        $msg_return[0][1] = True
    EndIf
    If $Option2 = $GUI_CHECKED Then
       $msg_return[1][1] = True
    EndIf
    If $Option3 = $GUI_CHECKED Then
        $msg_return[2][1] = True
    EndIf
    If $Option4 = $GUI_CHECKED Then
        $msg_return[3][1] = True
    EndIf
    
    Return $msg_return ;will return the whole array.
EndFunc  ;==>DisplayOptions
Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...