Will this work to fix the memory leak issue in the If, Then loop?

Code:

Lbl S
If B>=10
Then
   ClrHome
   Disp "Now this is the job of","a true intelect. I hope","you are good at teaching","other. Maybe you will be as","good as Mr. Hansen"
   Pause " "
   ClrHome
   Disp "You will make $2700 per","year. Good Luck"
   Pause " "
   3->F
   1->I
Else
   ClrHome
   Disp "You need more intelligence","for this job"
   Pause " "
   2->I
End
If I=1
Goto V
If I=2
Goto P
Once you choose A job in the program, what would be the best way of storing your choice? Right now I just have a number 1-5 stored in a variable, and then when you "go to work" it checks the variable and gives the corresponding amount of money. This ends up with an extremely long and confusing chunk of code. It looks like this

Code:

Lbl T
If D>=10
Then

This checks if you have enough athleticism

Code:

   ClrHome
   Disp "You must be in good shape","to be a personal trainer.","Better keep working out"
   Pause " "
   Disp "You will make $3000 per","turn
   Pause " "
   4->F
   1->I

This is where things start to get really messy. The "F" stores the job you choose, and the "I" is used in the next chunk

Code:

Else
   ClrHome
   Disp "You need more athleticism","for this job
   Pause " "
   2->I
End

Storing 2 as I is how I let it know it needs to go back to the choose a job menu as athleticism is too low

Code:

If I=1
Goto V
If I=2
Goto P

Now if I is one then it goes to the menu where you can work, and if it is two it makes you go back.

Code:

Lbl V
H=2
Disp "Welcome to work. Depending on what","job you choose you may have","more successful than others."
Pause " "
Menu("What would you like to do","Work",Z,"Go to college",AA,"Check stats",N

Lbl Z
randInt(1,3)->Z
If Z=1 and F=1
Disp "I need a Big Mac"
Pause " "
1000->G
A+1->A

Now, this is where it really starts to fall apart. The random integer is used to display a different message each time you work.
Now I know I need a better method of checking what job has been chosen because it is getting more and more convoluted.

I'm sure there are even more things I could fix, but for now, this is the most annoying. Thanks.
I don't understand your question nor did I attempt to because it's 7:50PM and I'm tired, but I see you're using variables to store data. Try using lists.

How to use a list:

In the catalog, there's a small L. Use that with the listname afterwards to use it.

To store an entire list: {54,23}->L<LISTNAME>
To set the dimensions of a list: 4->L<LISTNAME> (Which will make the list be this: {0,0,0,0} (If there's already data in the first (let's say) 2 slots, it will stay))
To fill a list with numbers: Fill(2,L<LISTNAME>
To recall data or store data to one section of a list, simply put L<LISTNAME>(Section #) (The section number must be in parenthesis after the list (No space).)

And by the way, I've told you before. You can just use the Pause token without anything after. The
Code:
" "
is unnecessary and just takes up RAM space.
mets11rap wrote:
I don't understand your question nor did I attempt to because it's 7:50PM and I'm tired, but I see you're using variables to store data. Try using lists.

How to use a list:

In the catalog, there's a small L. Use that with the listname afterwards to use it.

To store an entire list: {54,23}->L<LISTNAME>
To set the dimensions of a list: 4->L<LISTNAME> (Which will make the list be this: {0,0,0,0} (If there's already data in the first (let's say) 2 slots, it will stay))
To fill a list with numbers: Fill(2,L<LISTNAME>
To recall data or store data to one section of a list, simply put L<LISTNAME>(Section #) (The section number must be in parenthesis after the list (No space).)

And by the way, I've told you before. You can just use the Pause token without anything after. The
Code:
" "
is unnecessary and just takes up RAM space.

Thanks for the help, and I just haven't gotten around to deleting the

Code:

" "
Tip: Copy the program and paste it into notepad. Press Ctrl+H to Find and Replace. Replace " " with nothing.
  
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 4 of 4
» 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