Operators (2773 S TIGHTER and following) are more complex. Some only accept numeric operands and have numeric results. Others accept string operands, and in these cases the operation code is incremented by 08 to give the corresponding string operation; + changed to strs-add; no-&-no changed to str-&-no; etc. Of these, only AND refuses a_second string operand, and only + operates on strings to produce a string; the other "comparison operations" all operate on two strings to produce a number. _Array_strings: the elements of string array variables. _Character_string: any sequence of character codes, not necessarily a "string" as discussed here. _Complete_simple_strings: not sliced and not array elements. _Length_of_string or_of_string_expression: the number of characters in it, not counting opening and closing quotes and counting any doubled quotes within the string as only one character. It is recorded as bytes 4 and 5 in the string parameters. _Null_string: a string of zero length, as in LET s$="". Its length parameter is zero, its start parameter is disregarded. You cannot make an array of null strings. _Parameters_of_string: see string parameters below. _Simple_strings: variables not elements of an array. _Single_strings: sometimes used for "simple strings". _Start_of_string: the address of the first code of the string in the variables area, work space etc. If it is in the variables area, the start is the first of the string codes, after the variable name and length bytes. Kept in bytes 2-3 of the string parameters. _String_expression: any combination of functions, operators, variables, etc, which has a string value. _String_parameters: there are 5 bytes. Byte 1: one for a complete simple string, zero for a slice_or array element; one indicates that the length isn't fixed, and therefore when the string is rewritten the old copy must be deleted, not just overwritten with new codes Bytes 2-3: the start address of the copy in the variables area, work space etc Bytes 4-5: the number of characters in the string, not counting opening and closing quotes and counting any doubled quotes within the string as only one character. _String_status: as opposed to numeric status, the string nature of an expression, or of the last entry on the calculator stack. The status of the last value is signalled by bit 6 of FLAGS, zero for string parameters. Introduction strings well managed 0605 SAVE ETC filename string parameters put on stack 0629 SA BLANK and fetched back 0672 SA V OLD simple strings can be SAVEd but not LOADed 175D OPEN 2 gets string parameters for channel code 1767 OPEN 3 gets length of channel code 178B OPEN END length must be one 1C30 VAR A 2 call STK VAR to get parameters 1C46 VAR A 3 vble letter_or length in STRLEN 1C8C EXPT EXP evaluate string expression 1F6A DEF FN 1 clear FLAGS 6 for string variable 1FA6 DEF FN 6 check FN variable with DEF FN for status 2024 PR ITEM 3 fetch string parameters for printout 203C PR STRING loop to print characters of string 24FB SCANNING explains start and length parameters 2573 S SCR NXT value of SCREEN$ (X,Y) may be null 257D S SCR STO stack parameters of SCREEN$ (X,Y) 25B3 S QUOTE string parameters after quotation marks 25BE S Q AGAIN open work space for string 25CB S Q COPY copy string to work space 25D9 S Q PRMS get length not counting double quotes 25DB S STRING stack string parameters of expression 2634 S INKEY$ handle 0 or 1 length string from INKEY$ 2660 S IK$ STK stack parameters of INKEY$ 26C9 S LETTER stack parameters of string value of vble 26DF S NEGATE flags of operation codes explained 2713 S CONT 3 check if slicing required after expression already read, eg a$(2,3)(4 TO 5) 2734 S LOOP usr-no and usr-str distinguished by FLAGS 6 275B SYNTEST check status flag (in syntax checking) 2764 S RUNTEST make status flag (in run-time) 2773 S TIGHTER change op code for string operands 2788 S NOT AND exceptional ops with string result etc 27F7 SF RUN status flag for FN expressions 2808 SF FND DF save status flag 2814 SF CP DEF status of FN and DEF FN must match 2825 SF NOT FD save status flag 2831 SF VALUES string parameters inserted after argu- ments on left side of DEF FN statement 2852 SF ARG VL parameters of string DEF FN arguments put on stack 28B2 LOOK VARS string vbles in BASIC marked by "$" 28DE V STR VAR clears FLAGS 6 for string vble 294B V END signals for string vbles/arrays 2951 STK F ARG stacks parameters of string DEF FN vble 295A SFA LOOP special status flag for matching DEF FN vbles 296B SFA CP VR skip string parameters 2981 SFA MATCH stack string parameters without STK VAR 2996 STK VAR determine and stack params of string vble 29A1 SV SIMPLE$ stacks params for simple string 29AE SV ARRAYS find start of string in array 29C0 SV PTR save variable pointer 29C3 SV COMMA dimension counter decremented for strings 29D8 SV CLOSE last subscript is slice 29E0 SV CH ADD evaluate slice 29EA SV LOOP detects slice with TO 29FB SV MULT separate string arrays from numeric 2A12 SV RPT C jump ahead for string array 2A2C SV ELEM$ params for array element found and stacked 2A45 SV SLICE parameters changed for slice 2A49 SV SLICE? check for slice and clear FLAGS 6 2A52 SLICING executes slicing 2A81 SL SECOND length of slice saved 2A94 SL DEFINE string parameters of slice stacked 2AA8 SL OVER clear FLAGS 6 for parameters of slice 2AB1 STK ST 0 entry point for slice/element parameters 2AB2 STK STO $ entry point for simple strings 2AB6 STK STORE puts string params on stack from ADECB 2ACD INT EXP2 check value against string length 2AFF LET string vble start is address of 1st of string 2B72 L DELETE$ rewriting old vble: simple strings, add new then delete old; slices/elements, copy in work space first, then to variables area 2B9B L LENGTH copy new string to work space 2BA3 L IN W/S recover length and start 2BA6 L ENTER copy from work space to vbles area 2BAF L ADD$ copy new to vbles area and delete old 2BC0 L NEW prepare vble for new string 2BC6 L STRING make space in vbles area and copy length 2BF1 STK FETCH gets string params from stack into AEDCB 2DE3 PRINT FP turns decimal number into string 2E24 PF SMALL mistake; gives wrong answers in some string comparisons 352D str-&-no make null string if X zero 354E NU OR STR sorts numeric and string comparisons 3559 STRINGS get parameters of two strings 3564 BYTE COMP jump for null second string 356B SECND LOW second less than first 3575 SEC PLUS compare byte by byte 3588 STR TEST zero put on stack for string comparisons 359C strs-add two strings copied to work space and parameters of concatenation stacked 35B7 OTHER STR second string copied to work space 35C9 chr$ one-char string made in work space and params stacked 35DE val evaluate string as numeric or string expression 360C V RPRT C string scanned as expression 361F str$ evaluate expression as string 3645 read-in one-char string made in work space and 365F R I STORE params stacked 3669 code uses string parameters 3674 len value of function is in string parameters string status of DEF FN & DEF FN arguments see strings string-valued function see string function string value (on calculator stack) see strings string variable see string, variables STRLEN system variable 5C72 see also 1C46 VAR A 3 in the long entry on 18B2 LOOK VARS Bytes: 2 STRLEN and 5C4D DEST hold data for identifying a "variable in assignment", eg the X in FOR X=Y TO Z or the X$ in LET X$="hello". They are loaded in 1C46 VAR A 3, part of the exit routines from - 1C1F CLASS 01, after the variable has been identified for a LET command - 1C6C CLASS 04, after the looping variable for a FOR command has been constructed. STRLEN may hold either - for string variables which already have a value, including array elements and slices: the length parameter of thevariable, with DEST holding the start parameter - "string parameter" - for numeric variables which already have a value: the letter of the variable in its lo byte, as it appears in the variables area, with DEST a pointer just before the FP form of the numeric value in the variables area - "variables identifier" - for new variables, string or numeric, which don't yet have a value: the letter of the variable in its lo byte, with bits 5 and 6 flagging the type of variable as it will be put in the variables area but with bit 7 zero, with DEST as a pointer to the first letter of the variable name in the BASIC line - "BASIC identifier". The "string parameter" value is only used for simple strings; it is read in 2B72 L DELETE$ and immediately checked for zero, then held over all the way to the call to 19E8 RECLAIM2 in 2BAF L ADD$, where after being incremented to cover the letter and length bytes of the variable it measures the deletionof the old version of the variable. The "BASIC and variables identifiers" are only used in the case of a looping variable in FOR ... NEXT loops, to find the first NEXT command with a matching variable letter. The identifiers are never used at all for ordinary numeric or stringvariables. Written by: 1C46 VAR A 3 Read by: 1D34 F L&S 2B72 L DELETE$ Rems: 1C22 VAR A 1 subroutine gets values for DEST and STRLEN str-l-eql, str-less see 353B no-l-eql STRMS system variable 5C10 see channels and streams Bytes: 38 strs-add subroutine 359C Called only from 0028 FP CALC with literal 17; executes the "+" operation when the arguments are strings, ie string concatenation. For example: LET C$ = A$ + B$. Could be called direct; this isn't done in the ROM. Input parameters: none - the string parameters of A$ and B$ are on the stack, B$ as last value; they must be on the stack even for a direct call. Action: call 2BF1 STK FETCH to get the string parameters of B$ - save the start and length - call 2BF1 STK FETCH to get the string parameters of A$; the parameters of A$ and B$ have now been cleared from the calculator stack - save the start and length - add the lengths - call 0030 BC SPACES to make a space of this length in the work space - call 2AB2 STK STORE to stack the string parameters of C$; the start is the start of the work space, the length the sumof the lengths of A$ and B$ - recover the parameters of A$ - if its length is zero jump on to OTHER STR - copy its codes into the start of the work space. _35B7_OTHER_STR: recover the parameters of B$ - if its length is zero exit - copy its codes into the work space following the codesof A$. Exit: into 35BF STK PNTRS to restore the stack pointers to positions suitable for unary operations. Output parameters: none - the last value is now the string parameters of C$. Rems: 2788 S NOT AND leave flag cleared, string result strs-eql, strs-neql see 353B no-l-eql STR TEST 3588 (353B no-l-eql) Jumps from: 356B SECND LOW 3572 BOTH NULL STRT MULT 3125 (30CA multiply) Jumps from: 30F0 MULT LONG STR$ key (C1) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode table (b) The Y key in E mode without shift produces the function STR$; it requires one operand, a numeric expression, which must be in brackets unless it is just a number or a variable, and thevalue of the function is a character string showing what would be printed on screen if that expression were evaluated. STR$ (x-x) prints the_character "zero", not the_digit zero, if x has been given a value, otherwise gets an error message. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code C1 first to 12, then to EE, then, because it has a string result, to 6E, and adds the priority 10h/16d. Code and priority 106E are now pushed on to the machine stack (270D S PUSH PO) while the expression following STR$ is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from 6E to 2E, the calculator offset for 361F str$. 2707 S NO TO $ only STR$ and CHR$ give strings from nos str$ subroutine 361F Called from 0028 FP CALC with literal 2E; the executive routine of the STR$ function. Outputs the evaluation Y of an expression, EXP say, into the work space, then gives this evaluation parameters as a string and puts them on the stack. Eg if EXP is 7*9 then X is 63; the string in the work space is "63". Not otherwise called from ROM; could be called from m/c,but it is difficult to imagine what useful purpose this might serve. [A mistake in ROM at 2E24 PF SMALL; an unwanted zero is left on the calculator stack below the result of STR$ X if X hasan absolute value less than one. This will be taken as the valueof any function or operator of which STR$ X is an argument or second operand - since it is a string, this only applies to CODE, FN, LEN, USR, VAL, VAL$, "+", and the comparison operations - and means that all the values on the stack below the unwanted zero will also be read one out of order in the evaluation of more complex expressions. For example, the BASIC command PRINT "Result = " + STR$ X will fail if X is less than one; if X = 7, it will print correctly Result = 7 but if X = 1/7 it will print only 0.14285714 because the unwanted zero is used as the first argument of the concatenation operation instead of the parameters of "Result =". The command PRINT "Result = "; STR$ X should be used instead.] Input parameters: none - the result Y of evaluating the expression EXP is last value on the calculator stack. Action: call 0030 BC SPACES to make a single space in thework space