So, I was looking to make a BASIC program that would make an inventory of chemicals. The reason is that we have a science club at my school that goes to other schools to do demonstrations for them. Interestingly enough, everyone has deemed that I will be in charge of math and ordering. Since I always bring my calculator and know the amounts of chemicals required for each iteration of the demonstration, I was hoping to keep track of inventory while I was there.

My idea is that I could make a program that would allow me to know how many grams/mL of something I have, in order to keep a stock. So far I am still in a planning stage, and trying to think of the best way to go about it. I was thinking that I could have three strings, the first with the chemicals, and the next two with the amounts relating to the first string. One of those two strings would have the current amounts, and the other would have the amounts that alerted I was running low. I decided the first string would look something like this "1Hydrogen Peroxide,2Potassium Permanganate,3etc,4etc", and I could have an index the numbers relating to each chemical in my binder.

I am aiming to be able to look at and edit each chemical's amount, and to have it compare the current and minimum strings, giving me the numbers of each that was needed in a list form. The main thing I need help on is how to edit the amounts. Anways, thanks to anyone willing to read it all and give some feedback and advice. I will update this later with code as I make it.
That's relatively easy to do. You'll use inString and subString to select items from the list between the commas, of course, are you familiar with that? You'll be able to use the same method to update the strings: substring from beginning of string to beginning of current item + updated current item + end of current item to end of string. To built the "updated current item" piece, you'll need a number-to-string routine or program, which is almost trivially easy to write for integers (guys, chime in with optimizations. This assumes your input is X and your output is Str0; it trashes Y1. Kudos to Weregoose.


Code:
{X,X->L2
{0,1->L1
LinReg(a+bx) Y1
Equ>String(Y1,Str0
sub(Str1,1,length(Str0)-3->Str0


Does that cover your questions? Throw us some code if you have it yet.
Yep, that helps a lot.

Code:
Input "Index",Str1
inString(str4,Str1
Ans->H
inString(str4,",",H
Ans->G
Disp sub(str4,H,G
Y=1
For(x,1,(Need Help Here)
inString(str5,",",Y
Ans->Y
x+1=x
End

This is what I have so far, and I am kind of stuck here. So here I was thinking that a for loop searching for commas in the string until it hit number 15 and to get the substring of the actual number. But I need a Str->Integer routine and I don't exactly understand the routines for them. So I understand the basics of your routine up until the last line. What exactly is that line doing?
That's integer to string. String to number is stupendously trivial:
Code:
expr(String)->X


The code in the previous post is a devious bit of trickery from Weregoose, let's walk through it line-by-line.
{X,X->L2 Y coordinates for two points: (??,X) and (??,X)
{0,1->L1 X coordinates for the same two: (0,X) and (1,X) now
LinReg(a+bx) Y1 Set up a linear regression equation for the (horizontal) line in Y1. This will essentially be Y1=X (since a horizontal line has the equation Y=[constant])
Equ>String(Y1,Str0 Convert the equation Y1="X" to the string containing the number in X.
sub(Str1,1,length(Str0)-3->Str0 Strip out the last three characters
Alright, that makes a lot of sense. Except, why do you use Str1 in "sub(Str1,1,length(Str0)-3->"? So, this is what my code looks like so far:

Code:
Input "Index",Str1
inString(Str4,Str1)
Ans+1->H
inString(Str4,",",H)
Ans->G
0->Y
0->X
expr(Str1->Q
While X<Q
inString(Str5,",",(Y+1))->Y
X+1->X
End
Y+1->Y
inString(Str5,",",Y)->P
Input "Change",L
sub(Str5,Y,(P-Y))
expr(Ans)+L->F
{F,F->L2
{0,1->L1
LinReg(a+bx) Y1
Equ>String(Y1,Str1
sub(Str1,1,length(Str1)-3->Str1
sub(Str5,1,Y-1)+Str1+sub(Str5,P,length(Str5)+1-P)->Str5


This works! I have to have an extra , at the beginning of the string, but I can just tell it to check for one and add it in at the beginning if it isn't there. Thank you very much Kerm for helping me with this, especially the strings, since I haven't played with them much. And thanks to Weregoose also, that is a really nifty routine.
Ah cool, nicely done. That was a typo on my part, my apologies. So now you need a nice GUI frontend for this, right? Smile
Heh, depends on what you mean by GUI. I was thinking of just making a few other things like comparing each of the chemicals to the minimum amount of each and just putting a menu in to access the different functions of the program. But I am very new to programming on the TI (As if you couldn't tell already~), so I don't know exactly what you mean by GUI.
Jebus721 wrote:
Heh, depends on what you mean by GUI.


I assume he means a prettier interface that doesn't make you re-run the program every time you want to look at/change something. For example, using a selector instead of "Input". (though you could always use a far more complex mouse-driven GUI using Zagors xDCS (or my modified version, called openxDCS), I suggest against it because of the resulting bloat and needless complexity)

Anyways, heres a simple, non-scrolling selector. I don't have a calc on me at the moment, so tell me if something doesn't work, or if you want me to bother to optimize it =D When running the program, press enter to select, and Mode to quit.


Code:
:inString(Str4,"," ->H
:1-> Z
:" " ->Str9
:ClrHome
:While H
:Str9 + sub(sub(Str4,Z,H-Z) + "                  ",1, 16)-> Str9
:H+1->Z
:inString(Str4,",",Z-> H
:Output(1,1Str9
:End
://Up to here, all I've been really doing is formatting Str4 so that each element gets 16 characters in Str9, making displaying text easier, especially if you do want scrolling.
:DelVar K
:1->C
:iPart(length(Str9)/16->D
:While K !=22
:Output(C,1,">
:0: Repeat Ans: getKey: End: Ans -> K
:Output(C,1,"
:if K = 105
:Then
://your existing code sans "Input"
:ClrHome
:Output(1,1,Str9
:End
:(K=34)-(K=25) + C -> C
:D(C=0) - D (C = D+1) + C -> C
:End
:ClrHome


*note, "!=" just means "not equal to", do not actually use the exclamation mark.
Wow, that is pretty nifty. So, I fixed it all up and put it in. When you said '://your existing code sans "Input"', did that mean to insert the same code, just take out the first line, or all of the inputs? It seems to be working, except that the cursor remains when I move it. So if I go all the way down, and try to go back to 1 or 2, I am not sure of where it actually is. Anyways, thanks, that is a pretty cool menu. Now I just have to find it scrollable, since it will be a long string in the end.
Might I suggest that using the two strings to store numbers is inefficient and suggest 2 lists for amounts as it will be more efficient and faster. The names list would need to stay because of its content but the other two could be replaced.
Glenn wrote:
Might I suggest that using the two strings to store numbers is inefficient and suggest 2 lists for amounts as it will be more efficient and faster. The names list would need to stay because of its content but the other two could be replaced.

I was thinking about that, but I couldn't get most of the commands since I have been finding commands on tibasicdev but their list commands don't all have pages. I will do some more searching on other sites, but until then strings will have to do.
Jebus721 wrote:
When you said '://your existing code sans "Input"', did that mean to insert the same code, just take out the first line, or all of the inputs? It seems to be working, except that the cursor remains when I move it.



Thanks! And yeah, just the first line.
The problem with the cursor is that you need a space in this line.
:Output(C,1," <-- space

@Glenn, yes. I was just trying to work with his existing code for now, indicating that the first few lines is simply there to format his existing string.
Ah, of course, that makes sense. I must have deleted that as it was spitting error messages at me, but it works perfectly now. Any other amazing things you can suggest doing with this?
rthprog wrote:

:Output(C,1," <-- space


I had that same problem once. It all works out once you know what you did wrong.
Thanks for explaining what I meant about a GUI, guys, you did an exemplary job. Smile Jebus, perhaps it might be appropriate for you to polish this up and publish it once it's finished?
Jebus721 wrote:
Ah, of course, that makes sense. I must have deleted that as it was spitting error messages at me, but it works perfectly now. Any other amazing things you can suggest doing with this?


Well you can always optimize and improve the interface. =D Its really a delicate balance between a small, lightweight (often ugly) program, and a gorgeous (often large and slow) program.

you should definitely:
1) Consolidate the database/method by which you store information
2) Explore ways to shorten your code

you should consider:
1) Making changing values easier, for example, by allowing a user to use the arrow keys to increase values by a preset increment
2) Moving your program to the graphscreen, from where you can make things look much much much cooler
3) Implementing scrolling =D Look at my own program, JOTR http://www.ticalc.org/archives/files/fileinfo/407/40700.html

and again, you can always implement xDCS/openxDCS for a much much cooler mouse-driven GUI. But save that for later. Much, much, later. =D
Quote:
you should definitely:
1) Consolidate the database/method by which you store information
2) Explore ways to shorten your code

So, I will definitely work on these, probably in math or science class, obviously that would help.
Quote:

you should consider:
1) Making changing values easier, for example, by allowing a user to use the arrow keys to increase values by a preset increment
2) Moving your program to the graphscreen, from where you can make things look much much much cooler
3) Implementing scrolling =D Look at my own program, JOTR http://www.ticalc.org/archives/files/fileinfo/407/40700.html

As for this... 1. I was thinking of making it so I could select an experiment and just select the iterations and it would change them automatically.
2. I will probably do that a bit later, but since I am the only intended user (program specifc to the situation) I am in no rush.
3. Alright, I will take a look at it in a bit, thanks.
Self-promotion and all that, but don't forget to add a DCS header / icon / description on your program. Smile
KermMartian wrote:
Self-promotion and all that, but don't forget to add a DCS header / icon / description on your program. Smile


I know how to do the icon, but how do I do a description?
Svakk wrote:
KermMartian wrote:
Self-promotion and all that, but don't forget to add a DCS header / icon / description on your program. Smile


I know how to do the icon, but how do I do a description?


1.) as always, look at the Doors CS wiki...
2.) Way to stay on topic =D
  
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 2
» 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