Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
ugcity
Newbie


Joined: 24 Jul 2010
Posts: 2

PostPosted: Sat Jul 24, 2010 7:55 pm   

Extracting substring base on index
 
Hi everyone.

I am struggling on extracting substring base on index of string by zscript.
For example there is a string "Hello World", how can I extract the characters from position 3 to 8, that is "llo Wo" and put it in a variable? Rolling Eyes
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Jul 25, 2010 1:34 am   
 
In Visual Basic the equivalent would be the MID() function, but in CMud it's a combination of two functions out of a possible 4:

%right()
%left()
%rightback()
%leftback()

Each one takes two arguments, the first being the string to work on and the second being the character position to start.
_________________
EDIT: I didn't like my old signature
Reply with quote
ugcity
Newbie


Joined: 24 Jul 2010
Posts: 2

PostPosted: Sun Jul 25, 2010 5:04 am   
 
I got it. Thanks a lot. Razz
Reply with quote
markb
Beginner


Joined: 15 Jul 2010
Posts: 12

PostPosted: Wed Jul 28, 2010 4:39 pm   
 
Actually there is a cleaner version using one command %copy;

Syntax: %copy(string,start,len)

return a portion of string, starting at character position start (the first character is position 1), and returning len characters. If len is missing, then the rest of the characters in the string are returned. If start is less than zero, then the start position is relative to the end of the string instead of the beginning.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net