[Info-vax] Any Way to Pass Character String Arguments from C to Basic?

VAXman- at SendSpamHere.ORG VAXman- at SendSpamHere.ORG
Mon Oct 21 14:10:39 EDT 2019


In article <41fb3094-0be6-4e52-8434-6df19f415ea2 at googlegroups.com>, Craig Dedo <craig.dedo at gmail.com> writes:
>On Monday, October 21, 2019 at 11:18:10 AM UTC-5, Robert A. Brooks wrote:
>> On 10/21/2019 11:31 AM, Craig Dedo wrote:
>>  
>> 
>> > Everything compiles and links correctly; no errors or warnings at all.
>> > When I run the program everything works fine until I try to assign character string data back into character string arguments> that are associated with character strings in the C program.
>> > * Assignment of character string arguments from the C program to variables in the Basic subroutine works fine.
>> > * Assignment of integer results from the Basic subroutine to the integer arguments in the C program works fine.
>> 
>> > * BUT when I try to assign character string values to a character string argument in the C program, I get a fatal error:
>> > %STR-F-FATINTERR, fatal internal error
>>  To be clear, you get this error not when you are calling the BASIC subroutine, but when you attempt to do the string assignment in the C source
>> prior to calling the BASIC subroutine?
>>  
>> Let's see the C actual source.
>> 
>> I don't see this support call in our internal bug tracking system yet.
>>  
>> -- 
>> 
>>                       -- Rob
>
>Bill Hall, our OpenVMS system manager, submitted the bug report at 10:07 a.m. Central Time (11:07 a.m. Eastern Time) today.
>
>No, this error is in the Basic subroutine, NOT the C program calling it.  Here are the relevant statements in the Basic subroutine:
>Declare String  Output_Results_lsa ( nItems_lkl )
>.. . .
>Call Returns_Elig ( Procedure_Name_ls, Input_Data_lsa(), Output_Results_lsa(), Message_ls )
>DR3_Quantity_al             = Integer ( Output_Results_lsa (1), Long )
>DR2_Quantity_al             = Integer ( Output_Results_lsa (2), Long )
>Oldest_Invoice_Number_as    = Output_Results_lsa (3)
>
>The suffixes _ls and _lsa refer to "local string" and "local string array", respectively.
>
>The error occurs at the assignment to Oldest_Invoice_Number_as.  Interestingly, the value is assigned properly before the error condition is triggered.  I know that from looking at the variables in the OpenVMS debugger.
>
>The string variables are passed from C to basic using variable-length string descriptors.  The reading of the input string variables, passed the same way, works properly but not assigning to string variables.
>
>Sincerely, 
>Craig T. Dedo. OpenVMS Software Development Consultant 
>Navistar, Inc. 
>2701 Navistar Drive 
>Lisle, IL   60532 

Try calling STR$COPY_R in the C code to a dynamic string descriptor.

==>> STR$COPY_R  destination-string ,word-integer-source-length, source-string-address

destination-string will need tobe a dynamic string descriptor which C knows
NOTHING about but you can easily compose one.  The word-integer-source-length
will the the length of the C sting and source-string-address will be the addy
of the C string.

Then, call the BASIC routine passing it the destination-string dynamic string
descriptor.  Be sure you invoke STR$FREE1_DX on the dynamic string descriptor
when you are done with the dynamic string or you *could* risk leaking memory.

-- 
VAXman- A Bored Certified VMS Kernel Mode Hacker    VAXman(at)TMESIS(dot)ORG

I speak to machines with the voice of humanity.



More information about the Info-vax mailing list