Say you're looking for the step size of a brush, just an example.
If you run this with the cutbrush active you can see my dilemma, it's monstrous
tv_getactivetool
Print result
I need the stepsize in this example no matter what brush is currently selected.
The problem comes because you can't count on "step" always being in the same position in the result variable, some brushes doesn't even have step.
Isn't there a way to do something like:
Parse Result "Step" MyStepSize
Or just some function that splits the result variable into an array so I can loop through it to grab what I need.
Grabbing a named parameter with Parse?
Grabbing a named parameter with Parse?
There's no place like ~/
Re: Grabbing a named parameter with Parse?
Hi Ken,
This puzzled me for a while but experimenting I came up with this:
Sven
This puzzled me for a while but experimenting I came up with this:
Code: Select all
tv_GetActiveTool
parse result Tool
parse result ToolType d // d = dummy so we are parsing out only the type of tool
IF CMP(ToolType, "tv_restorebrush")
tv_BrushRestore Size
parse result d BrushSize // again we use a dummy to parse only the brush value
// tv_warn BrushSize // remove comment to report current brush size
BrushSize = BrushSize - 5
IF BrushSize < 5
BrushSize = 5
END
tv_cmd Tool // restores settings as acquiring individual parameter resets all others
tv_BrushRestore Size BrushSize
END
Re: Grabbing a named parameter with Parse?
Thanks a lot Sven.
That also gave me a clue on how to parse "Result" into an array, just use that technique to hack off one value at a time and reparse the last dummy that will contain the rest and then stick each one into the array.
I tried using the built in functions like CHAR but it barfs on me when using a counter instead of a literal number like this
StrLen = LEN(Result)
For i=1 to StrLen
Print CHAR(Result,i)
END
This bombs with an execution error, because of using the counter variable "i" I'm guessing?
If I do this
Print CHAR(Result,5)
Then it works?
That also gave me a clue on how to parse "Result" into an array, just use that technique to hack off one value at a time and reparse the last dummy that will contain the rest and then stick each one into the array.
I tried using the built in functions like CHAR but it barfs on me when using a counter instead of a literal number like this
StrLen = LEN(Result)
For i=1 to StrLen
Print CHAR(Result,i)
END
This bombs with an execution error, because of using the counter variable "i" I'm guessing?
If I do this
Print CHAR(Result,5)
Then it works?
There's no place like ~/
Re: Grabbing a named parameter with Parse?
arrrrrgh so close but no cigar.
When parse doesn't have anything more to parse (String parsed is empty) it sticks "0" in there so now I can't check for a blank string to know when to bail from a while loop because the Result variable can contain 0 as part of a brush's value.
I guess I can do something ugly like sticking my own "end of line" character on to the result string.
When parse doesn't have anything more to parse (String parsed is empty) it sticks "0" in there so now I can't check for a blank string to know when to bail from a while loop because the Result variable can contain 0 as part of a brush's value.
I guess I can do something ugly like sticking my own "end of line" character on to the result string.
There's no place like ~/
Re: Grabbing a named parameter with Parse?
Ken,
Do you have the basic and advanced include files usually found in the George\Include subdirectory? If not, you should request them from TVPaint Headquarters.
Sven
Do you have the basic and advanced include files usually found in the George\Include subdirectory? If not, you should request them from TVPaint Headquarters.
Sven
Re: Grabbing a named parameter with Parse?
no they weren't installed with my version of tvpaint, there wasn't even the george folder so I just hacked my way so far
I'll send an email requesting it, thanks.
An updated SDK would also be lovely
I'll send an email requesting it, thanks.
An updated SDK would also be lovely
There's no place like ~/