Should TI-BASIC programmers have a general agreement on how to write?
Yes
 41%  [ 7 ]
No
 41%  [ 7 ]
Somewhere in between (please post)
 17%  [ 3 ]
Total Votes : 17

Reading other people's programs is always difficult for me because different people write the same types of code differently. In general, there seems to be little agreement on what variables to use, which lines to double, etc. This not only makes code hard to read, but increases interference with programs' stored data.

The only things that I have noticed that seem to be consistent is getKey being K and If:Then statements sometimes being paired.

What puzzles me is why this is. It would not be difficult to provide general information on stuff like this along with the resources teaching how to use the language. Information as simple as "pic0 is usually used for graphics like text layering rather than title screens" could stop lots of limited variables from being overwritten.

What do you think?
Sure, it would be nice, but you're suggesting to change the habits of thousands of people that all use a product distributed by a big company, to which we are not related.
If it were possible, sure, but I am afraid the only things theoretically possible would be some slight modifications to Kerm's books and some TI-Basic Developer changes. This does not look very promising, though.
I remember seeing some sort of convention written down by someone (possibly Kerm?) where he associated different variables to different uses, and indeed, K was for getKeys. However this kind of thing is completely unnecessary, I like to just assume that everything that can be easily overwritten, will be. This way, you ensure your code will always work as designed.
I frequently use K for getKey (K for "key"), A, B, N, and sometimes X for loop counters, A,B and C,D for coordinate pairs when I'm afraid of the OS disturbing Y, and so on. I think it's good to follow common convention when you don't have a good reason not to, since it'll make it much easier for other people to read and understand your (uncommented) code. However, I don't think it should be particularly mandatory; you're only making it harder for yourself to get help from others by following your own convention. And if you document your variables somewhere out of band, as you should be doing anyway for complex TI-BASIC programs, you have no problems.
To be perfectly honest, I agree with all of you as far as the practicality of this sort of thing. The thing mr womp womp was referring to was my inspiration for this (I also don't remember where it was from) along with concerns about uses of variables interfering with each other.
I use a couple of my own conventions myself.

I use K for getKeys.
Lately I've noticed I use variables in ascending alphabetic order (A, then B, then C, etc.) for main/loop variables, and variables in descending alphabetic order (theta, then Z, then W, then V, etc.) for temporary variables. I guess it's to keep track of how many variables I've used already.
I avoid X and Y if I can due to the common problems associated with using them.
If I wanna use comments, I put them in a While 0 loop.
I avoid subprograms if I can, and try if I can to stick everything in one program (using this one hack I found somewhere for subroutines in TI-BASIC, and which I taught to DJ Omnimaga for his First Fantasy Textlib games).
I always try to make temporary .txt files on my computer documenting exactly what each variable does if I can't remember...but then I always lose the .txt file.
A lot of my code sticks to a sort of template-ish format, such as when I'm using a routine someone else created. Only rarely do I optimize/change it to my benefit where it actually helps.

I'm sure if I go back to my old TI-BASIC programs now, I couldn't tell you what the code does. Especially something complicated like Bejeweled 84+ (literally half the code isn't even my own; thank you lirtosiast for basically writing most of the important stuff Razz ).
I voted no. This is not North Korea.

Although there are definitely do's and don't, including don'ts that I myself did in the past that I would not redo nowadays. For example:

-Unless you program directly on a calculator that lacks Doors CS/CSE/CE, don't combine your entire code into one line. It's unreadable. The only advantage of doing so is that it doesn't take 20 minutes to scroll through it. Also if you press CLEAR or 2nd+ENTER by accident, then you lose your entire project.

-Regarding sub-programs, sometimes they are inevitable, such as if you use ASM libs or if the game is very large. However, the Goto subroutines trick is a nice workaround, as JWinslow23 mentions. Sub-programs can make the game slow down as the VAT gets clogged. On the other hand, sometimes it's better to split your game into sub-programs if you program on-calc, as it takes less time to reach your code.
I just use K for getkey, just because that is what i am used to seeing, and i don't use k for other things very much. As for labels, i usually start with Lbl00 and then go from there, or i will name them according to their function, like i usually name the label,that displays my name before quitting the program, LblQQ. I just do names that make sense to my brain. I also usually use variables in mostly alphabetical number. I think that getkey being K is just habit...
EDIT: I found the old document in which Kerm arbitrarily picked uses for variables Razz
Kerm wrote:
Choose Consistent Variables
Part of programming is programming consistently: making an overall plan and sticking to it each and every time. This task becomes much easier if you use the same variables for the same tasks over and over again. This way, you will never get confused about which variables to use for what functions because you will have a template for such. This will minimize debugging time and make it easier to understand your code even if you have not looked for it in a long time. Below are some standard variables and their uses:
-I,J,Á,Z: For( Loops (J and Z are for nested loops)
-A,B,C: General temporary variables
-D,O: Can be used to represent a coordinate pair whenever it is appropriate to think of displaying in terms of 'Down' (D) and 'Over' (O), such as when using the Output ( function or Text( function.
-R,C: Can be used to represent a row/column pair
-P,Q: Another utility or secondary pair
-K: a temporary getKey storage variable
You do not have to use this exact template for your programs; the important thing is to choose a template that makes sense to you and stick with it
Pieman7373 wrote:
I just use K for getkey, just because that is what i am used to seeing, and i don't use k for other things very much. As for labels, i usually start with Lbl00 and then go from there, or i will name them according to their function, like i usually name the label,that displays my name before quitting the program, LblQQ. I just do names that make sense to my brain. I also usually use variables in mostly alphabetical number. I think that getkey being K is just habit...


I agree, and I sincerely wish TI would create a calc/os that supported variables with 2 letters. Yes, this would break a lot of things, but it would also open up a lot of possibilities.

Also, I prefer to either use G or K for getkey, as K is part of IJKL, which are great for coord pairs for, say, 2 similar enemies in an RPG.
_iPhoenix_ wrote:
Pieman7373 wrote:
I just use K for getkey, just because that is what i am used to seeing, and i don't use k for other things very much. As for labels, i usually start with Lbl00 and then go from there, or i will name them according to their function, like i usually name the label,that displays my name before quitting the program, LblQQ. I just do names that make sense to my brain. I also usually use variables in mostly alphabetical number. I think that getkey being K is just habit...


I agree, and I sincerely wish TI would create a calc/os that supported variables with 2 letters. Yes, this would break a lot of things, but it would also open up a lot of possibilities.

Also, I prefer to either use G or K for getkey, as K is part of IJKL, which are great for coord pairs for, say, 2 similar enemies in an RPG.

Why would you want 2 letter variables? If you ever need to use more than all 26 letters, theta, [recursive n] and all the stat variables, with imaginary and real parts there is definitely a better way to do it (most likely a list of some sort). Two character variables would also introduce the problem of the parser having to try to determine if the user wants to multiply variables together or indicate a two character variable because something like AB could be interpreted in both ways. I have a hard time seeing what these possibilities you speak of might be. Also, I think this might actually be a thing on other calc models (maybe the ti-86?) where you can name your variables whatever you please, for example, you can do "WOMP"→WOMP and it will create a string variable names WOMP.
When I write, I only like to only use lists to group related variables and so generally lots of single-letter variables get filled up quickly in complex programs. As far as multi-letter variables, they generally just make code easier to read (if a program isn't fully documented, you can tell what each variable does by its name).
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement