A common sticking point and the docs don't give the full picture.
Years back I learnt the ugly trial and error way, then I started to get it at the "understand it but can't fully explain it" level, but as I've got better at c++ coding I can explain it.
So... this one might go on a bit [P.S edit omg], but generally the thing to keep in mind is; quotes [and ' and `] are used to say
Thing inside quotes is one thing, one value, one word, one parameter.
That probably won't make sense yet, hopefully it will by the end.
So first lets get into how script works at the "in app" c++ code level [sort of]... Strap in.
script verbs[single commands] are c++ function calls, if you don't know what a function is, it's a block of instructions given a simple name so you don't have to list every step every time.
IRL example, I might think, makeACupOfTea;
and that seems straight forward, but really there's loads of steps to it
makeACupOfTea()
{
find clean cup;
find clean tea spoon;
fill kettle with enough water;
tea bag in cup;
spoon sugar into cup
boil kettle;
}
you get the idea even if I have missed about 10 steps.
some verbs/functions have parameters you can pass something - a number - a name - a logic state [true/false, also known as boolean or bool], to the function to make it act a certain way.
Back to my stupid IRL example
makeACupOfTea( alice 1 True );
This is completely made up but param1 is who I'm making the tea for (maybe they have a special cup) param2 is number of sugars, param3 is a bool, does it need milk)
Pretty boring and basic but this is the ground work;
Now what if this was my instruction instead
makeACupOfTea( True alice 1 );
The params are in the wrong order.
I can figure it out, but a computer can't, it has to to told everything, unless it's been told [when the program is written] you might get params in this order and in that case read them in a slightly different way to get the intended result.
In c++ you can do something called overloading functions, that is to have several functions all with the same name but they accept different parameters and they have to act differently [are wrote different at the c++ level] to deal with the different data types.
The machine has been told all the different orders it might get handed params and from the types [number, name, bool] of param in order it can figure out which overload to use by a process of elimination.
That's a 2 minute explainer to what functions are, one last thing;
Functions can have default parameters, that is to say, if you don't put include a parameter the guy who wrote the program could have assumed something for you.
Back to my stupid IRL example
makeACupOfTea();
... no params, yeah I'm making a cup of tea for myself I don't need to remember anything, it's something I do before I'm entirely awake I can autopilot this.
Somewhere deep in my brain there is a set of instructions
makeACupOfTea, if no params ? myCup 2sugars milk
So how does the vdj read in params or script in general? It's pretty simple and very efficient,
c++ has a input method called "custom data" it just takes the first valid letter number or symbol and keeps reading until it hits an invalid character,
everything it read up to that point becomes the param,
what is the invalid char? [the delimiter, if you want the proper term]
It's the space char.
Notice how no script verb contains a space? lots of under_scores but never a space.
There's a tiny couple of things about invalid chars I'll come back to, but keep this in mind,
params are separated by spaces
Verbs that accept script actions as parameters.
If a verb accepts script actions as a param is down to the verb,
It down to the fact if the programmer (sClavel or adion) included an overload for that verb to accept script actions as a value.
It's not a language wide convention. The verb description will say 'accepts actions as a param', if the verb allows it.
Now, scripts usually contain a space [interesting scripts not single commands], and earlier we said a space would act as a delimiter...
So we need to tell the machine
treat everything here including the spaces as one param
We wrap it in `` '' or "" , we encapsulate it.
Now some verbs you can use any of the 3 above interchangeably no problem, there is no ambiguity because it can work out the intention from the param data types,
All these will work, the program does not care
set a 0 & set b 0 & set c 0 & var_list & wait 2000ms & set a 1 & set b 2 & param_add "get_var a" "get_var b" & param_cast & set c & var_list
set a 0 & set b 0 & set c 0 & var_list & wait 2000ms & set a 1 & set b 2 & param_add `get_var a` `get_var b` & param_cast & set c & var_list
set a 0 & set b 0 & set c 0 & var_list & wait 2000ms & set a 1 & set b 2 & param_add 'get_var a' 'get_var b' & param_cast & set c & var_list
set a 0 & set b 0 & set c 0 & var_list & wait 2000ms & set a 1 & set b 2 & param_add 'get_var a' `get_var b` & param_cast & set c & var_list
get_var LETTER is script as a parameter for the param_add verb, but it contains a space so we encapsulate with ' " or `
but there are some verbs when it might not be clear. Some verbs where there's lots of overloads and simple process of elimination won't work.
think of this, you set these vars with a button
set a 1 & set b 1
Now you have another button
param_equal "get_var a" "get_var b" ? on : off
Should return true right?
Wrong, param_equal has lots of overloads and one of those is string comparison, and from the params given it will assume string comparison.
So for param_equal script actions have to be wrapped in ` ` then there's no doubt what the intention is
param_equal `get_var a` `get_var b` ? on : off
The set verb is another where using a script action as a param [for param2] you must use ` `
Set is used for setting a variable, to a value, to a script action value, or to the value of another variable.
The first param is ALWAYS a string for the name.
The second param is the value and there are overloads, and if you neglect to include something as a value it has a default value of 1
user set value
set a 2.4
script action as a value
set a `deck 1 level`
setting the variable to the value of another variable by name
set a 0 & set b 3 & set a b
Ok some of you might have noticed I don't use ' or " when using a var name, that's because it's not really needed, the var name is a parameter, as long as it doesn't hit an invalid char it will read it as a string without encapsulation.
[and sometimes every ` ' " is precious doing complicated stuff]
So the important question what are the invalid chars?
Well there's a list and I don't know them all but I do remember a few important rules that means you don't have to know every char
When the variable is a persistent, [is remembered even after a restart] so the name starts with a @ symbol. @ is an invalid char,
ALWAYS use " " or ' ' when dealing with persistent variable names.
Don't start variable names with numbers, just a rule from c++ and it applies in vdj script too.
Avoid using symbols in var names without wrapping the var name in " " or ' ' except;
$ as a start for a global var name
% as a start for a local var name [but really don't bother with using % in names]
_underscore is fine anywhere
generally avoid using symbols.
That's pretty much it, when ' should be a little bit clearer.
I could give examples of deep ` use but I think we're good for now.
Posted Sun 20 Apr 25 @ 11:00 pm
Questions about Hotcues:
1-M’y understanding is that all cues in VDJ are ‘hot’. I always have to hotcue then press Cue if I want to move the head to a position without playing. There are no memory cues like PDJ. Is it the case?
2-I would like to be able to show the First Beat (and others) on the waveform when I setup my tracks. It can be done in the POI by setting Marker Only instead of Invisible. I would like to have a button to automate this. I tried without success. Can someone advise me?
3-I’m trying to add cues in a script at the next available position. Do I have to search each time for an empty slot (from 1 to 8 in my case) or is there a way to do it more directly?
1-M’y understanding is that all cues in VDJ are ‘hot’. I always have to hotcue then press Cue if I want to move the head to a position without playing. There are no memory cues like PDJ. Is it the case?
2-I would like to be able to show the First Beat (and others) on the waveform when I setup my tracks. It can be done in the POI by setting Marker Only instead of Invisible. I would like to have a button to automate this. I tried without success. Can someone advise me?
3-I’m trying to add cues in a script at the next available position. Do I have to search each time for an empty slot (from 1 to 8 in my case) or is there a way to do it more directly?
Posted 5 days ago @ 4:35 pm
1 If you're wanting a memory cue then logically you won't be playing the track that instant
pause, turn hotcue stutter on, call the cue, revert stutter setting if you need to
this can all be built into a padpage.
There's a few ways this could be done with script
2 Adding a marker can't done with script currently, I have a windows plugin to do this.
I charge a couple of beers for it.
3 I'm certain there is a verb that does this but I can't find it, had a call to use it myself and found it in testing but because my thing started at cue 11 I didn't use it in the end.
pause, turn hotcue stutter on, call the cue, revert stutter setting if you need to
this can all be built into a padpage.
There's a few ways this could be done with script
2 Adding a marker can't done with script currently, I have a windows plugin to do this.
I charge a couple of beers for it.
3 I'm certain there is a verb that does this but I can't find it, had a call to use it myself and found it in testing but because my thing started at cue 11 I didn't use it in the end.
Posted 5 days ago @ 5:08 pm
For 1, you could also create a pad page using goto_cue 1 instead of hot_cue 1
Posted 5 days ago @ 7:03 am
3 looks like I was mistaken, you'll have to
( has_cue 1 !? set_cue 1 : has_cue 2 !? set_cue 2 : has_cue 3 !? set_cue 3 : .... ) &
Posted 5 days ago @ 7:56 am
Thanks both of you for the help! I’m currently unable to try, but will be in a few days.
I was not aware of the ! Operator used in !? Can it be used in different contexts?
I was not aware of the ! Operator used in !? Can it be used in different contexts?
Posted 5 days ago @ 11:33 am
Yan Duval wrote :
I was not aware of the ! Operator used in !? Can it be used in different contexts?
I was not aware of the ! Operator used in !? Can it be used in different contexts?
Yes did I miss that somewhere, I have not seen that operator usage, what exactly does it do?
It looks like it's 'if the query is negative then do this action'
Is that a correct assumption.
Posted 5 days ago @ 11:40 am
Correct, basically it inverts the query and can be applied to almost any query
so say deck is paused, and you query
play !?
the replies to the query are like so
I used !? in the cue case above because it was neater to write that way.
The normal way would have been like this which isn't as clear
has_cue 1 ? has_cue 2 ? has_cue 3 ? set_cue 4 : set_cue 3 : set_cue 2 : set_cue 1
so say deck is paused, and you query
play !?
the replies to the query are like so
play !? deck is not playing : deck is playing
I used !? in the cue case above because it was neater to write that way.
The normal way would have been like this which isn't as clear
has_cue 1 ? has_cue 2 ? has_cue 3 ? set_cue 4 : set_cue 3 : set_cue 2 : set_cue 1
Posted 5 days ago @ 11:57 am
set result 0 & set a 1 & set b 2 & set c 4 & set d 8 & set e 16 & set f 32 & set g 64 & set h 128 & param_add `param_add "param_add 'get_var a' 'get_var b'" "param_add 'get_var c' 'get_var d'"` `param_add "param_add 'get_var e' 'get_var f'" "param_add 'get_var g' 'get_var h'"` & param_cast & set result & var_list
So the first bit is just setting some variables, no need to explain
then we say param_add and our param is a script action so we open a ` then our script action is param_add again and the param for that is a script action so we open a " then our script action is param_add again and it's params are also a script action so we open a '
this 3rd level of param_add, the ' is open the first param is get_var a, so then we close the ' , we're onto the 2nd param for the 3rd param_add so we open another ' get_var b the close the '
that completes the 1st param for the 2nd param add so we close the "
we're now onto the 2nd param of the 2nd param_add so we open another " and so on.
This is a pretty dumb example but this is as deep into script inception you can go.
And I have gone that deep in some cases.
One thing I dislike is spaces in fx names, the fx name needs to be wrapped in ' or " and that means I can go 3 levels deep with echo but I can't go as deep with "mt delay"
that's why all my fx I've created never contain a space, sometimes I use camelCase, sometimes I use under_score
that said it's a super rare case that I have to go that deep and I can work my way round it usually, but it would be nice if fx names were under_scored instead of containing spaces.
But script is a language, languages are never 100% consistent.
Posted 5 days ago @ 12:52 pm
Is it possible to script a custom button to add a shortcut to the focused folder from the Folder List for quick access? It should work like the button in sideview: Leftclick = Add shortcut, Rightclick = Delete shortcut, Buttontext = Foldername?
Now i have the edit the custum button script ex. browser_shortcut 1 every time i want to change it.
Now i have the edit the custum button script ex. browser_shortcut 1 every time i want to change it.
Posted 19 hours ago
browser_shortcut with no param and it will default to the next available number, deleting - since you're using the mouse already just right click the shortcut.
Posted 19 hours ago
Thanks Locodog, but i want the button to act like a shortcut not only add a shortcut to the side toolbar.
Like this:
Like this:

Posted 19 hours ago
name buttons
`browser_shortcut NUM`
script buttons
browser_shortcut NUM
use the button with the first empty name for new shortcut
`browser_shortcut NUM`
script buttons
browser_shortcut NUM
use the button with the first empty name for new shortcut
Posted 18 hours ago
Thanks, it works great, but the button name doesnt work. I have tryed to copy your text
`browser_shortcut NUM`, tryed to change ` to ', ´ and ". No name in the button after shortcut is created
Posted 17 hours ago
you are using an actual number and not using the text NUM, right?
Posted 17 hours ago
How stupid I am :-). Now it works exactly as I want it to be. Thanks!
Posted 16 hours ago