PB function library-data type check and conversion functions

Source: Internet
Author: User

PB function library-data type check and conversion functions

ASC ()
Function to obtain the ASCII integer of the first character of the string.
Syntax ASC (string)
String: the return value of the first ASCII character. When the function is successfully executed, the ASCII value of the first character of the string parameter is returned. If the value of the string parameter is null, the ASC () function returns NULL.

char ()
the function converts the first character of a string, the first value of a blob variable, or an integer to a character.
syntax char (n)
parameter n: String, blob variable, or integer. It can also be an any type variable that contains the preceding data and returns a char. Returns the first character of parameter n. If the value of N is null, the char () function returns NULL.

Dec ()
the function converts string or blob values to decimal values.
syntax Dec (stringorblob)
parameter stringorblob: string type variable or blob type variable. When a blob type variable is used, the first value of the variable is converted to a decimal type value, and the rest is ignored. The stringorblob parameter can also be the return value of any type variable containing the preceding data type decimal. The corresponding decimal type value is returned when the function is successfully executed. If the value in the stringorblob parameter is not a valid powerscript number or the data type is incompatible, the DEC () function returns 0. If the value of stringorblob is null, the DEC () function returns NULL.

double ()
the function converts string or blob values to double values.
syntax double (stringorblob)
parameter stringorblob: string type variable or blob type variable. When a blob type variable is used, the first value of the variable is converted to a value of the double type, and the rest is ignored. The stringorblob parameter can also be an any type variable that contains the preceding data and returns a double value. If the function is successfully executed, the corresponding double type value is returned. If the value in the stringorblob parameter is not a valid powerscript number or the data type is incompatible, the double () function returns 0. If the value of stringorblob is null, the double () function returns NULL.

INTEGER ()
the function converts string or blob values to integer values.
syntax INTEGER (stringorblob)
parameter stringorblob: string type variable or blob type variable. When a blob type variable is used, the first value of the variable is converted to an integer value, and the rest is ignored. The stringorblob parameter can also be an any type variable that contains the preceding data and returns an integer. The corresponding Integer type value is returned when the function is successfully executed. If the value in the stringorblob parameter is not a valid powerscript number or the data type is incompatible, The INTEGER () function returns 0. If the value of stringorblob is null, The INTEGER () function returns NULL.

long ()
the function converts data of other types to values of the long type. This function has two syntax formats:
Syntax 1. Combine two unsigned integers into a long integer;
syntax 2: convert a string or blob value to a long value.
Syntax 1: combine two unsigned integers into an integer
syntax long (lowword, highword)
parameter lowword: unsignedinteger: Specifies the low value of the long integer in highword: unsignedinteger type, and specifies the high value in the long integer to return the long value. If the function is successfully executed, return the long integer after the combination of the low and high values. If an error occurs, return-1. If the value of any parameter is null, the long () function returns NULL.
syntax 2: Convert string or blob values to long values
syntax long (stringorblob)
parameter stringorblob: string type variable or blob type variable. When the Blob type variable is used, the first value of the variable is converted to the long type value, and the rest is ignored. The stringorblob parameter can also be the return value of the any type variable that contains the preceding data type long. If the function is successfully executed, the corresponding long type value is returned. If the value in the stringorblob parameter is not a valid powerscript number or the data type is incompatible, the long () function returns 0. If the value of stringorblob is null, the long () function returns NULL.

Real ()
Function to convert a string or blob value to a real value.
Syntax real (stringorblob)
Parameter stringorblob: string type variable or blob type variable. When this parameter is a blob type variable, the first value of this variable is converted to a real type value, and the rest are ignored. The stringorblob parameter can also be an any type variable that contains the preceding data. The return value is real. If the function is successfully executed, the corresponding real type value is returned. If the value in the stringorblob parameter is not a valid powerscript number or the data type is incompatible, the real () function returns 0. If the value of stringorblob is null, the real () function returns NULL.

