Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Convert enumeration type in PB to numeric type.
Convert enumeration type in PB to numeric type.
For example, the following functions are type conversion functions:

Char()

The function converts the first character of a string, the first value of a Blob variable, or an integer to a character.

Syntax character (n)

Parameter n: string, Blob variable or integer, or the return value Char of any variable containing the above data. Returns the first character of parameter n. If the value of parameter n is NULL, the Char () function will return NULL.

-

December ()

Function converts a string or Blob value to a value of type Decimal.

Grammar Dec (stringorblob)

Parameter string or lob: a variable of type string or Blob. When using a variable of Blob type, the first value of the variable is converted to a value of Decimal type, and the rest is ignored. The stringorblob parameter can also be the return value Decimal of any type variable containing the above-mentioned data. When the function is successfully executed, the corresponding value of Decimal type is returned. If the value in the stringorblob parameter is not a valid PowerScript number or the data type is incompatible, the Dec () function will return 0. If the value of the stringorblob parameter is NULL, the Dec () function will return NULL.

-

Double precision ()

Function converts a string or Blob value to a value of type Double.

Syntax Double(stringorblob)

Parameter string or lob: a variable of type string or Blob. When using a variable of type Blob, the first value of the variable is converted to a value of type Double, and the rest is ignored. The stringorblob parameter can also be the return value Double of any type variable containing the above type data. When the function is successfully executed, the corresponding Double value will be returned. If the value in the stringorblob parameter is not a valid PowerScript number or the data type is incompatible, the Double () function will return 0. If the value of the stringorblob parameter is NULL, the Double () function will return NULL.

-

Integer ()

Function converts a string or Blob value to a value of type Integer.

Syntax integer (stringorblob)

Parameter string or lob: a variable of type string or Blob. When using a Blob variable, the first value of the variable is converted to an integer value, and the rest is ignored. The stringorblob parameter can also be an integer with the return value of any type of variable that contains the above type of data. When the function is successfully executed, the corresponding integer value is returned. If the value in the stringorblob parameter is not a valid PowerScript number or the data type is incompatible, the Integer () function will return 0. If the value of the stringorblob parameter is NULL, the Integer () function returns NULL.

-

Long()

Function converts other types of data into long integer values. This function has two syntax formats:

Syntax 1: Merge two unsigned integers into one long integer value;

Syntax 2: Convert a string or Blob value to a value of type Long. The following are introduced respectively:

Syntax 1. Merges two unsigned integers into one long integer value.

Grammar length (low word, high word)

Parameter lowword:UnsignedInteger type, which specifies the low-order value in long integer, and highword:UnsignedInteger type, which specifies the high-order value in long integer, and returns a long value. If successful, the function will return a long integer consisting of a low value and a high value, and if failed, it will return-1. If the value of any parameter is NULL, the Long () function will return NULL.

Syntax 2: Convert a string or Blob value to a long integer value.

Syntax Long (stringorblob)

Parameter string or lob: a variable of type string or Blob. When using a Blob variable, the first value of the variable is converted to a long integer value, and the rest is ignored. The stringorblob parameter can also be the return value Long of any type variable that contains the above type data. When the function is successfully executed, the corresponding long integer value is returned. The Long () function returns 0 if the value in the stringorblob parameter is not a valid PowerScript number or the data type is incompatible. If the value of the stringorblob parameter is NULL, the Long () function returns NULL.

-

True ()

Function converts a string or Blob value to a value of type Real.

Syntax real number (stringorblob)

Parameter string or lob: a variable of type string or Blob. When the parameter is a Blob variable, the first value of the variable is converted into a real value, and the rest is ignored. The stringorblob parameter can also be the return value Real of any type variable containing the above-mentioned data. When the function is successfully executed, the corresponding real value is returned. The Real () function returns 0 if the value in the stringorblob parameter is not a valid PowerScript number or the data type is incompatible. If the value of the stringorblob parameter is NULL, the Real () function returns NULL.

-

The Date () function converts other types of data into data of date type. This function has three syntax formats:

Syntax 1: Converts a DateTime type or Blob value whose first value is DateTime or Date to a Date type value;

