Why is using GoTo considered bad practice?

Thanks for that link David. I have all sorts of links re ChrisO. He certainly knew the intricacies and had examples to try and teach the rest of us.
 
David,
I noticed that the sample database on that latest link can not be downloaded. It appears to be a feature not yet available?? It would be nice to have some of the ChrisO gems/sample dbs available in newer version of Access.
 
searching Chris's stuff is both nostalgic and extremely educational!
ChrisO was long gone by the time I came around, but it is obvious to the most casual observer that he was a tremendous asset and a real Access Heavyweight.
 
I know but doesn't user-defined type reset because of an un-handled error?
That does not make sense at all. In an unhandled error all variables reset throughout the application. So in your example all those variables reset too. Only tempvars do not.
 
ChrisO was a member here(AWF) also. Many posts with great discussion, comments and examples are here and searchable..
 
Yes - I now how to do it, it just feels slightly wrong when I use arguments as byRef
I think most people feel this way. Almost never see people modify a passed variable in a sub, although it is completely legitimate. I find it hard to debug and follow the logic. When i do this accidently it can make your head spin debugging. My guess is that is why VB now defaults to byval.
 
David,
I noticed that the sample database on that latest link can not be downloaded. It appears to be a feature not yet available?? It would be nice to have some of the ChrisO gems/sample dbs available in newer version of Access.
I was able to download it.

It was in A97 format so I have converted it to A2K7, so modern versions should be able to open it.

Might be a bit of a mission to convert all his samples! Let me know if you find any specific ones I can do quickly. (y)
 

Attachments

Thanks David. I downloaded your attachment successfully.

Speaking of nostalgia, you can just see ChrisO saying this (taken from his comments in your attached file).

'* No restrictions! *
'* Please do not use this until you know how it works. *
'* (That goes for homework as well, your teacher might ask.)



This is the error message I got when trying to download the A97 file from UA.
ErrorA97_UA.PNG
 
Last edited:
I think most people feel this way. Almost never see people modify a passed variable in a sub, although it is completely legitimate. I find it hard to debug and follow the logic. When i do this accidently it can make your head spin debugging. My guess is that is why VB now defaults to byval.
so does that mean anyone building VB aps has to check all the code when recompiling?
 
so does that mean anyone building VB aps has to check all the code when recompiling?
I do not understand the question. The default is simply byval. Not sure what that has to do with recompiling.
 
I do not understand the question. The default is simply byval. Not sure what that has to do with recompiling.

you said VB now defaults to byVal. That implies there's old code that doesn't explicitly say byVal, and works byRef. So if you edit the old code, and recompile the old code in the new compiler, than the (undeclared) byRef arguments will now become byVal, so programs that worked great in vbOLd now produce strange results in vbNew, because arguments passed to subs now don't return different values.

That would happen in Access if VBA code that we use suddenly treated all default arguments (currently byRef) as (now the new default) byVal.
 
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 ;)
 
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 :)
 

Users who are viewing this thread

Back
Top Bottom