Hello everyone. I'm still pretty horrible at programming but I am learning. Right now I'm trying to create a VERY basic game of Oregon Trail. I'm trying to use lists to input different information for the game but can't quiet figure it out. Any help with how to input data into lists and then read that data to utilize in If commands would be greatly appreciated. Thanks!
There's some good info on lists here. If you still have questions ask away but that should cover most of it.
It has helped some but I'm still a bit confused. Say I want to prompt a variable and then input that variable as the first number in a 4 length list. Then display that number from retrieving it out of the list. How would I do that?
:ClrHome //This is used to clear up the home screen for neater display of the list element :4 -> dim(L1 //This sets the length of list L1 to 4 elements :Input A :A -> L1(1 :Disp L1(1 :Pause :ClearHome //Tidies up the screen after you're done displaying the list element
OK here is a general summary of the basics of lists. You have your obvious L1-L6 to chose from but you can also create your own custom lists with the SetUpEditor command. The dim( command can be used for many things but its basic use is to set the number of elements you want the list to have (maximum of 999). To retrieve any value from a list you just type the list name then a "(" then the element number you want and then a ")" (ex: L1(5)). Likewise to store a value to a specific element of a list you type the value you want stored and then the list name and the element you want it to be stored at (ex: 5->L1(3)). If you set the dim of L1 to be 5 and then try to store a value to L1(6) you will not get an error but it will add an element to the list, However if you try to store a value to say L1(50) and the dim is 5 it will give you an error. I've kind of run out of things to say… I think lists are fairly simple
I would just like to elaborate some.
First of all, like 7HQR was saying, if you have a list with a dimension of 5 elements, and you
do X -> L1(6 it will not throw an error, but if you try doing that with a list element higher than 6, such as 7, or like 7HQR proposed, 50, there WILL be an error. I would just like to clarify that you can ALWAYS store to 1 list element greater than the current dimensions of the list, and that when you do this, you increase the dimensions of the list by 1.
Here's an example:
Let's say you do Clrlist L1. This will set the dimensions of L1 to zero, effectively erasing all data stored in L1. Now, let's check to make sure the dimensions of L1 are actually zero. You would do dim(L1. This will return the dimensions of L1, and sure enough, after doin Clrlist, it returns a zero.
Ok, now store an arbitrary value to L1. Let's go with the number 3. To do this you do 3 -> L1(1
After executing that command, go into the list editor and look at L1. It now has 1 list element, containing the number 3. Ok, so now do dim(L1 a second time. The number 1 is returned. Now let's store the number 5 into L1(2. This is done by doing 5 -> L1(2. Now do the dim(L1 command again.
It returns a value of 2. Alright, so we now have a list with a dimension of 2, which means it has 2 list elements. Let's see what happens if we try to store a value to L1(4.
It throws an error (INVALID DIM) because we tried to store to a list element that was more than 1 greater than the current list dimensions (the list dimensions are 2, we tried to store to L1(4, and
4-2=2 which is greater than 1).
Also, notice that so far I haven't closed the parentheses when storing to lists.
Instead of 1 -> L3(4)
You can always do 1 -> L3(4
Leaving out the ending parenthesis serves to purposes: it speeds up your program, and saves memory.
Note that sometimes you DO have to close the parentheses when using lists. For example, if you did:
The above statement is an instance when you have to close the parenthesis.
Generally speaking, if you have ANYTHINg after the L1(X you have to close the parenthesis, unless it is a store arrow (->)
2 -> L5(9
This DOES NOT require a closing parenthesis
This DOES require the closing parenthesis
This DOES require the closing parenthesis
This example DOES require a closing parenthesis for the first set of parentheses, but DOES NOT require a closing parenthesis for the second set.
L4(1 -> A
This DOES NOT require a closing parenthesis, because the thing that comes after is a
store arrow (->).
You probably get the idea.
Also, note that you can display an ENTIRE list at once.
Store some values to a list, say L1, and then do this:
A final note, the SetUpEditor command is not always necessary. If you want to make a user created list (in this example I will call it LSNAKE, and suppose, in this example I want it to have a dimension of 10) simply do the following:
10 -> dim(LSNAKE
Oh yeah, one more thing. The fill( command. Just give this one a try, you'll see what it does.
4 -> dim(L2
Thank you so much everyone! I have never met a more helpful community before. You guys are awesome.
Hey I have one more quick question. Is there any way to have people input a name, like a series of letters, and then display that name later?
Thank you so much! I hope I don't iritate everyone to much with my idiotic questions.
Don't worry Mscscr, feel free to ask all the questions you want. They don't irritate us. In fact, I feel good helping programmers no matter what level. And keep in mind, you're not the first to ask these types of questions, and you won't be the last :)