Jump to content
Macro Express Forums

Radio Buttons


Recommended Posts

Suppose the variable you're going to save your result into is called %tChoice%, and that you're going to save the text, not the value. Then simply set %tChoice% to any valid response before you display the menu, and you'll find it becomes the default choice. E.g.

Variable Set String %tChoice% to "Two"
Multiple Choice Menu: My Title
Text Box Display: %tChoice% 

<VARIABLE SET STRING Option="\x00" Destination="%tChoice%" Value="Two"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x01" Dest="%tChoice%" Title="My Title" Prompt="Select one choice" Options="One\r\nTwo\r\nThree" Left="Center" Top="Center" Monitor="0" Width="443" Height="296" OnTop="FALSE"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 My choice was %tChoice%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Link to comment
Share on other sites

Hi Paul, actually that's what I tried to do originally but it didn't "take." I set a default value with "set string variable" in the Script window. I've just double checked and tried again, but no cigar.

 

Before pursuing this, it would help if you could answer a dumb question from me. You're posting examples of actual code. Where do you access that? So far, I've built my macros entirely using the "building blocks" provided by the Script Editor. It would actually help a lot if I could look at the code itself, and thereby figure out what I'm doing that's different from you.

 

Thank you very much for your help.

Link to comment
Share on other sites

Hi Paul, actually that's what I tried to do originally but it didn't "take." I set a default value with "set string variable" in the Script window. I've just double checked and tried again, but no cigar.

 

Before pursuing this, it would help if you could answer a dumb question from me. You're posting examples of actual code. Where do you access that? So far, I've built my macros entirely using the "building blocks" provided by the Script Editor. It would actually help a lot if I could look at the code itself, and thereby figure out what I'm doing that's different from you.

 

I almost never access "actual code"! If you want to do that, simply click on the Direct editor icon. All I do is compose my macro, then select the code and Copy It (this shows the XML view of the code). You can also copy the command text by right-clicking (which gives you that first view of the code in my reply to you).

 

And check the variables tab to see what your variable type is. BTW, wherever possible (which is almost always), I always include the initial and final % when referencing variables.

Link to comment
Share on other sites

Paul and Terry,

 

Thanks. Looking at my code, I had originally tried to do exactly what Paul suggests (or at least I think so). Here's the code:

 

<VARIABLE SET STRING Option="\x00" Destination="%NaturalOffset%" Value="0.10"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x00" Dest="%T[1]%" Title="Shift Accidental - Specify Offset" Prompt="Choose an offset in the list below. \r\n\r\nSibelius is quite \"granular\" and will not place accidentals in fine increments.\r\nThis is also related to the staff size. Smaller staves yield smaller offset values.\r\n\r\nClick OK to process the file.\r\n" Options="0.10%T[1]%\r\n0.15%T[1]%\r\n0.20%T[1]%\r\n0.25%T[1]%\r\n0.30%T[1]%\r\n0.35%T[1]%\r\n0.40%T[1]%\r\n0.45%T[1]%\r\n0.50%T[1]%\r\n0.55%T[1]%\r\n0.60%T[1]%\r\n0.65%T[1]%\r\n0.70%T[1]%\r\n0.75%T[1]%\r\n0.80%T[1]%\r\n0.85%T[1]%\r\n0.90%T[1]%\r\n0.95%T[1]%\r\n" Left="Center" Top="Center" Monitor="0" Width="553" Height="330" OnTop="TRUE"/>
<IF VARIABLE Variable="%T[1]%" Condition="\x00" Value="A" IgnoreCase="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%NaturalOffset%" Value="0.10"/>
<END IF/>
<IF VARIABLE Variable="%T[1]%" Condition="\x00" Value="B" IgnoreCase="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%NaturalOffset%" Value="0.15"/>
<END IF/>

 

And so on.

 

But I'm still not getting the default choice of "0.10" radio button so what gives?

Link to comment
Share on other sites

Your code in no way resembles mine!

- You haven't changed the Output Results of the Multiple Menu command to Item Text

- Your output variable is T1, and you have failed to preset its value

- For some reason best known to yourself, you append T1 to every permitted Multiple Menu choice

