|
>From: "Condon, Mike, /m1c" <m1c@ingersoll-imc.com> >Subject: ILE program problem >Date: Mon, 27 Aug 2001 08:55:53 -0500 > >I have the following ILE (my 1st) program that fails whenever I set an >environment variable >in a CL program using addenvvar. I'll have to admint that since I am a 400 >programmer I don't >know ILE at all. It gets this error: >Message . . . . : Pointer or parameter error (C G D F). > >And here's the program: >DGetEnv PR * ExtProc('GetEnv') >DEnvData@ * Value Options(*String) >Dgalflibr S 16A Based(EnvData@) >C *entry plist >C parm envlibr 16 >C* movel *blanks galflibr 16 >C eval EnvData@ = GetEnv('GALFLIBR') >C movel galflibr envlibr >C MOVE *ON *INLR >C RETURN Mike, you are probably not getting a pointer back from GetEnv. I forget why, but prior to V5R1 you should use ExtProc ('Qp0zGetEnvNoCCSID'). V5R1 and after you should use ExtProc('getenv'). But even when you get your pointer back, you might have problems. The value galflibr will have a x'00' character indicating the end of the data. If you use %str to get the data, instead of using a based variable, you will avoid the x'00. It's safer to use %str anyway, because it won't access the pointed-to data beyond the valid length. Using a based variable to copy the data might cause you to occasionally get MCH0601 (pointer offset error). Here's how you'd use %str: c eval envlibr = %str(EnvData@) (How do I know about Qp0zGetEnvNoCCSID? Looking at the C header file stdlib.h, there is a #pragma map from GetEnv to "Qp0zGetEnvNoCCSID". #pragma map has a similar function to RPG's EXTPROC keyword. Starting in V5R1, the #pragma map is conditioned by target < 510.) Barbara Morris
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.