Syntax 2: Convert a string with a valid date into a value of date type;

Grammar 3. Combine three integers into a date. The following are introduced respectively:

Syntax 1. Converts a DateTime type or Blob value whose first value is Datetime or date to a date type value.

Grammatical date (date and time)

Parameter DateTime: the value of datetime type or the first value is a value of Blob type of datetime or date. When the parameter is a Blob variable, the first value of the variable is converted to a date value, and the rest are ignored. The Datetime parameter can also be the return value date of any variable containing the above-mentioned types of data. When this function is successfully executed, the corresponding date value will be returned. If the value in the Datetime parameter is not a valid PowerScript date or the data type is not compatible, the date () function will return1900-01-0/. If the value of the Datetime parameter is NULL, the date () function will return NULL.

Syntax 2: Convert a string whose value is a valid date to a value of date type.

Syntax Date (String)

Parameter string:string, whose value contains the effective date in the form of a string (such as January 1, 1998 or 12-3 1-99). The string parameter can also be the return value date of any variable that contains string data. When this function is successfully executed, the corresponding date value will be returned. If the value in the string parameter is not a valid PowerScript Date or the data type is incompatible, the date () function will return1900-01-01. If the value of the string parameter is NULL, the Date () function will return NULL.

Grammar 3. Combine three integers representing year, month and day into a date.

Grammatical date (year, month, day)

Parameter year:integer type, the year in the specified date is represented by four digits, from 0 to nine thousand nine hundred and ninety-nine 9999month:integer type, the month in the specified date is represented by one digit or two digits, from 1 to 12 day: integer type, and the digits in the specified date are represented by one digit or two digits, from 1 to 330. When this function is successfully executed, it returns the date determined by three parameters: year, month and day. If any of these three parameters uses an invalid value (for example, the month is specified as 14), the Date () function will return1900-01-01. If the value of any parameter is NULL, the Date () function will return NULL.

-

Date and time ()

Function converts other types of data into date-time data. This function has two syntax formats: syntax 1, which combines date and time values into DateTime type values; Syntax 2: Convert a value of type Blob to a value of type DateTime. The following are introduced respectively:

Syntax 1. Combines date and time values into values of type DateTime.

Syntax DateTime (date {,time})

Parameter date: date value of date type Time: optional parameter, time value of time type. When this parameter is omitted, PowerBuilder sets the time to midnight (00:00:00.000000). If this parameter is specified, you can only specify an hour value to return the value DateTime. When this function is successfully executed, it will return a value of date-time type, which is a combination of date and time. If the value of any parameter is NULL, the DateTime () function will return NULL.

Syntax 2: Convert a value of type Blob to a value of type DateTime.

Syntax date time (blob)

Parameter BLOB: Variable blob:Blob type, the first value of which is converted to a value of DateTime type, and the rest is ignored. The blob parameter can also be the return value DateTime of any variable that contains blob data. When the function is successfully executed, the corresponding DateTime type value will be returned. If the value of the blob parameter is NULL, the DateTime () function will return NULL.

-

String ()

Function converts data into a string in the specified format. String () can convert data of date, date and time, number type, time and string type into a string in a specified format.

Syntax string (data, {format})

Parameter data: specifies the data to be formatted. Its data type can be date, date and time, number type, time and string, or it can be in any variable format: optional. Its value specifies the data format. If the data parameter is of string type, you must specify the format parameter return value string. When the function is successfully executed, the specified data is returned as a string. 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, the string () function returns an empty string ("").

Usage:

