[Info-vax] VMS Basic strings class D vs class S

Arne Vajhøj arne at vajhoej.dk
Wed Feb 28 09:38:03 EST 2024


On 2/26/2024 4:17 PM, Stephen Hoffman wrote:
> On 2024-02-25 21:33:33 +0000, Arne Vajhøj said:
> 
>> If I have understood it correctly then VMS Basic strings use class D 
>> descriptors.
>>
>> That is very nice.
>>
>> But what happens if non-Basic code call Basic code with a string using 
>> a class S descriptor? For input/read? For output/write?
>>
>> Does the Basic runtime call some STR$ function that understands the 
>> difference between S and D and handle A properly? Or will I get a 
>> runtime error due to invalid string?
> 
> "It depends."
> 
> Most everything in most of the traditional languages and in the RTLs 
> does the right thing with both dynamic and static text strings, though 
> the app code involved might not. BASIC app code works pretty well here, 
> absent "heroic" efforts by the app developer.
> 
> If the app code assumes a dynamic arriving and gets handed static, the 
> RTL will either copy it, or space-pad the results into the static, or 
> the RTL will return a string truncation error. BASIC space-pads into 
> static string buffers if and as needed. Or truncates with an error.

 > Apps expecting to work with dynamic descriptors might fail with the
 > truncation error as mentioned, and apps expecting to massage static
 > descriptors directly and not coded sufficiently cautiously around any
 > arriving dynamic strings can fail with heap and other errors.

Basic cannot stuff 200 bytes into a 100 bytes fixed length string. That
is fair.

> it wouldn't surprise me to learn that BASIC will fail to work correctly 
> with 64-bit string descriptors, though. Lots of home-grown app code also 
> won't.

I sort of get the impression that using 64 bit descriptors is like
doing a bungee jump.

:-)

>         I also wouldn't expect the RTLs to work with encodings other than 
> ASCII and DEC MCS, either. And UTF-8 will fail in the expected places, 
> and most searching and sorting tends not to be sensitive to the 
> (written) language used within the text string.

I would assume that it works as long as the string is considered
a sequence of bytes not a sequence of characters.

Arne





More information about the Info-vax mailing list