PROGRAM PASCAL_STRING { Copyright (C) 1989, Walter Torres, Chicago, Illionis. All rights reserved. This source code segment may be used in whole or partial at any time. This code is freely given. If at any time in future anyone can improve upon this segment, please sent the improved code to the authur. } PROC PascalString [ GS!, String$ ] { This code segment is needed as a global for use with this procedure. It is also used with any TOOLBOX call procedure or function. This code must be placed at the top of the main application code module. } DIM PascalBuffer% ( 125 ) { This will limit the number of characters to to be converted into a PASCAL string to 123. Increase or decrease as you wish. } PascalAddress% = 0 { The address as an INTEGER for TOOLBOX calls } PascalAddress& = 0.0 { The address as a REAL for`calculations } PascalBank% = 0 { The bank number as an INTEGER for TOOLBOX calls } { To access certain TOOLBOX ( or GS/OS ) calls, BASIC strings must be converted into PASCAL ( or GS/OS ) strings. This procedure does that convertion. NOTE : ( There is also a need for 'C' strings in TOOLBOX calls. See C.STRING for that piece of code. ) By declaring the GS! logical FALSE, this procedure will produce a PASCAL string. A PASCAL string needs the first byte to be the string length. By declaring the GS! logical TRUE, this procedure will produce a GS/OS string. GS/OS string needs the first TWO bytes to be the string length. } PascalAddress% = ADDR ( PascalBuffer% () + 2 { The address as an INTEGER for TOOLBOX calls. This is the MSB of the ADDRESS. } PascalBank% = PEEK ( 202 ) { The bank number as an INTEGER for TOOLBOX calls. This is the LSB of the ADDRESS. } PascalAddress& = ADDR ( PascalBuffer% () + 2 { The address as a REAL for calculations. This is the complete ADDRESS. } Place% = 1 { Begin at first byte for length for PASCAL string } Count% = 0 { Counter to start at Zero } EndIt% = LEN ( String$ ) { Total length of string } Location& = PascalAddress& { Convert TOOLBOX into new variable } { Converting BASIC string into GS/OS string for GS/OS calls. The first two bytes must be ZERO and string length, respectivly. } IF GS! THEN BEGIN Location& = PascalAddress& + 1.0 { Move location up one for GS/OS } POKE Location&, 0 { Clear first byte } Place% = 2 { Begin at second byte for length for GS/OS string } ENDIF POKE Location&, EndIt% { Place length in length byte of array } { Place each character of string into array, one at a time. The first charater will begin at the first byte after the length byte. } REPEAT Location& = ( PascalAddress& + Count% + Place% ) { Location in array } PutIt% = ASC ( MID$ ( String$, Count% + 1, 1 ) ) { pull out charater } POKE Location&, PutIt% { place that charater } Count% = Count% + 1 { advance counter for next charater } UNTIL Count% = EndIt% { repeat until the entire string is in place } { This is to make sure that the string was really placed in the array. It pulls each charater out one at a time and prints it to the screen. This is for debugging only!! This section is REMED out. This can be removed from your final code version. } FOR Count% = 1 TO EndIt% + Place% - 1 Location& = ( PascalAddress& + Count% ) { Location in array } GotIt& = ( PEEK ( Location& ) ) { pull out 1 charater } { PRINT CHR$ ( GotIt& ); } { print that charater } NEXT Count% ENDPROC