# Number

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## How to combine two numbers to one and vice versa

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 )
```

## How to convert a number to string using prefixed zeros

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"
```

## An alternative way to define a number in boolean expressions

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 )
```

## Enter new tip title here

Enter new tip description here