Jump to content

Should += work inside a function?


Recommended Posts

Was trying to perform a simple operation inside the INIWrite function. I at least thought it was simple. I was trying to use the operator += inside the INIWrite function and it failed.

Non-working...

INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration += 1)oÝ÷ Ùj+)àjëh×6  $i_Iteration += 1
    INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration)

Is this expected behavior? I haven't the time to test in other functions, but I thought it would/should work.

Thanks,

Jarvis

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

Was trying to perform a simple operation inside the INIWrite function. I at least thought it was simple. I was trying to use the operator += inside the INIWrite function and it failed.

Non-working...

INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration += 1)oÝ÷ Ùj+)àjëh×6  $i_Iteration += 1
    INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration)

Is this expected behavior? I haven't the time to test in other functions, but I thought it would/should work.

Thanks,

Jarvis

Don't see why it would/should work. IniWrite() is really looking for a string there although it will accept a number the number will be handled as a string so you can't perform a math operation inside the function call.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • Developers

in this case I would expect it to look like this: INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration + 1),

because this is not a common way of doing it: INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration = $i_Iteration + 1)

:)

Edited by Jos

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

Was trying to perform a simple operation inside the INIWrite function. I at least thought it was simple. I was trying to use the operator += inside the INIWrite function and it failed.

Is this expected behavior? I haven't the time to test in other functions, but I thought it would/should work.

Thanks,

Jarvis

I think there is a difference between the two:

Assignment, where a value is assigned to a variable but there is no external return value.

Evaluation, where a value is returned from an operation, but not assigned to a variable.

Inside a function you can use the returned value from evaluation as a parameter, but attempted assignment triggers syntax errors.

Don't see why it would/should work. IniWrite() is really looking for a string there although it will accept a number the number will be handled as a string so you can't perform a math operation inside the function call.

Native AutoIt functions expecting strings effectively perform String() on whatever they are given, which can be the evaluation of a math expression (including variable values), as long as there is no assignment in it. This would work:
IniWrite($sIniFile, "Math_Section", "Cube_Root_Of_" & $i & "_Squared", ($i ^ 2) ^ -3)

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

By the way whats wrong with just using the + operation?

INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration +1)

NM, Just your everyday bad idea.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

in this case I would expect it to look like this: INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration + 1),

because this is not a common way of doing it: INIWrite("RestartPC.ini", "RestartPCSettings", "iteration", $i_Iteration = $i_Iteration + 1)

:)

Jos

This would seem to be the solution I was looking for as I don't really care if $i_Iteration has a new value or not. I just want the new value in the file. However, I added () to the equation, and I would have thought that to fix the assignment operation as I have used $i += somenumber inside other functions. I don't have any examples off the top of my head, and I could be mistaken, which is why I brought it here to the community. :o

I have it working, but I might just change it to your suggestion Jos as it makes more sense to me as to what I really want done.

Thanks for all the replies!

Jarvis

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

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