View Single Post
Old 08 July 2015, 16:21   #41
BigFan
Registered User
 
BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
Reserved special characters

Time for more basic stuff

In a previous example we addressed DirOpus and send a command named "Verify" to
open a requester. If you quickly browse the list of functions ARexx supplies, you
will find a function with exact same name.
How does ARexx know?
There is a tiny variation in our code that has a big effect on how ARexx interpretes
what we wrote.

A command is interpreted if it has no adjacent special characters like "." or "("
Moving open parenthesis next to it, turns the command into a function.
Set a period close to it and it will be identified as a stem.
Wrap it in ' ' and ARexx handles a string.
ARexx will check its internal table of symbols before interpreting a symbol as command.

ARexx will complain about any syntactic error that does not accidentily fits a
correct expression, command, function or statement.

Reserved special chars

. "dot" used for stems
, "comma" glues multiple lines into one statement if you need more space to code
() "parentheses" identifies priorization
( "open parenthesis" plus symbol = function
; "semicolon" seperates statements
: "colon" identifies a label

Some commands require a counterpart to be interpreted correctly:

Do ... End
Select ... End
If ... Then
When ... Then


What happens if code contains a symbol of same name as function or command?

In most cases this will cause an error message that is quite irritating. Or as in
example below, nothing happens at all.
Think of the following code:

Code:
/**/
string = 'This is a string with a number 42'
num = Words(string)  /* counting words , num contains now value 8 */
If Datatype(Word(string, num)) = NUM ,  /* check if last word is of numeric type*/
Then Say "We have a number!"
The string "We hav..." doesn't show up.
"If" conditiona checks against 8 not NUM. Remember, we deal with upper case mostly.
Our symbol num is NUM.

If you insist on the usage of num, then you have to wrap NUM in single quotes.
Code:
If Datatype(Word(string, num)) = 'NUM'
Now ARexx differentiates.

Same with commands. If a symbol exists that shares same name with a command used
by a host, wrap the command in quotes.

Your own functions may have same name as a command, use quotes for the command.

See upcoming chapter about function and procedure.

Last edited by BigFan; 08 July 2015 at 17:23.
BigFan is offline  
 
Page generated in 0.04525 seconds with 11 queries