Why is using GoTo considered bad practice?

David, It actually had the tab highlighted. I switched to Raw Data to see if it made a difference.
I am a UA member and was logged in, so unsure what the 'unauthorized' represents.
 
Remind me of your username at UA - I can picture your avatar, but am having a mental blank on your handle o_O
 
Thanks orange! What happened to the blue version of your cat?

I've put out a shout - will report back if I hear anything.

d
 
I had the orange cat as per the base graphic here. I tried to reverse the colours one day and the cat turned a "blue haze". I updated the graphic at UA and modified the current one here.
I have a nice gif on accessforums.net ;)
 
The link to the sample by @MajP is more aligned with how I would use a UDT than the sample by ChrisO which shows multiple occurrences of a single item.

The one piece of COBOL that i actually miss is the natural use of what VBA calls a UDT. Here's an example that UDT solves although I'm not sure you can get an array in also the way this does. the numbers show the hierarchy. This is a record layout and the 01 level lets you reference the entire record as a string and move it around or pass it to a different procedure. The Pic() clauses define the data type. In this case, they are some text and some integers. You can refer to SCF-Last-UPDT-YYMMDD or to just the month part of the field. The array is two dimensional in the sense of VBA arrays because each of the 31 instances is broken down into multiple fields. But is one dimensional in the COBOL would. You would need a subordinate OCCURS clause to have multiple dimrnsions. When you define the array, you also assign a variable name as the index. You use the same syntax as VBA to reference it. SCF-START-HHMM (SCF-DAY-IDX)
Code:
000100 01  SCF-SCHEDULE-REC.
000200     05  SCF-KEY.
000300         10  SCF-CUST-NUM                  PIC X(06).
000400         10  SCF-APPLICATION               PIC X(08).
000500         10  SCF-BRANCH                      PIC X(06).
000600         10  SCF-EFFECTIVE-YYMM.
000700             15  SCF-EFFECTIVE-YY          PIC 9(02).
000800             15  SCF-EFFECTIVE-MM       PIC 9(02).
000900     05  SCF-LAST-UPDT-YYMMDD.
001000         10  SCF-LAST-UPDT-YY            PIC 9(02).
001100         10  SCF-LAST-UPDT-MM          PIC 9(02).
001200         10  SCF-LAST-UPDT-DD            PIC 9(02).
001300     05  SCF-DAILY-GROUP OCCURS 31 TIMES
001400                INDEXED BY SCF-DAY-IDX.
001500         10  SCF-START-HHMI.
001600             15  SCF-START-HH              PIC 9(02).
001700             15  SCF-START-MI               PIC 9(02).
001800         10  SCF-STOP-HHMI.
001900             15  SCF-STOP-HH               PIC 9(02).
002000             15  SCF-STOP-MI                PIC 9(02).
002100         10  SCF-CSTART-HHMI.
002200             15  SCF-CSTART-HH             PIC 9(02).
002300             15  SCF-CSTART-MI             PIC 9(02).
002400         10  SCF-CSTOP-HHMI.
002500             15  SCF-CSTOP-HH              PIC 9(02).
002600             15  SCF-CSTOP-MI               PIC 9(02).
002700         10  SCF-SEVERITY-CODE          PIC 9(01).
 
Yes, @The_Doc_Man mentions DEC machines and their DIBOL/DBL is very useful like that. You can have a 400 byte record size made of fixed length elements of various sizes, and manipulate either the whole record or the individual fields. Very helpful at times.
 
The link to the sample by @MajP is more aligned with how I would use a UDT than the sample by ChrisO which shows multiple occurrences of a single item.

