Path: utzoo!attcan!uunet!mcvax!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.os.vms Subject: Passing strings from Cobol to Pascal Message-ID: <3744@enea.se> Date: 16 Jul 88 19:20:02 GMT Organization: ENEA DATA AB, Sweden Lines: 41 The scene: I have several Cobol modules that call this same Pascal module. Thus, all tricks should be on the Pascal side. All Cobol modules have the same appearance, only the contents of the strings vary beside a message code. Basically I want to write: CALL "Pascal_routine" USING Specific_msg_code, BY"specific text" GIVING Ret_status I don't want to explicitly mention the length of the string parameter, since it could be a source of error. (One changes the string, but for- gets to the change the length.) On the Pascal side I don't want to make any assumptions about the maximum length of the string, so accordingly I use a conformant schema. I tried various combinations of passing mechanism, PACKED/VARYING and VAR/non-VAR, but none of them worked as desired. Best was by descriptor and a Pascal declaration like: (. Global .) FUNCTION Pascal_routine( Code : integer; VAR Str : VARYING(.$len.) OF char) : integer; What Cobol put in the parameter area for the string was an address. On that address one could find the length of the string. *Behind* this word, was the string itself. On the Pascal side this became, assuming the string "ABCDEF": $len : 6 Str.length: 256*66 + 65 Str.body: "DCEF''(0)''(6)" The debugger presented the string to me as "ABCDEF", though. (If I used a PACKED ARRAY instead, both Pascal and debugger considered the Cobol descriptor as totally invalid.) My solution was to add a routine within Pascal-routine that took care of the string. Unfortunately, this meant I had to decide a maximum length, which in this case was acceptable, but next time it may not. And, no, it is not possible to shuffle around in Str. Cobol places the string in low read-only memory. Now, what should I've done? Is it just that it is impossible? -- Erland Sommarskog ENEA Data, Stockholm sommar@enea.UUCP "It all looks quite impressive really, but is it really necessary?" Radio Stars