- Your variable NaturalOffset is not being used at all in the Multiple Menu command

Link to comment
Share on other sites

It seems to me that your macro differs in at least two respects:

 

MEPro-Martin-1.jpg

 

And I don't see the purpose of your remaining script?

 

I'd have started like this:

 

Variable Set String %NaturalOffset% to "0.10"

Multiple Choice Menu: Shift Accidental - Specify Offset

// Now continue the macro based on your choice.

Text Box Display: Your choice

 

<VARIABLE SET STRING Option="\x00" Destination="%NaturalOffset%" Value="0.10"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x01" Dest="%NaturalOffset%" Title="Shift Accidental - Specify Offset" Prompt="Choose an offset in the list below. \r\n\r\nSibelius is quite \"granular\" and will not place accidentals in fine increments.\r\nThis is also related to the staff size. Smaller staves yield smaller offset values.\r\n\r\nClick OK to process the file.\r\n" Options="0.10%\r\n0.15%\r\n0.20%\r\n0.25%\r\n0.30%\r\n0.35%\r\n0.40%\r\n0.45%\r\n0.50%\r\n0.55%\r\n0.60%\r\n0.65%\r\n0.70%\r\n0.75%\r\n0.80%\r\n0.85%\r\n0.90%\r\n0.95%\r\n" Left="Center" Top="Center" Monitor="0" Width="553" Height="330" OnTop="TRUE"/>
<COMMENT Value="Now continue the macro based on your choice."/>
<TEXT BOX DISPLAY Title="Your choice" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 NaturalOffset\\f1  chosen = \\f0 %NaturalOffset%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

 

Edit: I see Paul responded while I was trying to figure it out!

12 October 2010, 12:19 UK time

 

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Your code in no way resembles mine!

- You haven't changed the Output Results of the Multiple Menu command to Item Text

- Your output variable is T1, and you have failed to preset its value

- For some reason best known to yourself, you append T1 to every permitted Multiple Menu choice

- Your variable NaturalOffset is not being used at all in the Multiple Menu command

Link to comment
Share on other sites

Thank you Paul and Terry. As I said, I am still very new with this software (and rusty at programming). I very much appreciate your help and I am sure it will work when I follow your advice, take out the gunk, and type/specify my variable properly. In this case part of the mess was caused by trying to follow an example in the Help system too rigidly.

Link to comment
Share on other sites

On further research:

 

>>You haven't changed the Output Results of the Multiple Menu command to Item Text.<<

 

As I said, I followed (too slavishly I suspect) the advice given in the Help. Here is their sample example:

 

Multiple Choice Menu: Prompt
If Variable %T[1]% Equals A
Web Site, "http://www.macros.com", using Default Web Browser
End If
If Variable %T[1]% Equals B
etc.....

 

From this I assumed that the menu choices should be parsed into an array of the general form T[].

 

>>Your output variable is T1, and you have failed to preset its value.<<

 

Yes that was the key mistake I made. Instead of presetting the default menu choice (T[1] = A) I preset the output variable itself (%NaturalOffset%). Fixed.

 

>>For some reason best known to yourself, you append T1 to every permitted Multiple Menu choice.<<

 

Fixed.

 

>>Your variable NaturalOffset is not being used at all in the Multiple Menu command.<<

 

Well, it sets Natural Offset according to the returned value of T[] and that was already working fine. It looks like I could have simplified the whole thing greatly if I'd passed the variable "By Item Text" instead of "By Value" and not used an array variable. Or maybe I still don't understand. Anyway, it's working fine now.

 

You and Terry are right that a lot of cobwebs need to be cleared out of my programming, which I am taking up again after a 15-year break. It's a lot of fun, and I really appreciate your help.

Link to comment
Share on other sites

>>You've gained far more by doing it yourself than having us send you a completed script, don't you think?<<

 

Absolutely. It is all gradually coming back to me. I am starting a new thread relating to a structural question, or rather a pair of questions (variables and macros that call other macros). I hope people don't feel I'm being too chatty by starting so many threads, but all sorts of different issues are coming up and I don't want to mix apples and oranges. Thanks again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...