Jump to content

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


xuzo
 Share

Recommended Posts

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")

 

Link to comment
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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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