Working with strings/text

Moderator: Moderator Group

Working with strings/text

Postby claude.rivet » Tue Mar 18, 2014 6:55 pm

I searched the help and forums and I could not find the answer, I was wondering how to work with text for a simple task.

I have a bunch of variables of the same type used for various identical modules used concurrently, it looks like this:

me1folder
me2folder
me3folder

Now my goal would be to get the user to just write the number in the function argument and my script would reconstruct the variable name by just changing the number in it. So if the user writes the function as

Code: Select all
mixit{2}


inside the function I would write something like

Code: Select all
VValue,me & arg1 & folder,99


It probably is not the good procedure but I hope you guys get the idea, is it possible?

Thanks for the help
regards
claude.rivet
 
Posts: 67
Joined: Tue Aug 07, 2012 5:40 pm

Re: Working with strings/text

Postby malkuth23 » Wed Mar 19, 2014 12:38 am

I think only with a text combiner node is this possible... but maybe there is another way.
Matthew Newman-Saul
Theatrical Concepts
mattns@theatrical.com
User avatar
malkuth23
 
Posts: 354
Joined: Tue Apr 20, 2010 7:14 pm
Location: New Orleans, LA

Re: Working with strings/text

Postby Dennis Kuypers » Thu Mar 20, 2014 3:50 pm

Hey,

You can create a function for that. Call it something like "concat{str1,str2}" and use the following code:
Code: Select all
VString,_tmp_concat,
VValue,_tmp_concat,str1
VAdd,_tmp_concat,_tmp_concat,str2
Return _tmp_concat
This will return the two strings glued together, for example calling "concat{dennis,kuypers}" will give you "denniskuypers"

If you only need it for your "ID" insertion then you can have a slightly different version like so: "mixit{number}"
Code: Select all
VString,_tmp_mixit,me
VAdd,_tmp_mixit,_tmp_mixit,number
VAdd,_tmp_mixit,_tmp_mixit,folder
Return _tmp_mixit
This will create your "meNUMBERfolder" string, a call to "mixit{4}" gives you "me4folder"

I haven't tested it but it should work like that.

Best regards
Dennis
Dennis Kuypers
(former Product Developer, Software)
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm

Re: Working with strings/text

Postby claude.rivet » Fri Mar 21, 2014 5:00 pm

Great, I'll try those methods, it makes sense, I like the function method but I guess I was mainly looking at the correct commands to use to merge strings, I thought VAdd was requiring number variables, happy to know it works for strings.

Thanks, much appreciated!
claude.rivet
 
Posts: 67
Joined: Tue Aug 07, 2012 5:40 pm

Re: Working with strings/text

Postby malkuth23 » Fri Mar 21, 2014 6:36 pm

Cool! I did not know that either. Vadd for combining text is very useful.

Thanks
Matthew Newman-Saul
Theatrical Concepts
mattns@theatrical.com
User avatar
malkuth23
 
Posts: 354
Joined: Tue Apr 20, 2010 7:14 pm
Location: New Orleans, LA

Re: Working with strings/text

Postby claude.rivet » Tue Mar 25, 2014 4:05 pm

I am so close to get what I need, one variable away from happiness :)

Here is a very good example of what I need to do and even with the ideas suggested I still cannot figure out how to achieve what I want.

I launch a file from a CustomScriptButton, at some point I write:
Code: Select all
DeviceSetParam,1,2,Playback Transport,but16mode


but16mode is a variable that is set by the user using another button, its value is either 192(loop) or 64(play)

In a perfect world I would reference the variable but16mode using the ID of the CustomScriptButton, I came up with the following using what I learned in this thread:
Code: Select all
VValue,_tmp_pbmode,but
VAdd,_tmp_pbmode,_tmp_pbmode,MyID
VAdd,_tmp_pbmode,_tmp_pbmode,mode
DeviceSetParam,1,2,Playback Transport,_tmp_pbmode


it doesn't work, even though the value of _tmp_pbmode is but16mode the parameter is viewed as a string and not as the value referenced by that string, fair enough. I need to assign the value to another temporary variable which would be int. This is the result (_tmp_pbmode is string, _tmp_butmode is int):
Code: Select all
VValue,_tmp_pbmode,but
VAdd,_tmp_pbmode,_tmp_pbmode,MyID
VAdd,_tmp_pbmode,_tmp_pbmode,mode
VValue,_tmp_butmode,_tmp_pbmode
DeviceSetParam,1,2,Playback Transport,_tmp_butmode


Still doesn't work.

If you have any idea how to do what I want your help would be greatly appreciated.
Regards
claude.rivet
 
Posts: 67
Joined: Tue Aug 07, 2012 5:40 pm

Re: Working with strings/text

Postby claude.rivet » Wed Mar 26, 2014 3:59 pm

Found a workaround, I am using labels, one per button, numbered 1000 higher, so button 1 is assigned label 1001 and so on and so forth.

then it looks like that:
Code: Select all
VValue,_temp_butID2,1000
VAdd,_tmp_butID2,_tmp_butID2,MyID
VGetLabelText,_tmp_pbmode2,_tmp_butID2
DeviceSetParam,1,2,Playback Transport,_tmp_pbmode2
claude.rivet
 
Posts: 67
Joined: Tue Aug 07, 2012 5:40 pm


Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 36 guests