**CIGAL Reference Manual, Chapter 1 (Topics): strings** ===== Strings -- Using Character Strings in CIGAL ===== CIGAL recognizes non-numerical text in three different forms: as unquoted character strings, as quoted character strings, and as character string variables. __**Unquoted Character Strings**__ Words entered without quotation marks are first assumed to have some special meaning to CIGAL. An unquoted word is first looked up in the tables of defined preprocessor strings, command names, and variable names. If it is found in one of those tables it is coded accordingly. If the word starts with a special character (i.e., other than letters, numbers, '.', and '_') then it is assumed to be a arithmetic operator or a variable name and must conform to CIGAL's naming syntax (see [[jvs:cigal:manual:chapter1:arithmetic|ARITHMETIC(1)]] and [[biac:jvs:cigal:manual:chapter1:variables|VARIABLES(1)]]). If it doesn't fall into any of these catagories, and the word is at the beginning of a command line or is followed by a '(' character, then it is interpreted as the name of a macro program. Terms in parentheses are passed as arguments to the macro (see [[jvs:cigal:manual:chapter1:syntax|SYNTAX(1)]]). If after all that, the word is still not recognized, then it is treated as a simple character string. Therefore you can use unquoted strings as filenames or to assign to string variables, or whatever, provided that they don't get misinterpreted as something else during the parsing process just described. In general, as long as a word doesn't start with any unusual characters and isn't a known variable name (see [[biac:jvs:cigal:manual:chapter1:names|NAMES(1)]]) you probably don't need to bother with quotation marks. However, if you have any problem using a character string as a command argument you should put quotes around it just in case. (See comments below regarding '\' characters in quoted strings.) __**Quoted Character Strings**__ Anytime that a CIGAL command expects a character string argument in a command line, you can enter that string within quotation marks. You can use either single (') or double (") quotes, CIGAL does not distinguish between them except that you must end the string with the same quotation mark you used at the beginning. Quoted character strings can contain any character. CIGAL's usage of quoted strings is based on the C language style, except that strings are not, in general, null terminated and therefore may contain the ASCII 0 code. Letters in quoted strings are not converted to lower case. All characters are passed exactly as they appear except for the beginning and ending quotation marks and special characters preceded by a backslash (\) character. The backslash is used to enter special character codes according to the following table: Usage Stored Character ASCII code Comment ===== ================ ========== ======= \' ' 39d (47o) \" " 34d (42o) \n newline 10d (12o) prints as Newline+CarriageReturn \b backspace 8d (10o) \f formfeed 12d (14o) \r carriage return 13d (15o) \t horizontal tab 9d (11o) \e escape 27d (33o) \\ \ 92d (134o) \NNN ASCII code NNN NNNo where NNN is the octal value for any ASCII code For example, the CIGAL commands: type 'This isn\'t a rigorous test of CIGAL strings' type 'But it shows some special characters\ne.g., \',\",\\' type 'and ASCII codes: \55\101\40\40\141\142' prints out as: This isn't a rigorous test of CIGAL strings But it shows some special characters e.g., ',",\ and ASCII codes: -A ab And the command: type '\7' causes the computer to produce a beep tone, because 7 is the ASCII code for ringing the bell. Note that to enter an ASCII code with the \NNN format the number NNN is expressed in octal (base 8) using the C language convention, and can be up to three digits long. However, it can also be less than three digits because the first character outside the range '0'-'7' ends the code. You should also keep in mind that, because DOS directory names are separated by the backslash character, whenever you enter a full path filename within quotation marks you must remember to type two backslashes wherever you want one. This can be a nuisance, but it seemed worthwhile to keep to the C convention and you quickly get used to using %%\\%% for \ (see [[jvs:cigal:manual:chapter1:filenames|FILENAMES(1)]]). __**Character String Variables**__ Anywhere that a character string is expected in a CIGAL command you can use a character string variable instead of a quoted string. Variables are particularly useful when you want to use the same string many times or when you want use a string that has been modified from some other string(s). For example: declare string fname dirname ; create 2 string variables dirname = 'C:\\mydir\\' ; assign directory name fname = mydir // test.dat ; construct filename read fname ; read C:\mydir\test.dat read mydir//test.dat ; read C:\mydir\test.dat For more information on character string variables see [[jvs:cigal:manual:chapter1:variables|VARIABLES(1)]], [[jvs:cigal:manual:chapter1:arithmetic|ARITHMETIC(1)]], [[biac:jvs:cigal:manual:chapter1:syntax|SYNTAX(1)]], [[biac:jvs:cigal:manual:chapter2:declare|DECLARE(2)]]. **See Also:**\\ [[jvs:cigal|CIGAL Home]], [[jvs:cigal:manual|CIGAL Manual]], [[jvs:cigal:manual:chapter1|Topics List]], [[jvs:cigal:manual:help|Manual Help]]