PDA

View Full Version : It's wrong in a test...


perfectboy
08-05-2009, 08:50 AM
a = "good_morning_boy"
--good_morning_boy
b = substring a 1 -4
--good_morning_boy

So what's wrong,why can't get "good_morning_"

VVaari
08-05-2009, 09:24 AM
Take a look at maxscript reference:
<string>substring <string> <from_integer> <length_integer>

<from_integer> and <length_integer> are pretty obvious and there are also examples in maxscript reference :)

So you might want to do something like this:
a = "good_morning_boy"
b = substring a 1 13

biddle
08-05-2009, 09:25 AM
IIRC, a negative length (2nd argument) always gets you to the end of the string regardless of the magnitude. You need to subtract from the length of the string

try:

a = "good_morning_boy"
b = substring a 1 (a.count-4)

perfectboy
08-05-2009, 09:30 AM
IIRC, a negative length (2nd argument) always gets you to the end of the string regardless of the magnitude. You need to subtract from the length of the string

try:

a = "good_morning_boy"
b = substring a 1 (a.count-4)

Hi guys...
It's really my meaning...I want to use "-4" , because i didn't konw how many chars in the front...
Thanks...

CGTalk Moderation
08-05-2009, 09:30 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.