|
>Date: Tue, 4 Apr 2000 17:31:24 -0400 >From: ajkumar@rccl.com > >If I have to use the Math Bindable API's CEESSCOS and CEESSSIN as a >procedure that returns a value, do I have to pass mandatory as well as >optional parameter all the time. > > >When I used the first approach the program worked fine for the first time. >But, everytime I compile and then call the program, the program bombs with the foll. errors >Pointer not set for location referenced. >Unexpected user error occurred in CEESSSIN. > >Strangely enough, the program seems to work in debug mode!! Ajith, the parameter is not optional; it is "omissible" which means you may pass *OMIT. The reason this works sometimes and crashes other times is that CEESSSIN is assuming you have passed the parameter and is accessing the place where the parameter would be. How it behaves depends on what happens to be at that place: a. not a pointer, CEESSSIN assumes an omitted parameter - this is fine b. a valid pointer, CEESSSIN puts feedback where the pointer points to - this is very bad - this can cause problems later in your code or in some other code, depending on what storage gets corrupted c. a pointer of some type that CEESSSIN doesn't like - this is the scenario that causes CEESSSIN to crash. Using the debugger causes the parameter stack to contain different values, so it is not surprising that this behaves differently in the debugger. I just read a second posting of yours on this subject. You were asking why using CALLB with the result in the second parameter gave you good results while using EVAL with a return value gave wrong results. This procedure can only be called the way it is intended to be called. If a parameter is listed as an output parameter, it must be passed as a parameter; it cannot be received as a return value. Here is a correct prototype (use a similar one for any CEE math function with 1 input parameter): d Cos pr extproc('CEESDCOS') d input 8f const d result 8f d FeedBack 12 options(*OMIT) CALLP Cos (0E0 : result : *OMIT) If you use CALLB, you must pass a third parameter of *OMIT. It is only working now by accident. If you want to use math functions as procedures returning a value, you can do as Paul Cunanne suggested, and write your own wrapping procedure for this, or you can call the C functions 'sin', 'cos' etc. If you use these, you need binding directory QC2LE. d Cos pr extproc('cos') d input 8f value Barbara Morris +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.