Jump to content

C++ question!


Maffe811
 Share

Recommended Posts

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

  • Developers

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

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 by Mobius

wtfpl-badge-1.png

Link to comment
Share on other sites

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 :huh2:

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

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

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

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

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