Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   repeating strings (https://forums.graalonline.com/forums/showthread.php?t=11429)

Warcaptain 09-08-2001 11:51 AM

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

grim_squeaker_x 09-08-2001 04:40 PM

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"

Warcaptain 09-09-2001 07:02 AM

Thanks :-)


All times are GMT +2. The time now is 07:52 PM.

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