yucatan Posted October 20, 2008 Share Posted October 20, 2008 hi i have a $var and that is used in a func and it get declared in a func so i wanne do add something global $item += 3 why that dont work i want in a func to do this global $item += 3 when i do that i get syntax error when i do $item += 3 the $var changes in that func but not in another func.. how i can fix this ? Link to comment Share on other sites More sharing options...
enaiman Posted October 20, 2008 Share Posted October 20, 2008 If you need your $item variable to be a global one then declare it somewhere inside your main script. "Global $item" will create the variable in the global scope (know all over the script). After you create the variable you can increment it, that's why you get an error for "global $item += 3" SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
yucatan Posted October 20, 2008 Author Share Posted October 20, 2008 If you need your $item variable to be a global one then declare it somewhere inside your main script."Global $item" will create the variable in the global scope (know all over the script).After you create the variable you can increment it, that's why you get an error for "global $item += 3"teh whole func is in a func i cannot run that part in the main script it just cant there got to be a way:S... Link to comment Share on other sites More sharing options...
enaiman Posted October 20, 2008 Share Posted October 20, 2008 Then break that line: Global $item $item +=3 SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
therks Posted October 21, 2008 Share Posted October 21, 2008 That will reinitialize $item to 0.At the top of your script (OUTSIDE the func) just put Global $item.Tadaa, no problems. My AutoIt Stuff | My Github 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