Difference between revisions of "VS:Num2Str"

From Vectorworks Developer
Jump to: navigation, search
m (1 revision)
(add remark about metric/amreican dot/comma troubles, add css to table)
Line 40: Line 40:
 
-----------------------------------------------------------------------------------------------------------
 
-----------------------------------------------------------------------------------------------------------
 
<remark>
 
<remark>
You can also use [[VS:Concat]] to convert numbers to strings. Only problem is that you're limited to 6 significant digits and cannot control that.
+
([[User:Orso.b.schmid|Orso]], 2014.09.14):
 +
You can also use [[VS:Concat]] to convert numbers to strings, but it uses exclusively a dot "." as symbol for the decimal marker, because it outputs the number as seen from inside VS, I suppose. See the table below for a list of routines formatting according to your system's settings.
 +
{| class="wikitable"
 +
+ symbol for the decimal marker
 +
! Metric: ',' !!  American '.'
 +
|-
 +
|
 +
: 100,123
 +
|
 +
: 100.123
 +
|-
 +
! Formatting routines: !!  Non formatting routines:
 +
|-
 +
| [[VS:Num2Str]], [[VS:Num2StrF]], [[VS:Angle2Str]], [[VS:Area2Str]], [[VS:Volume2Str]]
 +
: <code>Num2Str(3, 100.123) { --> 100,123 on metric systems } </code>
 +
: <code>Num2Str(3, 100.123) { --> 100.123 on American systems } </code>
 +
|
 +
| [[VS:Concat]]
 +
: <code>Concat(100.123) { --> 100.123 on any system } </code>
 +
|}
 +
 
  
 
The parameter <i>decPlace</i> can be the following values:
 
The parameter <i>decPlace</i> can be the following values:
{| border=1
+
{| class="wikitable"
 
!Value !! Meaning !! Sample
 
!Value !! Meaning !! Sample
 
|-
 
|-
Line 60: Line 80:
 
==== VectorScript ====
 
==== VectorScript ====
 
<code lang="pas">
 
<code lang="pas">
oldnumValue:=232.5148;
+
oldnumValue := 232.5148;
newStrValue:=Num2Str(3,oldnumValue);
+
newStrValue := Num2Str(3, oldnumValue);
{would return '232.515'}</code>
+
{ would return '232.515' if your system is american }
 +
{ would return '232,515' if your system is metric }
 +
</code>
 
==== Python ====
 
==== Python ====
 
<code lang="py">
 
<code lang="py">

Revision as of 23:54, 23 May 2015

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Function Num2Str converts a REAL value to a string and returns the value.

Parameter decPlace has a range of -1 to 9; if -1 is specified, the value will be returned in scientific notation.

FUNCTION Num2Str(
decPlace  :INTEGER;
v  :REAL) : STRING;
def vs.Num2Str(decPlace, v):
    return STRING

Parameters

decPlace INTEGER Number of decimal places.
v REAL Numeric value.

Remarks

(Orso, 2014.09.14):

You can also use VS:Concat to convert numbers to strings, but it uses exclusively a dot "." as symbol for the decimal marker, because it outputs the number as seen from inside VS, I suppose. See the table below for a list of routines formatting according to your system's settings.

+ symbol for the decimal marker
Metric: ',' American '.'
100,123
100.123
Formatting routines: Non formatting routines:
VS:Num2Str, VS:Num2StrF, VS:Angle2Str, VS:Area2Str, VS:Volume2Str
Num2Str(3, 100.123) { --> 100,123 on metric systems }
Num2Str(3, 100.123) { --> 100.123 on American systems }
VS:Concat
Concat(100.123) { --> 100.123 on any system }


The parameter decPlace can be the following values:

Value Meaning Sample
positive round-up the value 10.56 -> 10.6 (1 decimal place)
0 round-up the value 10.56 -> 11
-1 Use scientific notation (9 decimal places) 10.56 -> 1.056000000e+001
-2 Use scientific notation (15 decimal places) 10.56 -> 1.056000000000000e+001

Example

VectorScript

oldnumValue := 232.5148;
newStrValue := Num2Str(3, oldnumValue);
{ would return '232.515' if your system is american }
{ would return '232,515' if your system is metric }

Python


Version

Availability: from All Versions
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox