Real

Description

Converts a string value to a real datatype or obtains a real value that is stored in a blob.

Syntax

Real ( stringorblob )

Argument

Description

stringorblob

The string whose value you want returned as a real value or a blob in which the first value is the real value. The rest of the contents of the blob is ignored. Stringorblob can also be an Any variable containing a string or blob.


Return value

Real. Returns the value of stringorblob as a real. If stringorblob is not a valid PowerScript number or is an incompatible datatype, Real returns 0. If stringorblob is null, Real returns null.

Examples

This statement returns 24 as a real:

Real("24")

This statement returns the contents of the SingleLineEdit sle_Temp as a real:

Real(sle_Temp.Text)

The following example, although of no practical value, illustrates how to assign real values to a blob and how to use Real to extract those values. The two BlobEdit statements store two real values in the blob, one after the other. In the statements that use Real to extract the values, you have to know where the beginning of each real value is. Specifying the correct length in BlobMid is not important because the Real function knows how many bytes to evaluate:

blob{20} lb_blob
real r1, r2
integer len1, len2
 
len1 = BlobEdit(lb_blob, 1, 32750E0)
len2 = BlobEdit(lb_blob, len1, 43750E0)
 
// Extract the real value at the beginning and
// ignore the rest of the blob
r1 = Real(lb_blob)
// Extract the second real value stored in the blob
r2 = Real(BlobMid(lb_blob, len1, len2 - len1))

See also

Double

Integer

Long

Real method for DataWindows in the section called “Real” in DataWindow Reference.