Variables and Menus


I am very happy about the new version 11 of DO, and one of the things that i was waiting for seems to came up : Vars !
So i want to update my buttons, and few questions appeared :

First, I want to make a button to ask a path and a name to the user, and store them in variables. I think that i will not meet problems with it.
Second, I want to make another buton that will make the lister shows the desired path, stored in the variable.
Third (still there ? :wink: ), I want to use the value of a variable in the label of the button. Is it possible ??

Thanx for any help :slight_smile:

I'm not sure you can do the third thing.

The other two are easy, but may actually be best handled by an old-fashioned alias instead.

You can set an alias like this:

Favorites ADD=alias NAME=docs PATH "C:\Users\Jon\Documents"

(Using one of the {dlg...} codes instead of a hardcoded path, if you wish.)

You can then use the alias as you would any other, e.g. Go /docs

I don't want to use favorites for this, because i want to store paths used in my buttons, independently.

So i tried this :
One button with this code to store the path :

Set dlg = DOpus.Dlg dlg.title = "Choisissez le dossier à enregistrer..." chemin1 = dlg.folder DOpus.Vars("chemin1") = chemin1 dlg.message = "Votre choix : " & chemin1 dlg.Show

This button works fine...

But to make the second button, can you tell me why this kind of code doesn't work ??

@Set chemin = "C:\" Set dlg = DOpus.Dlg dlg.message = "{$chemin}"

Thanx in advance :slight_smile:

Not favorites, aliases. (It just uses the Favorites command, which does aliases as well.)

Whatever you do, the path won't literally be stored "in the button", it will live in the configuration somewhere, either as a saved variable, a script configuration parameter, or as an alias or similar.

Your second piece of code is missing the title that's in the first code, so that's the first thing to try adding if one works and the other doesn't.

Thank you for your help leo :slight_smile:

I know my code is ugly, but it is my way to learn how things work :slight_smile:

So i made this code :

chemin = DOpus.Vars("chemin1") Set dlg = DOpus.Dlg dlg.title = "Chemin" dlg.message = chemin Go "C:\" NEWTAB

The last line (Go etc...) is never executed, is it normal ??

oh and after i will understand why my ugly code doesnt work, i will use aliases ! :slight_smile:

That last line is an Opus command, not VBScript code. To run an Opus command from VBScript, you need to use a Command object. One is provided with most of the needed data pre-populated in most cases, e.g. as part of the object passed to your script's main function if it is a button script.

Thanks again for your help Leo, my "school buttons" work now, i learnt a lot thanks to them.
I made my "serious buttons" with aliases, it was easy and the best way as you said.

Now i wonder, is it possible to modify a button label using scrpits ? (as label fileds don't accept neither variables nor aliases).

Sorry for double posting, but i want to precise my question :

Is it possible to modify a button label using scrpits ? (as label fileds don't accept neither variables nor aliases)
or build a new button with a script ?

Thank you :slight_smile:

Not currently, but it's something we're thinking about.

It would give so much liberty, even for a beginner like me...
Thanks for all your help and patience leo.