UserCommand's, variables & concatenation

What I want to do it quite simple, but I think its going to take a bit to explain!

I have these toolbars :
My_Sidebar1
My_Sidebar2
My_Sidebar3
My_Sidebar_Header1
My_Sidebar_Header2
My_Sidebar_Header3

I essentially just want to be able to call a function to toggle between them, something along the following :
SidebarToggle(On,Off)

So if I called
SidebarToggle(1,3), this would turn on sidebar 1 and turn off sidebar 3

I have created a UserCommand, and it takes this format :

SidebarToggle ON,OFF

Here is the code for the user command "SidebarToggle"
@set Close_Sidebarname_Header="My_Sidebar_Header 1"
@set Close_Sidebarname "My_Sidebar 1"
@set Open_Sidebarname_Header "My_Sidebar_Header 7"
@set Open_Sidebarname "My_Sidebar 7"
Toolbar NAME={$Close_Sidebarname_Header} CLOSE
Toolbar NAME={$Close_Sidebarname} CLOSE
Toolbar NAME={$Open_Sidebarname_Header} LINE 2,835
Toolbar NAME={$Open_Sidebarname} STATE=right

At the moment all the variables are hardcoded to the actual toolbar names, ie "My_Sidebar_Header 1" - this is because I have never made a user command and I just wanted to see if I could get it working before trying to pass arguments to it.

I call this with SidebarToggle OFF=1 ON=2, and this works fine, the sidebars open/close as I want/expect - because they are hardcoded - but at least I know the user command is working.

Now, what I just can NOT get working (and ive tried all sorts!! lol), is for the user command to try and make use of the arguments it gets passed. I was hoping I could do something along the following, but it doesnt work.

@set Close_Sidebarname_Header="My_Sidebar_Header " & OFF
@set Close_Sidebarname "My_Sidebar " & OFF
@set Open_Sidebarname_Header "My_Sidebar_Header " & ON
@set Open_Sidebarname "My_Sidebar " & ON
Toolbar NAME={$Close_Sidebarname_Header} CLOSE
Toolbar NAME={$Close_Sidebarname} CLOSE
Toolbar NAME={$Open_Sidebarname_Header} LINE 2,835
Toolbar NAME={$Open_Sidebarname} STATE=right

I just need a way to concatenate the string "My_Sidebar_Header" (for example) with the OFF variable and storing that in the Close_Sidebarname_Header variable.

Or is there a way I could reference it like ;
Toolbar NAME="My_Sidebar_Header " & OFF CLOSE

Eliminating the need for variables.

Any help would be appreciated! :smiley:

In a user-defined command, you have to put &...& around the argument names to insert their values into the command.

& is not a concatenation operator like in VBScript; instead if has to surround the argument name.

e.g. I think this is right (although I haven't double-checked it):

Toolbar NAME="My_Sidebar_Header&OFF&" CLOSE

The manual page I linked has a bunch of examples.

doh! I did read the manual believe it or not, and I got close, I had - Toolbar NAME="My_Sidebar_Header{&OFF&}" CLOSE

i'll give it a try in a minute, and let you know if it works!

Thanks again for the super quick reply and solution! :smiley:

It works!! yay!!! If I could give you a kiss I would!!!

Thanks :smiley: