Maffe811 Posted June 7, 2011 Share Posted June 7, 2011 Now, the reason i started with AutoIt was that it would hopefully lead me into the coding world and learn the basics before i took on C.Now my friend that helped me get going, thinks im rappidly progressing with AutoIt and he suggested i should look at C++.So im looking at some example scripts when i get to the script below.And my question is, do AutoIt have an equvilant(?) to n-- ?Because i have always used n=n-1.// countdown using a for loop #include <iostream> using namespace std; int main () { for (int n=10; n>0; n--) { cout << n << ", "; } cout << "FIRE!\n"; return 0; } [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
jvanegmond Posted June 7, 2011 Share Posted June 7, 2011 (edited) The question is, why not: for (int n=10; n>0; n-=1) { Edited June 7, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Developers Jos Posted June 7, 2011 Developers Share Posted June 7, 2011 And my question is, do AutoIt have an equvilant(?) to n-- ? Because i have always used n=n-1. Closest thing in AutoIt3 is: $n -= 1 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...
Mobius Posted June 7, 2011 Share Posted June 7, 2011 (edited) In the c source the n-- component of the for loop as you would expect is to decrement integer n by 1, within a for loop in AutoIt3 the facility of the increment / decrement instruction is handled by the optional STEP parameter, default c equivelent without the step parameter would be n++ AutoIt3 example _Main() ; FUNC _Main() FOR $n = 10 TO 1 STEP -1 ConsoleWrite($n &',') NEXT ConsoleWrite('FIRE!'& @LF) RETURN 0 ENDFUNC Edited June 7, 2011 by Mobius Link to comment Share on other sites More sharing options...
Maffe811 Posted June 7, 2011 Author Share Posted June 7, 2011 The question is, why not: for (int n=10; n>0; n-=1) { Its not my script. Its an example script. Closest thing in AutoIt3 is: $n -= 1 Okay, thats what i needed to know I expect $n += 1 goes upwards ? In the c source the n-- component of the for loop as you would expect is to decrement integer n by 1, within a for loop in AutoIt3 the facility of the increment / decrement instruction is handled by the optional STEP parameter, default c equivelent without the step parameter would be n++ AutoIt3 example _Main() ; FUNC _Main() FOR $n = 10 TO 1 STEP -1 ConsoleWrite($n &',') NEXT ConsoleWrite('FIRE!'& @LF) RETURN 0 ENDFUNC Okay, so now i have both the $n -= 1 and The Step parameter to use. Thanks for clearing it up for me [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
Mat Posted June 7, 2011 Share Posted June 7, 2011 The question is, why not: for (int n=10; n>0; n-=1) { and why not: for (int n=10; n>0; n+=-1) { They all compile the same in the end. AutoIt Project Listing Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 7, 2011 Share Posted June 7, 2011 Okay, thats what i needed to know I expect $n += 1 goes upwards ?Sure does There are some others too, see Helpfile > Language Reference > Operators .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Valik Posted June 8, 2011 Share Posted June 8, 2011 C++ source code is not called "script". Link to comment Share on other sites More sharing options...
Maffe811 Posted June 8, 2011 Author Share Posted June 8, 2011 Should i just call it C++ code then ? [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
ProgAndy Posted June 8, 2011 Share Posted June 8, 2011 Should i just call it C++ code then ?That's right. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Maffe811 Posted June 8, 2011 Author Share Posted June 8, 2011 Ask for one thing, then you learn two things. I love this forum. [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] 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