* Date () * function converts data of other types to data of date type. The function has three syntax formats:
Syntax 1: Convert the Blob value of the datetime type or the first value is datetime or date to the value of the date type;
Syntax 2: convert a string whose value is a valid date to a value of the date type;
Syntax 3: combine the three integers into a date. We will introduce the following:
Syntax 1: Convert the Blob value of the datetime type or the first value is datetime or date to the value of the date type.
Syntax date (datetime)
Datetime: The datetime type value or the first value is the Blob type value of datetime or date. When this parameter is a blob type variable, the first value of this variable is converted to a date type value, and the rest are ignored. The datetime parameter can also be the return value of the any type variable containing the preceding data type date. If the function is successfully executed, the corresponding date type value is returned. If the value in the datetime parameter is not a valid powerscript date or the data type is incompatible, the date () function returns 1900-01-01. If the datetime value is null, the date () function returns NULL.
Syntax 2: convert a string whose value is a valid date to a value of the date type
Syntax date (string)
String: string type. Its value includes a valid date expressed in string format (for example, January 1, 1998, or 12-31-99 ), the string parameter can also be the return value of any type variable that contains string type data date. If the function is successfully executed, the corresponding date type value is returned. If the value in the string parameter is not a valid powerscript date or the data type is incompatible, the date () function returns 1900-01-01. If the value of the string parameter is null, the date () function returns NULL.
Syntax 3: combine three integers representing the year, month, and day into a date
Syntax date (year, month, day)
The year parameter is of the integer type. The year in the specified date is represented by four digits, ranging from 0 to 9999 month: integer. the month in the specified date is represented by one or two digits, from 1 to 12day: Integer type, specifies the number in the date, expressed in one or two digits, return date from 1 to 31. If the function is successfully executed, a date determined by the year, month, and day parameters is returned. If any of the three parameters uses an invalid value (for example, the month is set to 14), the date () function returns 1900-01-01. If the value of any parameter is null, the date () function returns NULL.

datetime ()
function converts data of other types to datetime type. This function has two syntax formats: Syntax 1. Combine the date and time values into values of the datetime type; Syntax 2. Convert the Blob type value to a value of the datetime type.
Syntax 1: Combine the date and time values into values of the datetime type.
Syntax: datetime (Date {, time})
parameter Date: date type date value time: optional parameter, time type time value. If this parameter is omitted, PowerBuilder sets the time to midnight (00:00:00. 000000 ). When this parameter is specified, only the hour value can be specified to return the datetime value. If the function is successfully executed, a datetime type value combined with the date and time is returned. If the value of any parameter is null, The datetime () function returns NULL.
syntax 2: Convert blob type values to datetime type values
syntax datetime (BLOB)
parameter BLOB: blob type variable, convert the first value of the variable to a value of the datetime type, and the rest are ignored. The Blob parameter can also be an any type variable that contains BLOB data and returns a datetime value. If the function is successfully executed, the corresponding datetime type value is returned. If the Blob parameter value is null, The datetime () function returns NULL.

Isdate ()
Function checks whether the specified string contains a valid date.
Syntax: isdate (datevalue)
The datevalue parameter is of the string type and specifies the string return value Boolean to be detected. If datevalue contains a valid date, the isdate () function returns true; otherwise, false. If the value of datevalue is null, The isdate () function returns NULL.

Isnull ()
Function test whether the value of a variable or expression is null.
Syntax: isnull (any)
Parameter any: Return Value of the variable or expression to be tested Boolean: if the value of any is null, the function returns true; otherwise, the function returns false.

isnumber ()
function to test whether the string is a valid value.
Syntax: isnumber (string)
string: string type. The string to be tested returns a Boolean value. If the string value is a valid powerscript number, the function returns true, otherwise, the function returns false. If the value of the string parameter is null, The isnumber () function returns NULL.

Istime ()
Function to test whether the string value is valid.
Syntax Istime (timevalue)
Parameter timevalue: string type, return value of the string to be tested Boolean: if the value of timevalue is a valid time, the function returns true; otherwise, the function returns false. If the value of timevalue is null, The Istime () function returns NULL.

