Re: Question about 4GL's verses C
Posted in 1994
Scott McClintock (scottmc@jolt.mpx.com.au) wrote: -> ->Peter Wiley - Poultry (peter@prospect.anprod.csiro.au) wrote: ->: I'm with Alan. My leverage in 4GL vs C is at least an order of magnitude ->: better. Of course, that may say as much about my C programming as it does ->: about 4GL. :) -> ->: The other issue is portability without tears. I've seen posts here about ->: problems with ESQL-C using a particular flavour of C compiler etc. With ->: 4GL p-code I just move the files and run. -> ->: Now, if only 4GL had more math functions - starting with log & antilog.... -> ->In general I agree, however there is one area that causes us to either resort ->to C or at best double the size of our 4GL code, and that is coming up with ->a decent user interface ie one that "DOS Dummies" (excuse the term please) ->can use. The problem lies with the "little" but never theless important ->things like making certain keys behave as the user would expect, having a ->word wrap field that behaves "normally" and so on. Certainly being able to ->redefine some keys does help but there are too many limitations. -> ->I would be interested in other people's thoughts in this area. -> ->Cheers, -> ->Scott. I agree with Peter about the portability. I have had the *least* trouble porting I-4GL code, compared to any other computer language (nine at last count, not counting assembly languages) that I have used. I partially agree with Scott that the code size expands, to port between DOS and UNIX, but disagree with his statement "at best double the size". The code included below shows how I dealt with the different keyboard mapping when I implemented my application "VITAL" in both DOS and UNIX: { module Util_Key.4gl - VITAL keyboard manipulations, etc. author: R. Alan Popiel version: 4.14 date: 20 May 1991 ... some portions omitted ... FUNCTION initial - Initialize cursor movement key definitions. FUNCTION key_notes - Display help for using editing keys. } GLOBALS "globals.4gl" DEFINE key_accept, char_delete, char_insert, line_delete, line_insert, page_next, page_prev CHAR(6) {----------------------------------------------------------------------------} FUNCTION initial () { purpose: Initialize cursor movement key definitions. input: op_sys: global control variable identifying operating system. outputs: 1. key definitions for help, accept, delete, insert, next, and previous keys. 2. identification strings for above keys. } { Define cursor movement keys. } IF op_sys = "DOS" THEN OPTIONS HELP KEY F1 ,ACCEPT KEY CONTROL-E ,DELETE KEY F2 ,INSERT KEY F3 { ,NEXT KEY PAGEDOWN { default value } { ,PREVIOUS KEY PAGEUP { default value } LET key_accept = "cntl-E" LET char_delete = "DELete" LET char_insert = "INSert" LET line_delete = "F2" LET line_insert = "F3" LET page_next = "PageDn" LET page_prev = "PageUp" ELSE { op_sys = "UNIX" } OPTIONS HELP KEY CONTROL-I ,ACCEPT KEY CONTROL-E ,DELETE KEY CONTROL-T ,INSERT KEY CONTROL-O ,NEXT KEY CONTROL-F ,PREVIOUS KEY CONTROL-B LET key_accept = "cntl-E" LET char_delete = "cntl-X" LET char_insert = "cntl-A" LET line_delete = "cntl-T" LET line_insert = "cntl-O" LET page_next = "cntl-F" LET page_prev = "cntl-B" { Set trap for 'quit-window' by user. } CALL i_quit_trap () END IF END FUNCTION { initial } {----------------------------------------------------------------------------} FUNCTION key_notes (items, verb, ins_on) { purpose: Display help message for using editing keys. inputs: 1. items: name of items in list (see message below). 2. verb: infinitive or perfect participle of verb ("to add", "deleted") to be applied to items. 3. ins_on: TRUE if "insert row" message should be displayed. outputs: Messages on lines 23 and 1 of screen. post-condition: ACCEPT KEY is active. } DEFINE items CHAR(10), verb CHAR(10), ins_on SMALLINT, arrows CHAR(6), note_insert CHAR(17) CASE WHEN op_sys = "DOS" LET arrows = ASCII 24, ASCII 26, ASCII 25, ASCII 27 WHEN op_sys = "UNIX" LET arrows = "arrows" END CASE IF ins_on THEN LET note_insert = line_insert CLIPPED, ":insert row" CASE WHEN op_sys = "DOS" OPTIONS INSERT KEY F3 WHEN op_sys = "UNIX" OPTIONS INSERT KEY CONTROL-O END CASE ELSE LET note_insert = "" OPTIONS INSERT KEY F11 END IF DISPLAY arrows CLIPPED,":move ", char_insert CLIPPED, ":insert mode ", char_delete CLIPPED, ":delete char ", line_delete CLIPPED, ":delete row ", note_insert CLIPPED, "" AT 23,1 DISPLAY "Use ", line_delete CLIPPED, " to remove from the list ", items CLIPPED, " that you do NOT want ", verb CLIPPED, ".","" AT 1,1 END FUNCTION { key_notes } { end of module Util_Key ----------------------------------------------------} Since I-4GL does not have a preprocessor similar to the C preprocessor, I could not put the OS dependent code into conditional compile sections. Instead I had a global variable 'op_sys' that was initialized in my MAIN, and had small sections of conditional execution code like the above in a few places in my program. Almost all of the OS dependencies were located in the module above, and in module 'util_file.4gl', which dealt with "\\" vs. "/" and so forth. A little extra code, but nowhere near double in size; I would estimate less than a 3% increase in code size. If I were writing VITAL today, I would probably remap the keyboard to use the "PgUp", "PgDn", "Ins", and "Del" keys on the right side of the Sun SPARC keyboard and then there would be even less difference between the DOS and UNIX versions. I have no opinion on the OS-specific issues involved in getting word wrap functions, since I have not dealt with that issue. Regards, Alan ___________________________ ______________________| R. Alan Popiel |__________________________ \\ Internet: | Martin Marietta, SLS | / \\ alan@den.mmc.com | P.O. Box 179, M/S 3810 | Std disclaimers apply. / )Voice: | Denver, CO 80201-0179 USA | ( / 303-977-9998 |___________________________| (But you knew that!) \\ /________________________)