Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 28-Nov-2021 19:44:57

vinurd
Member
From: irkutsk
Registered: 19-Jul-2014
Posts: 492
Website

Mathematical operations on variables

I've been digging for like 5 hours with variables.  Found the operator.But it's with one variable. The second one cannot be multiplied, divided, or raised to the root in any way.
How to do mathematical operations with variables?

Offline

#2 30-Nov-2021 09:47:43

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 4,845
Website

Re: Mathematical operations on variables

Hello,

you can do maths with the operator plugIT for example.

or using the "[code\]" mark in link parameter (remove the \ at the end of code mark this is because of the forum BBcode)
for that keep in mind that parameters are all string so you have ton use atoi or atof and then set the result back to string using itoa or atof.

multiply 2 parameter value based on int, the values must be interger only
[code\]
itoa ($1 * $2)
[/code\]

the same but forcing the parameter to integer to prevent error
[code\]
itoa ((atoi "$1") * (atoi "$2"))
[/code\]

again with float
[code\]
ftoa ((atof "$1") *. (atof "$2"))
[/code\]

Offline

#3 30-Nov-2021 13:57:37

vinurd
Member
From: irkutsk
Registered: 19-Jul-2014
Posts: 492
Website

Re: Mathematical operations on variables

arkeon wrote:

Hello,

you can do maths with the operator plugIT for example.

or using the "[code\]" mark in link parameter (remove the \ at the end of code mark this is because of the forum BBcode)
for that keep in mind that parameters are all string so you have ton use atoi or atof and then set the result back to string using itoa or atof.

multiply 2 parameter value based on int, the values must be interger only
[code\]
itoa ($1 * $2)
[/code\]

the same but forcing the parameter to integer to prevent error
[code\]
itoa ((atoi "$1") * (atoi "$2"))
[/code\]

again with float
[code\]
ftoa ((atof "$1") *. (atof "$2"))
[/code\]

now it is very important to understand how mathematics works with several variables. For some reason, I don't see the files with the project names in my projects folder.I see them in the program. How to send?

Offline

#4 30-Nov-2021 14:01:15

vinurd
Member
From: irkutsk
Registered: 19-Jul-2014
Posts: 492
Website

Re: Mathematical operations on variables

Offline

#5 2-Dec-2021 11:00:51

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 4,845
Website

Re: Mathematical operations on variables

To send a program export to PKOS (OpenSpace3D package)

The file should be in your my documents/OpenSpace3D/projects... folder

In last version the demos and examples have been transferred in the program folder to avoid multiplication of files for multiple account computers.

If you have modified the ums.ini file to change the default partition maybe this is your issue

Offline

#6 2-Dec-2021 12:42:30

vinurd
Member
From: irkutsk
Registered: 19-Jul-2014
Posts: 492
Website

Re: Mathematical operations on variables

did not change, the second file from the top of the documents

Offline

#7 2-Dec-2021 14:28:05

vinurd
Member
From: irkutsk
Registered: 19-Jul-2014
Posts: 492
Website

Re: Mathematical operations on variables

Offline

Board footer

Powered by FluxBB