CHARACTER SET Symbol Description * Multiplication Example: A=B*C (multiply B by C, store result in A) / Division Example: A=B/C (divide B by C, store result in A) + Addition Example: A=B+C (add C to B, store result in A) + String Concatenation Example: A$="AB"+"C" (A$ will contain "ABC") = Assignment Example: A=1 (A will be assigned the value 1) = Equality testing Example: IF A=1 THEN QUIT: (If the value stored in A equals 1 goto label QUIT) < Less than testing Example: IF A<1 THEN QUIT: (If the value stored in A is less than 1 goto label QUIT) <= Less than or equal to testing Example: IF A<=1 THEN QUIT: (If the value stored in A is less than or equal to 1 goto label QUIT) <> Inequality testing Example: IF A<>1 THEN QUIT: (If the value stored in A is not equal to 1 goto label QUIT) > Greater than testing Example: IF A>1 THEN QUIT: (If the value stored in A is greater than 1 goto label QUIT) >= Greater than or equal to testing Example: IF A>=1 THEN QUIT: (If the value stored in A is greater than or equal to 1 goto label QUIT) - Subtraction Example: A=B-C (Subtract C from B, store result in A) " String Delimiter Example: A$="the string is inside quote marks" () Parenthesis -- Ignored by ASIC ; Suppress Carriage Return/Line Feed with PRINT/LPRINT # Used to identify file usage with PRINT#/INPUT# , Comma, Ignored by ASIC $ Distinguishes a String Variable from an Integer. Example: ABC$ <---- String Variable Example: ABC <---- Integer Variable : Distinguishes a Label from a variable name. Example: START: <---Label name & Distinguishes a "long" (32 bit) integer from a normal integer (16 bit) variable or constant. Normal integers can hold numbers in the range +32,767 to -32,767. Long integers can hold numbers in the range +2,147,483,647 to -2,147,483,647. Note: You must compile with the "Extended Math" Option enabled to use long integers. Example: APPLES& <--Long Integer Variable Example: ORANGES <--Normal Integer Variable Example: 123457& <--Long Integer Constant Example: 1234 <--Short Integer Constant @ Distinguishes a "decimal" (64 bit) variable or constant from a normal integer (16 bit) variable or constant. Decimal numbers can be in the range +999,999,999,999.99999 to -999,999,999,999.99999. Note: You must compile with the "Decimal Math" option enabled to use decimal numbers. Example: APPLES@ <--Decimal Variable Example: 1234.567 <--Decimal Constant Example: 123@ <--Decimal Constant Example: 1.2@ <--Decimal Constant CONSTANTS, VARIABLES, AND LABELS ASIC supports the following data types: Decimal Constants Integer Constants Decimal Variables Integer Variables Decimal Arrays Integer Arrays String Constants Long Integer Constants String Variables Long Integer Variables String Arrays Long Integer Arrays Integer constants may be specified in decimal (base 10), hexadecimal (base 16), or binary (base 2). The following describes the restrictions for each data type. DECIMAL CONSTANTS Range +999,999,999,999.99999 to -999,999,999,999.99999 Example: 105.1 DECIMAL VARIABLE Described by a variable name beginning with a letter, followed by up to 78 additional letters, underscores, or numbers, terminated with an "@" symbol. It may contain a number in the range of +/-999,999,999,999.99999 Example: INTEREST@ Example: PAY_RATE_1@ DECIMAL ARRAY Described by a variable name beginning with a letter, followed by up to 78 additional letters, underscores, or numbers, terminated by an "@" symbol. This is followed by an integer variable or constant for the dimension of the array. Arrays must be dimensioned at the beginning of the program. See the DIM statement. Example: SALES@(YEAR) INTEGER CONSTANTS Range +32767 to -32767 Example: -26 INTEGER VARIABLE Described by a variable name beginning with a letter, followed by up to 79 additional letters underscores, or numbers. It may contain a number in the range +32767 to -32767. Example: VELOCITY1 INTEGER ARRAY Described by a variable name beginning with a letter, followed by up to 79 additional letters, underscores, or numbers. This name is followed by an integer variable or constant for the dimension of the array. Arrays must be dimensioned at the beginning of the program. See the DIM statement. Example: GROWTH (YEAR) LONG INTEGER Range +2,147,483,647 to -2,147,483,647 CONSTANTS Example: 3234457& LONG INTEGER Described by a variable name beginning with a VARIABLE letter, followed by up to 78 additional letters, underscores, or numbers terminated with a "&". Can contain numbers in the range +2,147,483,647 to -2,147,483,647. Example: VELOCITY1& LONG INTEGER Described by a variable name beginning with a ARRAY letter, followed by up to 78 additional letters, underscores, or numbers, terminated with a "&". This name is followed by an integer variable or constant for the dimension of the array. Arrays must be dimensioned at the beginning of the program. See the DIM statement. Example: GALAXY& (BILLIONSOF) HEXADECIMAL Hexadecimal constants are constants which are CONSTANT stated in base 16 instead of base 10 like normal constants. These may be specified wherever you can specify a integer constant. Hexadecimal constants in ASIC must be prefixed by "&hex". This prefix should be immediately followed by a valid normal or long integer constant. Hex constants may contain up to 8 hexadecimal digits for long constants, and 4 hexadecimal digits for normal constants. Example: &hexB000 <--equivalent to -20400 Example: &hexB& <--equivalent to 11& Example: &hexFFFFFFFF& <--equivalent to -1& Example: &hexB000& <--equivalent to 45056& BINARY CONSTANT Binary constants are constants which are stated in base 2 instead of base 10 like normal constants. These may be specified wherever you can specify a integer constant. Binary constants in ASIC must be prefixed by "&bin". This prefix should be immediately followed by a valid normal or long integer constant. Binary constants may contain up to 32 binary digits for long constants or 16 binary digits for normal constants. Example: &bin10 <--equivalent to 2 Example: &bin10101011& <--equivalent to 171& STRING CONSTANT A group of 0-80 characters enclosed by quotation marks. Example: "This is a String Constant" STRING VARIABLE Described by a variable name which begins with a letter, followed by up to 78 additional letters or underscores, or numbers, terminated with a "$". Can contain 0-80 characters. Example: ADDRESS$ STRING ARRAY Described by a variable name which begins with a letter, followed by up to 78 additional letters, underscores, or numbers, followed by a $, followed by an integer variable or constant enclosed in parenthesis representing the subscript. Arrays must be dimensioned at the beginning of the program. See the DIM statement. Example: STATE$(50) LABEL A Label is a location in your program you wish to transfer to. It must begin with a letter, and it may contain up to 78 additional letters or numbers. It must be terminated with a ":". Example: START: VARIABLES VS. CONSTANTS In general, ASIC will allow the use of either variables, arrays, or constants as operands to any program statement. For example: PRINT CASH PRINT 20 PRINT A(10) All three of the above examples are valid. The only case where a constant cannot be used, is where the value is being modified. For example: A = A + B <----VALID 17 = A + C <----INVALID Of course you must specify the correct data type for the ASIC keyword. For example: A = ABS("HELLO") <----INVALID This statement is invalid because you cannot take the absolute value of a string! There are a few ASIC statements which will accept only integer constants for some operands (DIM, OPEN, PRINT#, INPUT#). Refer to the individual statement for more information. There is a restriction on the use of subscripts for Arrays. A subscript for an array cannot be another array,. For example: Page - 53 . A(I(1)) <----INVALID A(I) <----VALID Finally, decimal variables or constants cannot be used as subscripts: A@(1.1) <----INVALID A@(B@) <----INVALID A@(1) <----VALID A@(A) <----VALID A@(A&) <----VALID CONVERSION BETWEEN NUMERIC FORMATS (INTEGER, LONG INTEGER AND DECIMAL) Decimal numbers, long integers, or normal integers may be used on any ASIC statement in any combination. Consequently, in the "Keyword Reference" Chapter of this is manual, operands are identified only as "number". "Number" in this context should be interpreted as meaning that the operand for that statement can be any of the following: integer constant, integer variable, integer array, long integer constant, long integer variable, long integer array, decimal constant, decimal variable, or decimal array. Exceptions, if any, are noted in the documentation for the statement. If you do mix decimal number, long integers, or regular integers in a statement, you should be aware of how ASIC converts between the formats. The following rules apply: 1) If a long integer variable or constant is being stored in a normal integer variable, the long integer (32 bit) number will ALWAYS convert correctly to a normal integer (16 bit) value provided the long integer variable contains a number which will fit in a normal integer (i.e., within the range of +32767 to -32767). If, however, the number is outside of this range, ASIC will truncate it to make it fit in a normal integer. This truncation will cause some surprising (but predictable) answers. For example if "A&" contained the value "50000&", and the following ASIC statement was executed "A=A&", then the value of "A" would be "-15536". The reason that the overflow results in such a strange number is due to the way the IBM PC stores numbers in binary format and is too complicated to describe here. The important thing to remember is, for ASIC to convert from long integers to normal integers correctly, the value in the long integer should be in the range of +32767 to -32767. 2) If a normal integer variable or constant is being stored in a long integer variable, ASIC will always convert the number correctly. 3) If a decimal number is stored in a normal or long integer, the fractional component of the number will be discarded, and the remaining integer value will be stored in the normal or long integer. The result will be truncated if necessary to fit. For example, after the statement "A=12345.67890" is executed, variable "A" would contain the value "12345". As another example, after the statement, "A=50000.12345" is executed, variable "A" would contain the value "-15536". The reason that the overflow results in such a strange number is due to the way the IBM PC stores numbers in binary format and is too complicated to describe here. The important thing to remember is, for ASIC to convert from decimal numbers to integers correctly, the value of the decimal number should be within the range for the target variable type. 4) If a long or normal integer is stored in a decimal variable, ASIC will always convert the number correctly. 5) IMPORTANT NOTE: When performing math with a mixture of decimal and integer variables, ASIC automatically converts the operands to the storage type of the result BEFORE computing the result, and the math function called will be based on the variable type of the result. GWBASIC/BASICA floating point, on the other hand, converts the operands to the most precise format of the operand types to the RIGHT of the equal sign and compute the results based on the longest type to the right of the equal sign, before scaling the result. This can be illustrated with the following examples: ASIC GWBASIC/BASICA A@=2*2.6 = 5.2 A#=2%*2.6 = 5.2 B=2*2.6= 4 B%=2%*2.6 = 5 B&=500 * 500=250000 B&=500% * 500%= OVERFLOW B&=500& * 500&=250000 B&=500& * 500&=250000 |