Asked — Edited

Can'T Multiply Variables

Hi everyone, it's me again.

I'm sorry if this question/suggestion has been asked/made before, but I am trying to make a custom AI with EZ-Script, and I would like to know if multiplication with declared number or float variables (i.e. "num1" * "num2") is possible at all. If not, I think it would make ARC so much more flexible!

Thanks everyone for any answers you can give me.

P.S. I've heard about EZ-AI... but my AI is based on a cognitive architecture.:)


ARC Pro

Upgrade to ARC Pro

ARC Pro is more than a tool; it's a creative playground for robot enthusiasts, where you can turn your wildest ideas into reality.

#1  

Of course it is possible. Don't use the " character, that denotes the data as text.

Here is a simple example I just tested.


$num1 = 15
$num2 = 10.5
$result = $num1 * $num2
print($result)
say($result)

Alan

#2  

Hooray! Thank you so much!:)

Now I can continue my work... And I'll be sharing it with this wonderful community for sure! :D

Thank you so much again!

#3  

If I may inject my 2 cents worth.

Because the type any variable can assume is fluid (any variable can be any type at any time), the way they are treated can vary depending on the operation. For example, you can actually add two literal strings together, but only in certain ways. Also they can be multiplied or divided as desired. All without Type Casting or translating them to integers first. The script operating system changes the type automatically. Some examples:


$Num1 ="12" #Set both to literal strings
$Num2 ="10"
$TheResult =$Num1 + $Num2 # It will consider them to be numbers
Print($TheResult)         # Result will be 22
$TheResult ="10" + "12"   # But this way it considers them to be strings
Print($TheResult)         # And + symbol is concatenation, so result is 1012
$TheResult ="10" + 12     # Even if one is an integer, it still concatenates them
Print($TheResult)         # So result is still 1012
$TheResult ="10" * "12"   # Here they are treated as numbers again regardless
Print($TheResult)         # So result is 120

Yeah, okay, so I may be the only one who cares about such minutia, but I thought I'd share it anyway. :D

#4  

@WBS00001 Thanks for sharing! That's actually pretty cool. Amazing, actually! :)