Using the CONVERT() function in program
|
10-29-2019, 11:28 PM
Post: #1
|
|||
|
|||
Using the CONVERT() function in program
I would like to add units to a value input from the user. Can CONVERT() do that in a program? I have tried to do:
var:= convert(var, 1_km); but that throws a syntax error. Or possible there is a way to affix units to a number being input via the input() function? |
|||
10-30-2019, 05:23 AM
(This post was last modified: 10-30-2019 10:05 AM by pinkman.)
Post: #2
|
|||
|
|||
RE: Using the CONVERT() function in program
[edited since precisions of tyann and John]
Hi, You may use /*intermediate strings*/ multiplication to add units : Code:
|
|||
10-30-2019, 05:53 AM
Post: #3
|
|||
|
|||
RE: Using the CONVERT() function in program
Bonjour
Vous également écrire : var:=var*1_unité par exemple : Hello You also write: var:=var*1_unit for example: Code:
Sorry for my english |
|||
10-30-2019, 05:54 AM
Post: #4
|
|||
|
|||
RE: Using the CONVERT() function in program
Another way to approach this is to multiply the value by a 1 of the unit you want.
var := var * 1_km |
|||
10-30-2019, 06:56 AM
Post: #5
|
|||
|
|||
RE: Using the CONVERT() function in program
Largely more elegant than my string usage.
I don’t know why, I thought this multiplication was not authorized in a program!? |
|||
10-30-2019, 12:35 PM
Post: #6
|
|||
|
|||
RE: Using the CONVERT() function in program
INPUT can force you to type the unit on the data entered, but this can be annoying and slow
Code: INPUT({{var,[9]}}) A more friendly alternative would be to indicate the unit in the label or help. Code: INPUT(var,{},"Long (km):"); You can also achieve something more interactive with a selection of the unit Code: LOCAL var,und={"mm","cm","m","km"},un; Viga C | TD | FB |
|||
10-30-2019, 06:32 PM
Post: #7
|
|||
|
|||
RE: Using the CONVERT() function in program
Bonjour
Ha l'entrée de la valeur par saisie et de l'unité par liste de choix me plait beaucoup. Merci Carlos295pz pour cette excellente suggestion. Hello Ha the entry of the value per entry and the unit per choice list I like it very much. Thank you Carlos295pz for this excellent suggestion. Sorry for my english |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)