PDA

View Full Version : Trouble with a char to ascii code function in maxscript


bloodlocust
06-30-2002, 10:53 PM
Hi there!

Work is going really well on the maxscript exporter plugin for blitz3d. I'm having a bit of a pain trying to figure out an effecient way to create a basic ASC( str$ ) function in maxscript.

basically, I want the function to Return the ASCII value of the first letter of a string, or char.

Is there an inbuilt function or do I have to code one up myself? it seems odd if it's omitted...

Any help will be much appreciated

Thanks!

bloodlocust
07-01-2002, 12:51 AM
If the above isn't possible, what could be the fastest way to check a letter and have it return a number? :)

bloodlocust
07-01-2002, 01:21 AM
lol... well here is my attempt.

--shitty ASC converter... pain ensues

fn asc str =
(
case str of
(
a : (Return 97)
b : (Return 98)
c : (Return 99)
d : (Return 100)
e : (Return 101)
f : (Return 102)
g : (Return 103)
h : (Return 104)
i : (Return 105)
j : (Return 106)
k : (Return 107)
l : (Return 108)
m : (Return 109)
n : (Return 110)
o : (Return 111)
p : (Return 112)
q : (Return 113)
r : (Return 114)
s : (Return 115)
t : (Return 116)
u : (Return 117)
v : (Return 118)
w : (Return 119)
x : (Return 120)
y : (Return 121)
z : (Return 122)
A : (Return 65)
B : (Return 66)
C : (Return 67)
D : (Return 68)
E : (Return 69)
F : (Return 70)
G : (Return 71)
H : (Return 72)
I : (Return 73)
J : (Return 74)
K : (Return 75)
L : (Return 76)
M : (Return 77)
N : (Return 78)
O : (Return 79)
P : (Return 80)
Q : (Return 81)
R : (Return 82)
S : (Return 83)
T : (Return 84)
U : (Return 85)
V : (Return 86)
W : (Return 87)
X : (Return 88)
Y : (Return 89)
Z : (Return 90)
1 : (Return 49)
2 : (Return 50)
3 : (Return 51)
4 : (Return 52)
5 : (Return 53)
6 : (Return 54)
7 : (Return 55)
8 : (Return 56)
9 : (Return 57)
0 : (Return 48)
)
)

bit of a mess really :) works tho ( I think! )

nates
07-01-2002, 05:01 AM
Why not just use the built in bit.charAsInt () function?

bloodlocust
07-01-2002, 05:23 PM
Doh. Never saw it :(

Thanks old chap ...

CGTalk Moderation
01-13-2006, 09:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.