432
Chapter 12: Methods
numToChar()
Usage
numToChar(
integerExpression
)
Description
Function; displays a string containing the single character whose ASCII number is the value of a
specified expression. This function is useful for interpreting data from outside sources that are
presented as numbers rather than as characters.
ASCII values up to 127 are standard on all computers. Values of 128 or greater refer to different
characters on different computers.
Parameters
integerExpression
Required. Specifies the ASCII number whose corresponding character
is returned.
Example
This statement displays in the Message window the character whose ASCII number is 65:
put numToChar(65)
The result is the letter
A
.
This handler removes any nonalphabetic characters from any arbitrary string and returns only
capital letters:
-- Lingo syntax
on ForceUppercase input
output = EMPTY
num = length(input)
repeat with i = 1 to num
theASCII = charToNum(input.char[i])
if theASCII = min(max(96, theASCII), 123) then
theASCII = theASCII - 32
if theASCII = min(max(63, theASCII), 91) then
put numToChar(theASCII) after output
end if
end if
end repeat
return output
end
// JavaScript syntax
function ForceUpperCase(input) {
output = "";
num = input.length;
for (i=1;i<=num;i++) {
theASCII = input.char[i].charToNum();
if (theASCII == min(max(96, theASCII), 123) {
theASCII = theASCII - 32;
if (theASCII == min(max(63, theASCII), 91) {
output = theASCII.numToChar();
}
}
}
return output;
}
See also
charToNum()
Summary of Contents for DIRECTOR MX 2004
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...