Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-08-2001, 11:51 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
repeating strings

im wondering how i can tell how many times a partstr appears in a string an
d also to display it as a variable
Reply With Quote
  #2  
Old 09-08-2001, 04:40 PM
grim_squeaker_x grim_squeaker_x is offline
Retired Oldbie
grim_squeaker_x's Avatar
Join Date: Mar 2001
Posts: 3,084
grim_squeaker_x will become famous soon enough
The following script might work, since I'm writing it here and now without testing:
NPC Code:
if (created) {
setstring string,abbaaaabaab;
setstring partstring,b;
this.partcount=0;
this.indexof=0;
while (this.indexof!=-1) {
this.indexof=indexof(#s(partstring),#e(this.indexo f,-1,#s(string));
this.partcount+=(this.indexof!=-1);
}
message #s(partstring) occurs #v(this.partscount) times in #s(string);
}


If it does work it should display the following message: "b occurs 4 times in abbaaaabaab"
__________________

Reply With Quote
  #3  
Old 09-09-2001, 07:02 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
Thanks :-)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.