Re: 4gl return value problem
Posted in 2004
pamela_tw@yahoo.com (daisy) writes: > "June C. Hunt" <june_c_hunt@hotmail.com> wrote in message news:<2sd8c.52394$Fh4.329@twister.nyroc.rr.com>... >> daisy wrote: >> > I had a question occurred when my 4gl main program calling a >> > function. There seems to be something wrong with the return value Yes, from your code snippets, sometimes you return a value and sometimes you don't. >> > Statements in my main program : >> > >> > ud_fun() >> > ........... >> > let p=1 >> > while p >> > if del_fun() then exit while end if >> > let p=0 >> > end while >> > if p then >> > rollback work >> > prompt "error... " for char answer >> > end if >> > ............ >> > end function >> > >> > >> > del_fun() >> > ........ >> > if m_ac31('2',n.acm02,n.acm00,n.acm01, >> > o[i].acn02 thru o[i].acn15) then >> > display "m_ac31 error ",o[i].acn02 at 21,1 >> > sleep 5 >> > return 1 >> > end if >> > .................. You're going to need a "return 0" statement outside your "if" statement. You can't have a function that returns either zero or one value. >> > end function >> > statements in my function >> > >> > m_ac31() >> > ............... >> > if status or sqlca.sqlerrd[3]<1 then >> > display "Upd ac31 err-",status >> > sleep 5 >> > return 1 >> > end if >> > ...... Need another "return 0" statement here for the same reason. > Please give me some advice . > Thanks again Browbeat IBM to make the 4GL compiler more robust to catch static situations like this at *compile time*. Or test your programs under the RDS at least once, since I believe it catches functions that don't return the expected number of values at runtime. -- Forte International, P.O. Box 1412, Ridgecrest, CA 93556-1412 Ronald Cole <ronald@forte-intl.com> Phone: (760) 499-9142 President, CEO Fax: (760) 499-9152 My GPG fingerprint: C3AF 4BE9 BEA6 F1C2 B084 4A88 8851 E6C8 69E3 B00B