Encyclopaedia Index

Character variables in PIL

The user can declare and use character variables in the same way as INTEGERs and REALs. The default maximum number of character variable is 50, but this can be altered in SATLIT.

Variables are declared by the command CHAR (CHARACter being already reserved PIL word); eg CHAR(CH1,CH2,CH3,CH4).

CHAR variables, which are 68 elements long, are defaulted to a blank line.

Variables are assigned by statements such as:

CH1 =

Permitted character expressions are:

:: or any concatenation of these two.

If, for example, the following PIL instructions are issued:

NX=2;NY=4;NZ=8
CHAR(CH1,CH2,CH3)
CH1=XXX;CH2=XXXZZ

the following assign the indicated values to CH3 ;
CH3=CH1 is equivalent to CH3 = CH1
CH3=:CH1: is equivalent to CH3 = XXX
CH3=CH1:CH1:QQQ:CH2: is equivalent to CH3 = CH1XXXQQQXXXZZ

The values of individual variables can be ascertained by typing the variable name (as with integers and reals). Alternatively, typing SEE C gives the values of all currently-declared character variables

Expression Substitution

Character-variable names placed between colons have their values substituted for their names. This process is actually carried out at a pre-processing stage and applies to integer and real expressions a well as character-variable names. It therefore has more power than merely allowing string concatenation, as will now be illustrated.

The following two PIL statements are exactly equivalent:

NX=4;PATCH(INL:NX:,NORTH,1,:NX:,1,NY,1,1,1,1)
NX=4;PATCH(INL4,NORTH,1,4,1,NY,1,1,1,1)

This feature can be used to set real or integer variables from character variables, as shown below:

REAL(RR);CHARACTER(CC)
CC=4.5
RR=:CC:
XFRAC(4)=:RR:

However, RR=CC would elicit an 'Invalid variable' message.


CHARACter

-----------------------------------

The following character variables are recognised by PIL:

TITLE, NAMFI, NAMGRD, NAMSAT, NAMXYZ, NSAVE, CSG1, CSG2, ..., CSG10.

The following character arrays are recognised by PIL:

CG, NAME, NAMPAT.

See the entry CHAR for declarations of users' own character variables.

wbs