Jump to content

Associating two variables.


anandnz
 Share

Recommended Posts

Hi Experts,

I am trying to associate two lists or arrays, so that i can control the execution just by True or False.

I need this in autolt commands and any better ideas would be greatly appreciated.

char str[2][2] = { "Arnold", "Yes"}

{"Tony","No"}

int i = 0, j =0

for i =0, i<2, i++

{

if str[i+1] == "Yes"

func();

else i = i+1

}

I tried this way which works but it comes from me, a beginner.

Local $CR[3] = ["notepad++.exe", "notepad++.exe","notepad++.exe"]
Local $sta[3] = ["1","0","1"];  Idea is to control the flow of execution, just declaring "Yes" or "No" or "1" or "0"
Local $cnt = 0
For $cnt= 0 to 2 Step 1
    ConsoleWrite("status =" & $sta[$cnt] & @CRLF)
    $command = "C:\Program Files\Notepad++\" & $CR[$cnt]
    $command2 = "notepad.exe"
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $command = ' & $command & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;
    if $sta[$cnt] = 1 Then
        Run($command2)
    Else
        Run($command)
    EndIf
Next

Please help me in this . Thanks in advance.

Thanks

Link to comment
Share on other sites

anandnz,

Questions about the code that look like C:

- the var "j" is not used, what is it for

- is str[2][2] a multi-dimensional array?

- is it your intention to reference subscript 0,1 from subscript 0,0?

I have a rough translation of this code but it is completely illogical.

With reference to you Autoit code:

It looks like you are associating a name with a boolean value and matching it up to a corresponding action (program to run in this case). Is that true?

Also, I don't really see a question in your thread.

Perhaps if you define what exactly you want to do you will have an easier time getting help.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I think you will find that a 2D Array (with 2 indexes) is what you want

#include <Array.au3>    ;only needed for _ArrayDisplay()
Local $CR[3][2] = [["notepad++.exe", True],["notepad++.exe", False],["notepad++.exe", True]]
_ArrayDisplay($CR)

For $cnt = 0 To UBound($CR) - 1
    ConsoleWrite("status =" & $CR[$cnt][1] & @CRLF)
    $Command = "C:\Program Files\Notepad++\" & $CR[$cnt][0]
    $command2 = "notepad.exe"
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $command = ' & $Command & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;
    If $CR[$cnt][1] Then
        MsgBox(262208, 'Result from instance ' & $cnt, $command2)
    Else
        MsgBox(262208, 'Result from instance ' & $cnt, $Command)
    EndIf
Next

Link to comment
Share on other sites

Apologies and Thank you kylomas.

Yes my intention is to match the variable to a boolean, a user can change. I trimmed the program just to get the bits and pieces

and i missed out on some variable. I missed your message as it was late night my end. Thanks mate.

anandnz,

5:00AM here, got to crash, good luck!!

kylomas

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...