[Programming] Treat like an adress, not like a number
|
12-02-2017, 12:03 AM
Post: #1
|
|||
|
|||
[Programming] Treat like an adress, not like a number
I'm doing a little program, but I have to deal with several different numbers of input, it will all depend on the first user input(condTot).
If the user choose 5, for example, it will ask them several questions about each one of those 5 elements. I could do a "case/if", for each one, with a limit, but I wanted to do better. So I did this loop, It takes the user input(condTot) and then it will create a list os inputs, asking questions about each one of those 5 elements. But there is a problem with this aproach, when I put: L9(TEMP1,1), it will append the value of "L9(TEMP1,1)", not the adress, and then, when i call it back with the input, the value of formVar element will be like: {0,[0]{20,20,1}} //What i get Not: {L9(TEMP1,1),[0]{20,20,1}} //What I want And when it goes inside of INPUT, of course it will give me trouble... Is there any way of avoiding that? Or is there any way to make the input do what I want?? A flexible way of doing INPUT. Code: FOR TEMP0 FROM 1 TO condTot DO The rest of the code Thank you for reading, and I would apreciate if you could help me |
|||
12-02-2017, 07:58 AM
Post: #2
|
|||
|
|||
RE: [Programming] Treat like an adress, not like a number
I hope that using [] instead of {} for indices using lists will help you.
|
|||
12-02-2017, 09:21 AM
Post: #3
|
|||
|
|||
RE: [Programming] Treat like an adress, not like a number
(12-02-2017 12:03 AM)alexandrehos Wrote: If I understand well you are building a list of couples of input values with formVar. What's not clear for me is what you expect to get with the final INPUT. Do you expect to get all couples of input values on the same input screen? |
|||
12-02-2017, 11:46 AM
Post: #4
|
|||
|
|||
RE: [Programming] Treat like an adress, not like a number
As far as I know, you can't pass a variable to a function by reference.
What you can do is: * return a value and assign it to the variable when returning from the function * if you wanted to pass more than one variable by reference then return a list of values and pick the return values out of the list upon returning * make sure the variable that you want to pass to the function is global pass its name to the function in a string, then within the function, append ":=value" to the string and then do EXPR(yourString) |
|||
12-02-2017, 01:46 PM
Post: #5
|
|||
|
|||
RE: [Programming] Treat like an adress, not like a number
(12-02-2017 07:58 AM)Arno K Wrote: I hope that using [] instead of {} for indices using lists will help you.Nope :/ When you make an input, you give it "lists", like this: Code: INPUT( This will give me a form like this: But at the end of this, you will see that is not exactly lists So guys, before I move on, I did some changes on my program, now I'm using the EXPR() function, like grsbanks suggested First I make a list, in a form of a string, and when I give it to the INPUT function, I give it using the EXPR function, like this: Code:
And, in an ideal world, the program would understand like this: Code:
And my INPUT would look like this: But, of course, the world is not that simple so, I got "Error: Invalid input". (12-02-2017 09:21 AM)Didier Lachieze Wrote: Do you expect to get all couples of input values on the same input screen?So, that's what I want, if the user enters 3, it will 6 questions on the next INPUT, for entering 4, 8 inputs in the INPUT screen, and so on grsbanks, L9 is global, formVar and formTit are local. After that, I had to dig a little further, and I did this, I gave something that I know that it will work, I extracted the list of inputs, and gave it back, but now in a list. Code:
And I got "Error: Invalid input", so, the thing we give to the INPUT function that looks like a list, is not exactly a list :/ Thank you guys again for the help The rest of the code |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)