Difference between revisions of "Number"

From Team Developer SqlWindows Wiki
Jump to: navigation, search
(New page: This page covers number datatype tips & tricks. __TOC__ <br> <h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold; border:1px solid #afa3bf;text-align:left;color:...)
 
Line 1: Line 1:
This page covers number datatype tips & tricks.
+
'''This page covers Number datatype tips & tricks.'''
  
 
__TOC__
 
__TOC__
 
<br>
 
<br>
  
<h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold;
+
<!------------------------------------------------------------------------------------------------------------------------------>
border:1px solid #afa3bf;text-align:left;color:#000;padding:0.2em 0.4em;">[[Image:Pointer.png]]How to combine two numbers to one and ''vice versa''</h2>
+
{{TipHeader|How to combine two numbers to one and ''vice versa''}}
 
To combine two numbers into one, use the next function
 
To combine two numbers into one, use the next function
 
<pre>
 
<pre>
Line 20: Line 20:
  
  
<h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold;
+
<!------------------------------------------------------------------------------------------------------------------------------>
border:1px solid #afa3bf;text-align:left;color:#000;padding:0.2em 0.4em;">[[Image:Pointer.png]]How to convert a number to string using prefixed zeros</h2>
+
{{TipHeader|How to convert a number to string using prefixed zeros}}
 
An easy way to do that is using this function
 
An easy way to do that is using this function
 
<pre>
 
<pre>
Line 39: Line 39:
  
  
<h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold;
+
<!------------------------------------------------------------------------------------------------------------------------------>
border:1px solid #afa3bf;text-align:left;color:#000;padding:0.2em 0.4em;">[[Image:Pointer.png]]An alternative way to define a number in boolean expressions</h2>
+
{{TipHeader|An alternative way to define a number in boolean expressions}}
 
Look at the next piece of code
 
Look at the next piece of code
  
Line 62: Line 62:
  
  
<h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold;border:1px solid #afa3bf;text-align:left;color:#000;padding:0.2em 0.4em;">[[Image:Pointer.png]]Enter new tip title here</h2>
+
<!------------------------------------------------------------------------------------------------------------------------------>
 +
{{TipHeader|Enter new tip title here}}
 
Enter new tip description here
 
Enter new tip description here

Revision as of 20:42, 24 September 2008

This page covers Number datatype tips & tricks.

Contents


Pointer2.png How to combine two numbers to one and vice versa Pointer.png

To combine two numbers into one, use the next function

   nCombined = VisNumberMakeLong( nValue1, nValue2)

You can find this function in vtmisc.apl
Beware that the two input parameters must have a value between 0 and 65535.

To get the two values back from the combined number

   Set nValue1= SalNumberLow( nCombined )
   Set nValue2= SalNumberHigh( nCombined )


Pointer2.png How to convert a number to string using prefixed zeros Pointer.png

An easy way to do that is using this function

   sResult = SalFmtFormatNumber( nValue, sPicture )

So if you want to have a string with 5 characters and if nValue results in less characters and should be prefixed with zeros

   Set nValue = 12
   Set sResult = SalFmtFormatNumber( nValue, "00000" )      ! Picture parameter has 5 zeros specified

   ! sResult has the value "00012"




Pointer2.png An alternative way to define a number in boolean expressions Pointer.png

Look at the next piece of code

   If bOk = TRUE
      Set nValue = 1
   Else
      Set nValue = -1

It can be rewritten using one line of code using this function from vtmisc.apl

   nResult = VisNumberChoose( bExpression, nTrueNumber, nFalseNumber )

So the If/Else construction above can be rewritten to

   Set nValue = VisNumberChoose( bOk = TRUE, 1, -1 )


See also String : An alternative way to define a string in boolean expressions


Pointer2.png Enter new tip title here Pointer.png

Enter new tip description here