String ()
Function to convert data into strings in the specified format. String () converts data of the date, datetime, numeric, time, and string types into strings of the specified format.
Syntax string (data, {format })
Parameter Data: Specifies the data to be converted. The data type can be date, datetime, numeric, time, string, or any variable format that contains the data of the preceding type: optional. string type. The value specifies the data format. If the data parameter type is string, you must specify the format parameter to return the string value. When the function is successfully executed, the specified data in string format is returned, if the data type of the Data parameter does not match the format specified by the format parameter, the format specified by the format parameter is invalid, or the data parameter is not the appropriate data type mentioned above, string () the function returns an empty string ("").
Usage:
Format is a string represented by a mask. When the data parameter is of the numerical type, the format is positive, negative, and zero; the empty display format must be provided in the first part, and other parts can be omitted. The numeric display format uses two masked characters: # and 0, where # represents 0 ~ Any number between 9. 0 indicates that each zero is displayed. In addition, currency signs ($ or ¥), percent signs (%), decimal points (.), comma (,) and other characters can also appear in the format string, but, except the decimal point (.), comma (,) can appear between the format character # and 0, other characters can only be placed before or after the format string, for example ,###, ####### it is an incorrect Format String. It is a correct format string. If the format parameter is omitted, the string () function uses the default PowerBuilder format. Note: If the display format contains multiple parts, the semicolon (;) between each part cannot be omitted. Other characters can also appear in the display Format String (only at the beginning and end of the format string), but they have no special meaning and the system only displays them as they are. For example, when the value 12 is formatted using the display Format String "revenue #", the result is "revenue 12 ". When the data parameter is of the string type, the format syntax of the format parameter is: normal string format; when the null value is in the "normal string format, @ represents any character in the string, and any other character is displayed as is. For example, if the following format is defined :(@@) @-@ then the string 0166767593 is displayed as follows: (01) 6676-7593. When the data parameter is of the date type, the syntax format of the format parameter is: the normal date format. When the date is null, the format characters in the date format are as follows: the number of days (such as 8) that start with "D" without "0) dd week start with 0 days (for example, 08) the abbreviation of DDD week Week (for example, Mon and Tue) the full name of dddd week (for example, Monday and Tuesday) month (for example, 8) Without 0 at the beginning of M-week. The abbreviation of month (for example, 08) with 0 at the start of MM-day (for example, Jan and FEB) the full name of the month in mmmm (for example, January or February) YY (for example, 97) YY In addition, the following keywords can be used as the display format of the date: [general] short date format defined in Windows [longdate] long date format defined in Windows [expiry date] short date format defined in Windows) in the case of type, the syntax format is: normal time format; when the time is null, the format character meaning in the format of time format is as follows: H starts with no 0 hours (such as 6) HH hour start with 0 hour (for example, 06) m hour start with no 0 minute (for example, 6) mm hour start with 0 minute (for example, 06) the second (for example, 6) that starts with the second (for example, 06 ~ 6 F. Each F indicates a part of the microsecond AM/PM duration. The AM/PM duration is displayed in the AM/PM mode, and the AM/PM duration in the 12-hour mode is displayed in the AM/PM mode, a/P in 12-hour format displays the upper and afternoon time with A/P, and A/P in 12-hour format displays the upper and afternoon time with A/P. In 12-hour format, you can also use the keyword [time] in the display format to display the time according to the format defined by the current Windows system. When the data parameter is of the datetime type, the syntax format is normal date and time format; the mask used for the format date and time when the date and time are null is to combine the date mask and time mask.

Time ()
Function to convert other types of data to time-type values. This function has three syntax formats: Syntax 1. Convert the datetime type or the Blob value whose first value is datetime or time to the time type; syntax 2: convert a string whose value is a valid time to a value of the time type. Syntax 3: Combine integers representing hours, minutes, seconds, and microseconds into a time value. We will introduce the following:
Syntax 1: Convert the Blob value of the datetime type or the first value is datetime or time to a value of the time type.
Syntax time (datetime)
Datetime: datetime type value or blob type value whose first value is datetime or time. When this parameter is a blob-type variable, the first value of this variable is converted to a value of the time type, and the rest are ignored. The datetime parameter can also be the return value of the any type variable containing the preceding data. The corresponding time type value is returned when the function is successfully executed. If the value in the datetime parameter is not a valid powerscript time or the data type is incompatible, the time () function returns 00:00:00. 000000. If the datetime value is null, the time () function returns NULL.
Syntax 2: convert a string whose value is a valid time to a value of the time type
Syntax time (string)
String: string type. The value includes a valid string representation time (for example, 9 or ), the string parameter can also be the return value of the any type variable containing time data. The corresponding time type value is returned when the function is successfully executed. If the value in the string parameter is not a valid powerscript time or the data type is incompatible, the time () function returns 00:00:00. 000000. If the value of the string parameter is null, the time () function returns NULL.
Syntax 3: Combine integers that represent time, minute, second, And microsecond into a Time Value
Syntax time (hour, minute, second {, microsecond })
Parameter hour: Integer type, specifies the hour in the time, from 0 to 23 minute: Integer type, specifies the minute in the time, from 0 to 59 Second: Integer type, specifies the second in the time, from 0 to 59 microsecond: Integer type, optional, microseconds in the specified time, return time from 0 to 32767. When the function is successfully executed, the return time is determined by four parameters: hour, minute, second, And microsecond. If any of the four parameters uses an invalid value (for example, the hour is set to 44), the time () function returns NULL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.