jhegener Posted February 3, 2005 Share Posted February 3, 2005 Hi, I've created a tiny function to make it easier to debug variables in my scripts. Func Debug($DATA) ; Local $DISPLAY ; $display = string($DATA) MsgBox(0, "Debug", "[" & $DATA & "]") EndFunc When I don't seem to be getting the correct results from a script I just call the debug function: debug ($any_variable) and it will display the variable value at that point in the logic flow. What I just discovered is that, once I start working with more than a couple variables, it's tough to figure out which variable I'm looking at when the box pops up. As you can see from the rem'd out lines up above I've attempted to put the variable NAME ($file, $I, etc.) and not value into a local string variable which I could then incorporate into my msgbox display string. I can't seem to get it to work but I know it's probably something stupid that I'm missing. None of the string manipulation functions seem to do what I want. Any ideas? Jay Link to comment Share on other sites More sharing options...
Blue_Drache Posted February 3, 2005 Share Posted February 3, 2005 (edited) Hi,I've created a tiny function to make it easier to debug variables in my scripts.Func Debug($DATA); Local $DISPLAY; $display = string($DATA) MsgBox(0, "Debug", "[" & $DATA & "]")EndFuncWhen I don't seem to be getting the correct results from a script I just call the debug function: debug ($any_variable) and it will display the variable value at that point in the logic flow.What I just discovered is that, once I start working with more than a couple variables, it's tough to figure out which variable I'm looking at when the box pops up.As you can see from the rem'd out lines up above I've attempted to put the variable NAME ($file, $I, etc.) and not value into a local string variable which I could then incorporate into my msgbox display string.I can't seem to get it to work but I know it's probably something stupid that I'm missing. None of the string manipulation functions seem to do what I want.Any ideas?Jay<{POST_SNAPBACK}>Cake!Func Debug($DATA,$variablename="") ; Local $DISPLAY ; $display = string($DATA) MsgBox(0, "Debug", "$" & $variablename & "[" & $DATA & "]") EndFuncDownload the latest beta so you can use optional paramaters in your functions.Just call it like thisFunc Debug($variable,"variable") Edited February 3, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
jhegener Posted February 3, 2005 Author Share Posted February 3, 2005 Cake!Func Debug($DATA,$variablename="") ; Local $DISPLAY ; $display = string($DATA) MsgBox(0, "Debug", "$" & $variablename & "[" & $DATA & "]") EndFuncDownload the latest beta so you can use optional paramaters in your functions.Just call it like thisFunc Debug($variable,"variable")<{POST_SNAPBACK}>Thanks, I'll give it a shot!Although I was really looking for a function that could extract it from the passed variable itself rather than passing along a string to describe the variable. Link to comment Share on other sites More sharing options...
Valik Posted February 3, 2005 Share Posted February 3, 2005 Thanks, I'll give it a shot!Although I was really looking for a function that could extract it from the passed variable itself rather than passing along a string to describe the variable.<{POST_SNAPBACK}>No function exists and its not an easy thing to implement either. I did it once but the method wasn't pretty. Its probably for the best that Jon didn't take that particular bit of code. Link to comment Share on other sites More sharing options...
lupusbalo Posted February 3, 2005 Share Posted February 3, 2005 or you can take it the other way just try this: dim $abc,$xyz $abc="a string value" debug("abc"); see below for $sign $xyz=12345 debug("xyz") Func Debug($DATA) MsgBox(0, "Debug",$data & "=" & Eval($DATA)) ; remenber no $sign in front of the variable name EndFunc no $sign: I wonder why (implementation dependant?? or choosen??) 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