The format is a string represented by a mask. For the case that the data parameters are numeric values, the format is: positive number format; Negative number format; Display format of zero; The blank display format can be omitted except for the first part. Two mask characters are used in the digital display format: # and 0, where # is used to represent any number between 0 and 9, and 0 means that each zero should be displayed. In addition, such as currency symbol ($ or @), percent sign (%), decimal point (.) and comma (,) can also appear in the format string. However, except for the decimal point (. ) and comma (,) can appear between the format characters # and 0, and other characters can only be placed before or after the format string, for example, # #, #. When the format parameter is omitted, the String () function uses the default format of PowerBuilder. Note that if the display format has multiple parts, semicolons (; ) 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 just displays them as they are. For example, when the value 12 is formatted as the display format string "Revenue # #", the display result is "Revenue012". When the data parameter is a string type, the syntax format of the format parameter is: ordinary string format; In Normal String Format, @ means any character in the string, and all other characters are displayed as they are. For example, if the following format is defined: (@ @) @-@ @, the string 0 166767593 is displayed as: (0 1) 6676. When the date is empty, the meanings of the format characters in the format date format are as follows: days without 0 at the beginning of D date (e.g. 8) days with 0 at the beginning of DD date (e.g. 08) English abbreviation of DDD date week (e.g. Mon, English full name of Tuesday date week (e.g. Monday, Tuesday) Month with zero at the beginning of M date (e.g. 8) Month with zero at the beginning of MM date (e.g. feb) English full name of mmmm jujube month (e.g. 1 month and February) yy jujube double-digit year (e.g. 97)yyyy jujube four-digit year (e.g. 1997) In addition, You can also use the following keywords as the date display format: General Short Date Format defined in Windows System longdate】Windows Date Format defined in Windows System Short Date Format defined in Windows System. When the data parameter is of time type, the syntax format is: normal time format; Time is a space-time format. The format characters in Time format have the following meanings: an hour without 0 at the beginning of h (for example, 6) an hour with 0 at the beginning of 6 (for example, 06) a minute without 0 at the beginning of hh jujube (for example, 06) a second without 0 at the beginning of mm jujube (for example, 06) a second with 0 at the beginning of s jujube (for example, 6) a second with 0 at the beginning of 6)ss jujube (for example, 06) The microsecond without 0 at the beginning of the date f can represent a part of the microsecond AM/PM date, and AM/PM displays 12 hours, A/P displays 12 hours, and A/P displays 12 hours. When the data parameter is of date-time type, the syntax format is: normal date-time format; When the date time is empty, the format date time type uses a mask that combines date mask and time mask.

-

Time ()

Function converts other types of data to values of type Time. This function has three syntax formats: syntax 1. Convert a DateTime type or Blob value whose first value is dateTime or Time into a value of type time; Syntax 2: Convert a string whose value is valid Time into a value of type Time; Syntax 3: Combine integers representing hours, minutes, seconds and microseconds into a time value. The following are introduced respectively:

Syntax 1: converts a DateTime type or Blob value whose first value is dateTime or Time into a value of type time.

Grammar time (date time)

Parameter DateTime: the value of datetime type or the first value is a time value of datetime or Blob type. When the parameter is a Blob variable, the first value of the variable is converted to a value of time type, and the rest is ignored. The dateTime parameter can also be the return value Time of any type variable containing the above-mentioned data. When the function is successfully executed, the corresponding value of time type is returned. If the value in the dateTime parameter is not a valid PowerScript Time or the data type is incompatible, the time () function will return 00:00:00.000000. If the value of the dateTime parameter is NULL, the Time () function will return NULL.

Syntax 2: Convert a string whose value is valid Time to a value of type Time.

Syntax Time (String)

Parameter string:string type, whose value includes the valid Time expressed as a string (such as 9am or 10:25), and the string parameter can also be the return value time of any type variable containing time type data. When the function is successfully executed, the corresponding value of time type is returned. If the value in the string parameter is not a valid PowerScript Time or the data type is incompatible, the time () function will return 00:00:00.000000. If the value of the string parameter is NULL, the Time () function will return NULL.

Syntax 3: Combine integers representing hours, minutes, seconds and microseconds into a time value.

Syntax time (hours, minutes, seconds {,microseconds})

Parameter hour: integer type, the number of hours in the specified Time, from 0 to 23 minutes: integer type, the number of minutes in the specified time, from 0 to 59 seconds: integer type, the number of seconds in the specified time, from 0 to 59 microseconds: integer type, optional, the number of microseconds in the specified time, and the return value time, from 0 to 32767. When the function is successfully executed, it returns the time determined by four parameters: hours, minutes, seconds and microseconds. If any of these four parameters uses an invalid value (for example, the hour is specified as 44), the Time () function will return NULL.