Operators

C Scripting Language
Reference Manual
Version 4.4.0

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using the CSL executive
Language
   Comments
   Numbers
   Literals
   Var and const
   Operators
   Statements and blocks
   Program flow
   Trace facility
   Exception handling
   Functions
   Predefined identifiers
Directives
System library
String library
Math library
Regular expression lib.
File library
Database library
Async Communication
Registry/Profile handling
Windows control
C API
C++ Class Interface
CSL links
  

Operators in descending precedence:

Operators Comments
( ) [ ]  
! + - ++ -- & sizeof exists Unary pre/postfixes. & is only allowed in parameter lists
* / \ % \ is integer divide
- + | With + one or both operands may be a string (non-numeric) whereby string concatenation is performed instead of a numeric add.
| is the string concatenation operator.
< <= > >= If one or both operands are strings, a literally string-compare will take place.
== != If one or both operands are strings, a literally string-compare will take place.
&& Evaluation of A && B:
In CSL, B will always be evaluated.
In C/C++, B will only be evaluated if A is true.
|| Evaluation of A || B:
In CSL, B will always be evaluated.
In C/C++, B will only be evaluated if A is false.
= += -= *= /= \= %= |= With += source or target may be a string (non-numeric) whereby string concatenation is performed instead of a numeric add.
, Comma is used to group several expressions into a single statement.

There are no bitwise (| & ^^ ~~) and no conditional (? :) operators in CSL.

Expressions true/false evaluation:

  • if the expression is a number, zero values are false and nonzero values are true.

  • if the expression is no number, empty strings are false and nonempty are true.

The sizeof operator returns 1 for simple var's. For arrays it returns the number of elements for the given index:

var xy[5][4];

sizeof(xy);      // 20
sizeof xy[1];    // 4
sizeof xy[2][3]; // 1

The exists operator checks if a variable exists and returns 1 or 0. Within directives the condition is met if the var/const is declared despite the fact indexes may be invalid. In script code the var/const must be allocated and any indexes must be valid to return 1:

extern const a[];

#message exists maxSize       // 1, even if only declared but
                              //    not yet implemented
const a[3] = { 1, 2, 3 };

#message exists(maxSize[99])  // still 1, indexes are not checked!

foo()
{
   sysLog(exists a);      // 1
   sysLog(exists(a[1]));  // 1
   sysLog(exists a[99]);  // 0, indexes are checked in code!
}
  Copyright © IBK Landquart Last revision: 27.05.2002 << Back  Top  Next >>