| «‹ July 2026 ›» | | S | M | T | W | T | F | S | | | | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | 9 | 10 | 11 | | 12 | 13 | 14 | 15 | 16 | 17 | 18 | | 19 | 20 | 21 | 22 | 23 | 24 | 25 | | 26 | 27 | 28 | 29 | 30 | 31 | |
|
2009 年 9 月 11 日 星期五  |
| String Procedures |
分類: Programming Language |
High-level Programming Language (Pascal)
String Procedures
- val (<InStr>, <Num>, <ErrorCode>)
- converts a <InStr> to its numeric equivalent
- if the conversion is successful, <Num> is assigned this numeric value and the <ErrorCode>, is assigned the value 0
- if the conversion is unsuccessful, <ErrorCode> is assigned the position of the first invalid character in the <InStr> and <Num> is set to 0
- if <Num> is declared as an integer, the <InStr> will be converted into an integer
- if <Num> is declared real, the <InStr> will be converted into real
- <ErrorCode> must be declared as an integer
- for example,
|
InStr
|
Data type of Num
|
Num
|
ErrorCode
|
Remarks
|
|
'153'
|
integer
|
153 |
0
|
Valid conversion |
|
'153'
|
real
|
1.5300000000E+02 |
0
|
Valid conversion |
|
'52.68'
|
real
|
5.2680000000E+01 |
0
|
Valid conversion |
|
'52.68'
|
integer
|
0 |
3
|
Decimal point is invalid for Num being an integer |
|
'7A12'
|
integer
|
0 |
2
|
First invalid character is A |
- str (<Num>, <OutStr>)
- converts a numeric value, <Num>, to its string representation and assigns this string value to <OutStr>
- <OutStr> must be string data type
- field descriptors can be included in the str procedure to specify the string format
- str (<Num>:<w>:<d>, <OutStr>)
- for example,
|
Num
|
Data type of Num
|
Procedure call
|
OutStr
|
|
135
|
integer
|
str (Num, OutString) |
135 |
|
135.0
|
real
|
str (Num, OutString) |
1.3500000000E+02 |
|
135.79
|
real
|
str (Num:8:3, OutString) |
135.790 |
|
24.3432
|
real
|
str (Num:2:0, OutString) |
24 |
|
|