Watcher Posted December 6, 2004 Share Posted December 6, 2004 Really basic question I'm sure, but I'm stuck! Here's what's going on. I have a global variable list of $abcX1 = 100, $abcY1 = 200, $abcX2 = 500, etc. I'm trying to string $abcX and an incrimenting number $num together into a single variable for a coordinate lookup. I.E. $positionx = ("$abcX" & $num). Instead of getting a 100, I of course get that $positionx = $abcX1. How can I get this to show that $positionx = 100? Thanks! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 6, 2004 Developers Share Posted December 6, 2004 (edited) Really basic question I'm sure, but I'm stuck! Here's what's going on.I have a global variable list of $abcX1 = 100, $abcY1 = 200, $abcX2 = 500, etc.I'm trying to string $abcX and an incrimenting number $num together into a single variable for a coordinate lookup. I.E. $positionx = ("$abcX" & $num). Instead of getting a 100, I of course get that $positionx = $abcX1. How can I get this to show that $positionx = 100?Thanks!<{POST_SNAPBACK}>have a look at Eval()eg:$abcX1 = 100 $abcY1 = 200 $abcX2 = 500 $num=1 $positionx = Eval("abcX" & $num) Edited December 6, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Watcher Posted December 6, 2004 Author Share Posted December 6, 2004 have a look at Eval()eg:$abcX1 = 100 $abcY1 = 200 $abcX2 = 500 $num=1 $positionx = Eval("abcX" & $num)<{POST_SNAPBACK}>Eval() gave me what I was looking for. Thanks much! Link to comment Share on other sites More sharing options...
Watcher Posted December 6, 2004 Author Share Posted December 6, 2004 Doh! Ok, thought Eval fixed the problem (I got "did not declare variable" trying it your way Larry), but Eval only seems to be getting me past errors, not giving the correct output. I'll give another example: $target = Eval("F" & $person) If $hexcoord NOT = $hexscan Then Call("TargetSelect") ..... ;Target Select Func TargetSelect() If $target = "F1" Then Send("F1") ElseIf $target = "F2" Then Send("F2") ElseIf $target = "F3" Then Send("F3") ElseIf $target = "F4" Then Send("F4") ElseIf $target = "F5" Then Send("F5") Else send("END") EndIf EndFunc I'm getting the END message when trying to run this, so Eval doesn't seem to be sticking the F and 1 (which is what $person is set to) together recognizably. Anything look obviously wrong? Also, how do you output variables in an error message in AutoIt? I tried using a splash screen, but the variable would not output, so I couldn't see exactly what $target was set to. Any help is appreciated. Thanks! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 6, 2004 Developers Share Posted December 6, 2004 Any help is appreciated.<{POST_SNAPBACK}>The easiest way to debug these kind of issues is to put a msgbox(0,'debug','|' & $target & '|' ) in your TargetSelect() function.This will then display the exact content between the vertical bars.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 6, 2004 Share Posted December 6, 2004 Okay, I think the eval would only be for the number scenario. So to do what you are trying to do above just do the following $target = "F" & $person If $hexcoord NOT = $hexscan Then Call("TargetSelect") EndIf Func TargetSelect() If $target = "F1" Then Send("{F1}") If $target = "F2" Then Send("{F2}") If $target = "F3" Then Send("{F3}") If $target = "F4" Then Send("{F4}") If $target = "F5" Then Send("{F5}") Else Send("{END}") EndIf EndFunc I am assuming you are actually wanting to press the key F1 not just send the text of F1 to something, so I took the liberty of adding the proper code for that as well. Also as you asked, the best way to debug/troubleshoot I have found is using message boxes as follows below. MsgBox(0, "Your Title Here", "Some text " & $variable & "more text " & $vairable2) I hope some of this helps, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Watcher Posted December 6, 2004 Author Share Posted December 6, 2004 Ok, those posts were really helpful, and I've got it down to one last problem: If $hexcoord NOT = $hexreturn Then Call("TargetSelect") ... Even though I can verify through messages that the 2 variables are not the same, this If statement won't work. I'm thinking maybe it's a syntax problem (because I could find no examples of the NOT syntax in the helpfiles). Ideas? Thanks again for everyone's help up to this point. Link to comment Share on other sites More sharing options...
Watcher Posted December 6, 2004 Author Share Posted December 6, 2004 If $hexcoord NOT = $hexreturn should beIf $hexcoord <> $hexreturncourse you could...If Not ($hexcoord = $hexreturn)i think...wait... that looks bad<{POST_SNAPBACK}>The <> got it. Thanks Larry! I had it ingrained in my head that I was going to use a NOT= like != Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now