I'm gonna throw my 4 cents in to hopefully stop this excessive coding. <snip> > 0005: EOF = 0 > 0006: LOOP > 0007: READNEXT ITEM_CODE ELSE > 0008: EOF = 1 > 0009: END > 0010: UNTIL EOF DO </snip>
Can be replaced with one line that's pretty readable: ud/uv version: LOOP WHILE READNEXT ID DO or the D3 version LOOP READNEXT ID ELSE EXIT UNTIL 0 DO or even the Mvbase or Microdata version LOOP READNEXT ID ELSE ID="@@@" UNTIL ID="@@@" DO ( use @@@ or whatever is not a likely item-id) I have read these EOF=FALSE blah, blah, blah ways of avoiding the GOTO statements for almost 30 years. It's pretty tiring and does not need to be perpetuated. While anyone can argue that we have an infinite amount of resources (disc space, RAM etc), we are still human programmers reading source code. Condensing the code isn't for the system's sake, it's for the programmer's sake. Please, anyone who's new to MV should consider more than one style of programming examples. From what I continue to view, It's perpetuating the technique first learned with no opportunity for learning a better or shorter way. Another pet peeve of mine is the habit of using the null DICT portion when OPENing a file. I recall in the late 1970's when I accidentally forgot to include it on a Microdata and it compiled and worked anyway. Haven't looked back on that useless parameter. Old School: OPEN "","ABC" TO F.ABC ELSE xxx Works on all Platforms: OPEN "ABC" TO F.ABC ELSE xxx also OPEN "DICT ABC" TO D.ABC ELSE xxx I forego the entire OPEN mess with a subroutine that does not cause the bother of the wide variety of "Can't Open" scenarios. 99% of the time, the OPENing of a file is a must-do, ie if you can't don't continue. There is the less than 1% of the time where opening a file is a logical THEN/ELSE. Most of the time it's a requirement for the rest of the program to continue. Therefore, I use a sub called OPENER that I published in an issue of Spectrum. It's use is: CALL OPENER("ABC", F.ABC) or CALL OPENER("DICT ABC", D.ABC) and in that subroutine, you can write War & Peace if you want to get that verbose about a file not opening. My point is, I have seen some pretty stupid methods of handling these 99% OPEN scenarios. It's a 'housekeeping' section of the program that should be blown past without too much fanfare in the source code. Thus you can have this: CALL OPENER("FILE1", F.FILE1) CALL OPENER("FILE2", F.FILE2) CALL OPENER("FILE3", F.FILE3) instead of these 3 ridiculous methods OPEN "FILE1" TO F.FILE1 ELSE PRINT "CANNOT OPEN FILE1. PLEASE CALL TECH SUPPORT. PROGRAM TERMINATING" ; STOP OPEN "FILE2" TO F.FILE2 ELSE PRINT "CANNOT OPEN FILE2. PLEASE CALL TECH SUPPORT. PROGRAM TERMINATING" ; STOP OPEN "FILE3" TO F.FILE3 ELSE PRINT "CANNOT OPEN FILE3. PLEASE CALL TECH SUPPORT. PROGRAM TERMINATING" ; STOP or OPEN "FILE1" TO F.FILE1 ELSE PRINT "CANNOT OPEN FILE1. PLEASE CALL TECH SUPPORT" ERR.SW=1 END OPEN "FILE2" TO F.FILE2 ELSE PRINT "CANNOT OPEN FILE2. PLEASE CALL TECH SUPPORT" ERR.SW=1 END OPEN "FILE3" TO F.FILE3 ELSE PRINT "CANNOT OPEN FILE2. PLEASE CALL TECH SUPPORT" ERR.SW=1 END or this doozy of a mess OPEN "FILE1" TO F.FILE1 THEN OPEN "FILE2" TO F.FILE2 THEN OPEN "FILE3" TO F.FILE3 THEN <500 LINES OF PROCESSING AS PER APPLICATION> END ELSE PRINT "CAN'T OPEN FILE3" END END ELSE PRINT "CAN'T OPEN FILE2" END END ELSE PRINT "CAN'T OPEN FILE1" END Please, lets not spend so much effort on this simple task. OPEN them and get on with it. I work with a guy who sometimes uses method 2 above and sometimes uses method 3 above. I try to show him the simplicity of OPENER (it's already on that system) but he continues to respond "But that's how I was taught". Pretty stupid. I even have a program called MAKE.OPENER that will go through source code and replace whatever open statements exist with OPENER. I don't know the approval or voting process on what methods are useful to show the newbies so they start off on the right foot. Respectfully submitted Mark Johnson ----- Original Message ----- From: "Sanjeebkumar Sarangi" <[EMAIL PROTECTED]> To: <u2-users@listserver.u2ug.org> Sent: Tuesday, March 13, 2007 6:40 AM Subject: [U2] Error in report generation. > Hi > I tried to generate a report by writing a small program. But I got an error > as below. > > ERROR: > > >RUN TEST.BP MAIN > MAIN > > 45 record(s) selected to SELECT list #0. > Program "SUB": Line 3, Variable "REC" previously undefined. Empty string > used. > Program "SUB": Line 3, Printer name UVDEFAULT is not recognized by the > system. > > CODE: > > >ED TEST.BP > Record name = MAIN > 15 lines long.> 0005: EOF = 0 > 0006: LOOP > 0007: READNEXT ITEM_CODE ELSE > 0008: EOF = 1 > 0009: END > 0010: UNTIL EOF DO > > ----: P > 0001: CRT 'MAIN' > 0002: OPEN 'INVENTORY.T' TO INEVNTORY ELSE STOP > 0003: SENT = 'SSELECT INVENTORY.T BY ITEM_CODE' > 0004: EXECUTE SENT > 0011: READ REC FROM INEVNTORY ,ITEM_CODE THEN > 0012: CALL SUB > 0013: END > 0014: REPEAT > 0015: STOP > Bottom at line 15. > ----: Q > > File name = TEST.BP > Record name = SUB > 6 lines long. > > ----: P > 0001:CRT 'SUB' > 0002: PRINTER ON > 0003: PRINT "ITEM_CODE" "L#16":REC<1> > 0004: PRINT "DESCRIPTION" "L#16": REC<2> > 0005: PRINT "TYPE" "L#16":REC<3> > 0006: PRINTER OFF > 0007: RETURN > Bottom at line 7. > ----: > How do I resolve this? > > > Thanks > Sanjeeb > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > ------- > u2-users mailing list > u2-users@listserver.u2ug.org > To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/