|Standards for Using GVs|
|17:39 Ensign Howard:
ok, now to answer makesownbweat's question about a suggested standard
17:29 makesownbweather: Ensign Howard, I have a question about establishing standards for the use of GV. Of course, each person is free to use whatever GV they please for whatever purpose they please. But, If some sort of (suggested but not required) convention is established (preferably by someone at Ensign for GV numbers which will be used by the "Ensign produced template samples" then we (users) can feel free to stay away from those GV numbers and use other ones for our (user) purposes. Could you establishing some sort of guidelines like this. I find that when I make a DYO and then begin using a sample there are many conflicts; these are unnecessary conflicts when a reasonable convention is established by someone in authority at Ensign Software. (The range of Private GVs, seems too small so this would be for GVs outside the private range.)
17:40 Ensign Howard: In my published examples I typically use GVs through , and possibly up to 20 if I am really in need of more GVs. I never use  because I treat this as a garbage bucket. It is a valid GV, but for lines that I am not really trying to save the value, I let them dump into GV. This last example illustrates that with Line B.
17:41 Ensign Howard: Line B returns a Flag, and Line B has a Write GV selection box, so IT IS GOING TO WRITE THIS RESULT SOMEWHERE that somewhere I have chosen to be GV  by leaving the Write GV selection set on 0.
17:42 Ensign Howard: And Line C is also reading a value from  AND it is going to write this result to some GV, and it dumps it into  since Line C Write GV selection is on zero.
17:43 Ensign Howard: So one standard I would like all to adopt is to use GV zero as the garbage bucket
17:44 Ensign Howard: I would have had a potential logic error to debug if I had left the Line High value in  and expected it to still be there for Line C to Read. That is because Line B would have dumped its flag into GV and ruined the High initially parked there. So first standard suggestion is to use  as the throw away bucket, and don't try to use  to hold something you intend to read later on in the DYO.
17:46 Ensign Howard: The vast majority of GV use is in the format where you write out a value and then later on read it back on another line.
17:46 Ensign Howard: This is the case in this last example. The Line A High is parked in  because I want to read it back by Line C.
17:47 Ensign Howard: Line A writes the value, and Line C reads the value. Now I am done with the High value.
17:47 Ensign Howard: So I can turn right around with Line D and F and reuse the same GV for the Low values.
17:47 Ensign Howard: Neither the High nor the Low need to be remembered for any other purpose. So reusing GV over again does not create any conflict.
17:48 Ensign Howard: The 2nd standard I suggest is that you always consider GV through  to be completely temporary and reusable.
17:49 Ensign Howard: If you ever need a GV to remember values between calculations, as was the case in our weekly high and low example, then use a private GV in the range  through .
17:50 Ensign Howard: That would be the 3rd standard or principle...... something that needs to be remembered between calculations must be written in private variables in ...
17:50 Ensign Howard: Not too many examples have this need. The Weekly H/L example happened to be a case of just such a need to remember values between calculations.
17:51 Ensign Howard: All the other GVs,  through  are global, like GVs through  and I have rarely had a need to use them. In fact, I think 99% of my examples could have been implemented with 20 global variables and the 16 private variables.
17:53 Ensign Howard: So why some of you have run out of GVs is a mystery to me.... and probably just not paying closer attention to the nature of the GVs being reusable. It is reusable if it is written before it is read, and then not going to be read later on.
17:54 Ensign Howard: So, in the 92 Q&A templates I just finished grooming, this is the standard by which I have done the implementation.
7:54 Ensign Howard: You will see very high use of GVs  through , infrequent use of .., and use of .. when the information needs to be retained between calculations.
17:55 Ensign Howard: you all are free to do whatever you see fit to do in GVs ..
17:55 Ensign Howard: Does that answer your question about a suggested standard, makesownbweat??
17:56 @Buffy2: it is a great explanation Howard, thank you.
7:56 Ensign Howard: thx, buffy, and hi to you.