Help needed with Director (Shockwave)

Righty’o

I need someone who knows a thing or two about Director to help me build something…

What I need is a script that can take a given string and split it up into smaller parts.
The string could look like this:

something/Bla_Key_Some.txt

or

something\LALALALA_KKEEYY_So.txt

I need the script to check if the last 4 chars is .txt

Then I need to put everything from the . to the first _ in a variable..
and then from the first _ to the next _ in another variable..
and then from the last _ to the first / or \ in another variable..

so the last test string would be parsed to something like this:

something\LALALALA_KKEEYY_So.txt =
Var1 = So
Var2 = KKEEYY
Var3 = LALALALA

If you can do this… Ill donate 1500 EFD to your account or any account you whish for..

btw.. It has to be in lingo…

I don’t know how director does it, but in C/C++ I would rfind() on .txt then if it matches split off the front half and just loop around using rfind(spacer, currindex), tracking the current index in the string as you go.

I suppose director has string manipulation features similar to this, or you can write your own find/rfind from basic array manipulation functions if it doesn’t.

  • Deathifier

ive worked quite a bit with director, but i think it doesnt work the way you want it to work, you need to make separate variables for every word, i got a lingo dictionary here ill look

cant find it in the dictionary, please be slightly more specific in what kind of script you want

set mNum = the member of sprite the currentSpriteNum
set mName = the name of member mNum
set mName = char 1 to length(mName)-2 of mName
set the member of sprite the currentSpriteNum to member mName

This cuts off the last 2 chars of mName and “reloads” mName with the new string…

Basically… I need to make a loop.. that first check the last four..
so.. something like
char length(mName) - 4 to length(mName) .. if thats = .txt then proceed..
Then make a loop..

i = 1
loop here..

if char length(mName) - 4 - i to length(mName) - 4 + 1 - i = _ then
– Var1 = char length(mName) - 4 - i to length(mName) - 4

Then do so for the other _ as well…

thats the way to do it.. I think…

:smiley:

Pretty simple really :wink:

myLen = length(myString)
myExtension = myString.char[myLen-4..t]

now check to see if myExtension = “.txt”

Send those EFD to ultimababe plz :smiley:

prehaps its a bit unclear..

I have a given string…
could be: soemthing/blabla_key_hey.txt

I want it to check its a txt file…

Then, if it is, i want the script to split the original string upto subsrtings using the _ as a seperator..

the above example would be:

Var1 = blabla
Var2 = key
Var3 = hey

:smiley:

Right! Challenge heheh

Note: everything that starts with a ’ is a comment

[B]
myLen = length(myString)
myExtension = myString.char[myLen-4..t]

if myExtension = “.txt” then
’ Firstly, remove the “.txt” - we dont need it any more
myString=myString.char[1..myLen-4]
’ And loop through the remaining string character by character

myLen = length(myString)
repeat while myLen > 0
repeat with myLoop = 1 to myLen
’ Check for ""
if myString.char[myLoop] = "" then
’ Discard everything before it
myString=myString.char[myLoop+1..myLen]
end if

     ' Check for "_"
     if myString.char[myLoop] = "_" then
        ' Use an array to hold the variables, as we dont know how many there will be
        myArrayCounter = myArrayCounter + 1
        ' Store the text preceding the "_"
        myVar[myArrayCounter] = myString.char[1..myLoop-1]
        ' And discard it and the "_"
        myString = myString.char[myLoop+1..myLen]
     end if
  end repeat

end repeat
myLen = length(myString)
end if

[/B]

That should work

Sorry, but I did nest everything nicely, but the php pulled the spaces out

Send those EFD to ultimababe plz

[QUOTE=FireW0lf]
Sorry, but I did nest everything nicely, but the php pulled the spaces out
[/QUOTE]

In such cases try using the HTML tag, like this…

[HTML]myLen = length(myString)
myExtension = myString.char[myLen-4..t]

if myExtension = “.txt” then
’ Firstly, remove the “.txt” - we dont need it any more
myString=myString.char[1..myLen-4]
’ And loop through the remaining string character by character

myLen = length(myString)
repeat while myLen > 0
repeat with myLoop = 1 to myLen
’ Check for ""
if myString.char[myLoop] = "" then
’ Discard everything before it
myString=myString.char[myLoop+1..myLen]
end if

     ' Check for "_"
     if myString.char[myLoop] = "_" then
        ' Use an array to hold the variables, as we dont know how many there will be
        myArrayCounter = myArrayCounter + 1
        ' Store the text preceding the "_"
        myVar[myArrayCounter] = myString.char[1..myLoop-1]
        ' And discard it and the "_"
        myString = myString.char[myLoop+1..myLen]
     end if
  end repeat

end repeat
myLen = length(myString)
end if[/HTML]

…or the PHP tag…

[PHP]myLen = length(myString)
myExtension = myString.char[myLen-4..t]

if myExtension = “.txt” then
’ Firstly, remove the “.txt” - we dont need it any more
myString=myString.char[1..myLen-4]
’ And loop through the remaining string character by character

myLen = length(myString)
repeat while myLen > 0
repeat with myLoop = 1 to myLen
’ Check for ""
if myString.char[myLoop] = "" then
’ Discard everything before it
myString=myString.char[myLoop+1..myLen]
end if

     ' Check for "_"
     if myString.char[myLoop] = "_" then
        ' Use an array to hold the variables, as we dont know how many there will be
        myArrayCounter = myArrayCounter + 1
        ' Store the text preceding the "_"
        myVar[myArrayCounter] = myString.char[1..myLoop-1]
        ' And discard it and the "_"
        myString = myString.char[myLoop+1..myLen]
     end if
  end repeat

end repeat
myLen = length(myString)
end if[/PHP]

See ? you get the colors right too :slight_smile:

Ooooh thats nifty :smiley:

Hmmmm ulti doesn’t seem to have received those EFD… :confused:

yeah.. dident you get my PM.. it dident work.. endless loop…

I sent you the one I made my self, as you could see.. its much diffrent to yours :wink:

Hmmmm not that much different to be honest :wink:

There’s only so many ways to parse thru a string line by line… but never mind

The only difference between yours and mine is that I scrap the *****\ first, and you do it last

The main thing is that you now have working code
:slight_smile: