xuzo

How to learn the syntax, what can be done or not, what works or not?

5 posts in this topic

I'm having a hard time knowing how to input the code, I always get it wrong and don't know where to start for example, how do I learn where to put ' or " or { or { ect....

The first example works, with trial and error, but I wish I could learn how to do this right...

 

MsgBox(0, "Saved Variables", $title & @CRLF & $city & @CRLF & $country)
MsgBox(0, "Saved Variables", "$title & @CRLF & $city & @CRLF & $country")
MsgBox(0, "Saved Variables", "$title" & @CRLF & "$city" & @CRLF & "$country")

 

Share this post


Link to post
Share on other sites



A good place to start learning AutoIt is the help file (esp. the first chapters) and the wiki where you will find some tutorials.

In your case it is easy: You enclose a string in " or '. If you want to output the content of a variable do not use " or '.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Difficult to answer as you do not give any background on other languages you know

start from scratch:  https://scratch.mit.edu/projects/editor/?tip_bar=getStarted

start early: http://www.calormen.com/jslogo/

start basic: http://www.calormen.com/jsbasic/

Basic elements of any programming language (and once you now that it should not be hard to learn a new one), you can find details in AutoIT help

  • Keywords/reserved words
    if then else function 
  • variables and constants
    In AutoIT starts with $     (however I remember experimental that its not required)
    constants start with a @
  • loops
    for while
  • blocks that start with { and end with }
  • Conditionals like:   if then else endif 
  • input and output
  • functions and subs

As in your example it depends on what you try to accomplish

https://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm

so the 0 you give would have been better to give $MB_OK

You probably wanted

$city="Amsterdam"
$country="The Netherlands"
MsgBox($MB_OK, "The title I wan to see on top of my messagebox", "A multiline text " & @CRLF & "showing the city: " & $city & @CRLF & " a country: " & $country & @CRLF)

My advices is to write first like this and over time you combine it in functions, it makes your code clearer to understand (however in the end its just a coding style)

$city="Amsterdam"
$country="The Netherlands"
$myText=""
$myText=$myText & "A multilinetext" & @CRLF
$myText=$myText & " Showing the city" & $city & @CRLF
$myText=$myText & " Showing the country" & $country & @CRLF
MsgBox($MB_OK, "The title I wan to see on top of my messagebox", $myText)

And in the end if you want to understand any programming language build a compiler yourself with for example http://www.antlr.org/

 

Edited by junkew

Share this post


Link to post
Share on other sites

you can find details in AutoIT help

You forgot thehelpfile FAQ, especially (in this case) the #5   :)

Share this post


Link to post
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