Re: A BUG in 4GL ??
Posted in 1992
Topics: High Availability & Replication, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
}Below is a program lifted from our Unisys 5000/80 running 4GL version }4.00UE3. It's a short little thing that displays a form that holds a menu }for an application that I have yet to complete. As you can see, I prompt }the users for their choice and will later call some functions. Um... not quite, you keep prompting the user... nothing more. }When I compile it I get "line 514: warning: statement not reached." The }WHILE loop with the PROMPT statement works ok, but the program ends up in }an infinite loop. The CASE is skipped altogether. It seems the GOTO at }the bottom is not being handled properly. Is this a Bug?? Also the form }has some graphics characters in it (just a box around the title) that are }not getting converted. Form graphics have worked fine with other programs. Case statements are notorious for generating the ``statement not reached'' warning. That's just what it is, a warning, and you can safely ignore it. }Yes, I know it's not the very best of programming technique to use the GOTO, }but it lets me avoid having a nested WHILE with an EXIT WHILE inside the CASE }(which by the way is how I fixed this; and yes there're other ways to do it). I have no problems with goto's when they're used correctly. }Any Bug #'s on this Informix? Probably not since the only bugs I see here are yours. (Don't know about your graphics on the form problem since you didn't include the form.) }- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }database sfbase }MAIN } define msel char(1) # <--- the user's menu selection. } defer interrupt } options input wrap } }open form rp_men from "tkw2" } }label dsf: } display form rp_men # <--- Display the menu form. } options prompt line 15, message line 15 } } while true } prompt " Enter selection and press Return: " } for char msel } if msel not matches "[1-4]" then } display msel, " is not a valid option. Try again." at 15,25 } sleep 4 } end if } end while At this point, how does the program get out of the while loop? You check to see if the user entered a valid response (which isn't needed since the case statement also generates an error for the user on an invalid response), and then go back to the top of the while loop. } case msel } when "1" } clear screen } # call rp_qry() <--- this function not yet coded. } when "2" } message " Option 2, not yet implemented." attribute (reverse) } sleep 4 } message "" } when "3" } message " Option 3, not yet implemented." attribute (reverse) } sleep 4 } message "" } when "4" } clear screen } exit program } otherwise } display msel, " is not a valid option." at 15,25 } sleep 3 } end case }goto dsf }END MAIN }- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You might find this easier to maintain if you'd coded it like: ----- Begin Sample Program ----- main define msel char(1) # store the users response here defer interupt # make the user wait till we want to be stopped open form rp_men from "tkw2" while true # stay here forever !?!?!? prompt " Enter selection and press Return: " for char msel case when msel = "1" clear screen # call rp_qry() # call the rp_qry module when msel = "2" message " Option 2, not yet implemented." attribute(reverse) sleep 4 message "" # clear the message line when msel = "3" message " Option 3, not yet implemented." attribute(reverse) sleep 4 message "" # clear the message line when msel = "4" clear screen close form rp_men exit program # this is how we get out of the while loop otherwise display msel, " is not a valid option." at 15, 25 sleep 3 end case end while end main ----- End Sample Program ----- Hope this helps, jeffl ---- Jeffrey F. Lawhorn American TriTech/ISG Programming Manager C, C++, and Database Consulting jeffl@isg.com 450 B Street 16th Floor sdsu!isg100!jeffl San Diego, CA 92101 (619) 234-3405 x274