Pages: 1
Topic closed
Sorry for my english. I'm trying to make a program that ask various questions and then add the numeric result... When I try it the only answer I can operate with is the last. Help please.
Offline
Hmm... I see what you mean. Perhaps try something like this.
when gf clicked ask [first number] and wait set [#1 v] to (answer) ask [second number] and wait set [#2 v] to (answer) ask [third number] and wait set [#3 v] to (answer) set [total v] to ( (#1) + ( (#2) + (#3) ) ) say (join [The total is ] (total) )If you a lot of numbers, you could use lists, but it would be more complicated.
Offline
Lucario621 wrote:
Hmm... I see what you mean. Perhaps try something like this.
when gf clicked ask [first number] and wait set [#1 v] to (answer) ask [second number] and wait set [#2 v] to (answer) ask [third number] and wait set [#3 v] to (answer) set [total v] to ( (#1) + ( (#2) + (#3) ) ) say (join [The total is ] (total) )If you a lot of numbers, you could use lists, but it would be more complicated.
This seems like it's the simplest way.
Offline
The way with lists (unlimited amount of inputs)
when gf clicked ask [how many numbers?] and wait set [numbers v] to <answer> set [1 v] to [0] repeat (numbers) change [1 v] by [1] ask <join<join [what is number] <1>>[ ?]> and wait add <answer> to [list of numbers v] end repeat (length of numbers) replace item (1 v) of [list of numbers v] with <<item (1 v) of [list of numbers v]>+<item (2 v) of [list of numbers v]>> end say <join <item (1 v) of [list of numbers v]> [ is the total]>
Offline
Topic closed
Pages: 1