The one piece of COBOL that i actually miss is the natural use of what VBA calls a UDT. Here's an example that UDT solves although I'm not sure you can get an array in also the way this does. the numbers show the hierarchy. This is a record layout and the 01 level lets you reference the entire record as a string and move it around or pass it to a different procedure. The Pic() clauses define the data type. In this case, they are some text and some integers. You can refer to SCF-Last-UPDT-YYMMDD or to just the month part of the field. The array is two dimensional in the sense of VBA arrays because each of the 31 instances is broken down into multiple fields. But is one dimensional in the COBOL would. You would need a subordinate OCCURS clause to have multiple dimrnsions. When you define the array, you also assign a variable name as the index. You use the same syntax as VBA to reference it. SCF-START-HHMM (SCF-DAY-IDX)
Code:
000100 01  SCF-SCHEDULE-REC.
000200     05  SCF-KEY.
000300         10  SCF-CUST-NUM                  PIC X(06).
000400         10  SCF-APPLICATION               PIC X(08).
000500         10  SCF-BRANCH                      PIC X(06).
000600         10  SCF-EFFECTIVE-YYMM.
000700             15  SCF-EFFECTIVE-YY          PIC 9(02).
000800             15  SCF-EFFECTIVE-MM       PIC 9(02).
000900     05  SCF-LAST-UPDT-YYMMDD.
001000         10  SCF-LAST-UPDT-YY            PIC 9(02).
001100         10  SCF-LAST-UPDT-MM          PIC 9(02).
001200         10  SCF-LAST-UPDT-DD            PIC 9(02).
001300     05  SCF-DAILY-GROUP OCCURS 31 TIMES
001400                INDEXED BY SCF-DAY-IDX.
001500         10  SCF-START-HHMI.
001600             15  SCF-START-HH              PIC 9(02).
001700             15  SCF-START-MI               PIC 9(02).
001800         10  SCF-STOP-HHMI.
001900             15  SCF-STOP-HH               PIC 9(02).
002000             15  SCF-STOP-MI                PIC 9(02).
002100         10  SCF-CSTART-HHMI.
002200             15  SCF-CSTART-HH             PIC 9(02).
002300             15  SCF-CSTART-MI             PIC 9(02).
002400         10  SCF-CSTOP-HHMI.
002500             15  SCF-CSTOP-HH              PIC 9(02).
002600             15  SCF-CSTOP-MI               PIC 9(02).
002700         10  SCF-SEVERITY-CODE          PIC 9(01).
Go on Pat, gives us a few lines on REDEFINES :)
 
I know you are joking but -- Redefines is used for two reasons. One, the input/output is variable (and out of your control. You would never use redefines on the programs working variables). Two, you need to reference a group item as numeric but want to have a subdivision. So for example, All group items (ones with subdivisions) are treated as text but you might want to treat one as numeric so technically SCF-LAST-UPDT-YYMMDD is a string. you could redefine it if you needed it to be numeric for some purpose. A more rational use would be for an Amt field that is defined as 99999V99 where you want jus the dollars or cents. you could redefine and break down the details as Dollar pic 9(5) and Cents 9(2), The "V" means the decimal point is assumed but not really there.
 
No, I was absolutely serious. (y)
It was a blast from the past for me when you posted #85, and I feel REDEFINES deserves a mention.
Not sure you can do the same in VBA?
 
Last edited:
While I really enjoyed reading where this went, I understood less than half of the discussion o_O
 
While I really enjoyed reading where this went, I understood less than half of the discussion o_O
Welcome to the club. These forums have a way of doing that, and I am guilty of enabling the "stray"...

Surely you got your question answered?
 
O very much so! I understand that while GoTo's are generally bad, they do have their purpose and should be used only sparingly. The rest of the conversation was quite educational, even though a lot of the terms being thrown around required a google search to keep remotely following the conversation :ROFLMAO:
 
I learned about the GoSub() procedure just following this so there is always something to pick up along the way.
 
No, I was absolutely serious. (y)
It was a blast from the past for me when you posted #85, and I feel REDEFINES deserves a mention.
Not sure you can do the same in VBA?

Well, I don't know if COBOL is identical to DIBOL/DBL but the latter had two number formats.

One was a character decimal, where you defined a number as say D8.2 where you had an 8 figure number with 2 implied dps, The characters were stored as 00345678, but the compiler knew this number was 3456.78. Negatives were shown by a letter at the end.
eg 0034567t where t represented -5 (I think), and therefore this number was -3456.75. You didn't have to specify the dps. You could just assert the dps when you used the number, but you had to be consistent for it to work in this way.

So you could redefine D8.2 as A8 and just treat it as 8 characters. You could change the number characters to produce a different number , and you couldn't store a non-numeric in the numeric field.

But you could also define a field as i4, and now you had a 4 byte long which can store the normal range of longs - but now although you can redefine the i4 as a A4, it's not really meaningful, and hard to change the number by changing one character in the number.

is that the same in COBOL @Pat Hartman
 
Last edited:
The Picture clause was sort of like a format. But numbers could be physically stored in at least 3 formats. As plain text, which is what the layout I posted shows or binary which we rarely used or as "packed" which was the normal usage. That was two digits to the byte. So a 6 digit date would take 4 bytes because you needed a half byte for the sign. So the high order half byte would be zero 02 20 82 1C for 220821. Or we would just use a 3 digit year rather than waste the half byte.
 
Those computers that could support it used any of 3 (or 4) different formats. You could count actual numbers with either binary integers or with binary real (floating point). You could count numbers using ASCII strings (a datatype called "number strings" to differentiate from "numbers." AND for those that could handle it, BCD numbers, in which each 4-bit quantity, one digit for each "nibble" of a BCD number (a nibble = 1/2 byte) The digits for 0-9 were actual digits. The other six possible nibbles were specialty flags. One was a minus sign. The others were something else.

IBM's 360 architecture supported BCD, as did Digital, Motorola (mostly in micro chips), Intel, TI, and a few other chip makers.
 

Users who are viewing this thread

Back
Top Bottom