gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] nested call statements, best practices


From: Brian Tiffin
Subject: Re: [open-cobol-list] nested call statements, best practices
Date: Tue, 17 Sep 2013 16:44:00 -0400

Yeah, on 2.0.  Tonight I'm going to ask Simon to pull the trigger and
post the code to SVN on the Forge.

It'll likely take us a day or two (or nine) to work out final details,
but the time has come.

Cheers,
Brian

On 9/17/13, Michael Anderson <address@hidden> wrote:
> There is a cobc directive for that.
> -fnull-param          Pass extra NULL terminating pointers on CALL
> statements
>
> OR, What I do for this situation:
>
> Working Storage.
>   1 astring pic x(32000).
>   1 bstring pic x(24) value "       asdfgh           ".
>
> Procedure Division.
>   begin.
>          String trim(bstring) X"00" Delimited by size into astring.
>
> NOTE: MOVE pads with trailing spaces, where STRING does not!
> After the above "STRING" statement, 'astring' contains 'asdfgh' followed
> by a single null byte, followed by 31k bytes of "Who the heck knows".
> But the remainder 31k bytes does not matter in C, because when you pass
> it to C everything after the NULL is ignored, but you could initialize
> it to something.
> Something like LOW-VALUES, which is all NULLS, in which case you could
> just:
>
>          Move Low-Values To astring.
>          String trim(bstring) Delimited by size into astring.
>
> Now 'astring' contains 'asdfgh' followed by a 31k null bytes, if you had
> used MOVE instead, you'd have 'asdfgh' followed 31k of spaces.
> Using STRING, not MOVE, and Passing astring to a C function, the C
> function see's only 'asdfgh', but the C function should allow space for
> at least one null character at the end.
>
> Maybe Brian could write an example of a OpenCobol 2.0 function to do
> this, but it would require OpenCobol 2.0,
> I'd like to see what 2.0 functions look like.
>
>
>
>
> On 09/17/2013 12:27 PM, Patrick wrote:
>> Thanks Michael
>>
>> I was thinking about reposting, there was missing information I should
>> have included and the mailing list reformatted my code so it was
>> really hard to read.
>>
>> Here is what I am trying to do in non-Cobol-ish pseudo code
>>
>> Example 1:
>>
>> cFunction = would be a call statement calling cFunction
>> cob-str-to-C = a utility to trim strings and append nul byte
>> incompatible = a picture based Cobol string
>>
>> cFunction ( cob-str-to-C ( incompatible ) )
>>
>>
>>
>> I know I could do something like
>>
>>
>> Example 2
>>
>> temp = cob-str-to-C ( incompatible )
>>
>> CFunction ( temp )
>>
>> But then I have to use Cobol storage for the output of cob-str-to-C
>> and that might be an issue. i was thinking that a nested call result
>> would not have to be passed back into the PICTURE based system..
>>
>> Does this make any more sense? Sorry to everyone for the last post.
>>
>> Thanks
>>
>>
>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
> 1,500+ hours of tutorials including VisualStudio 2012, Windows 8,
> SharePoint
> 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack
> includes
> Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
> http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]