MartinMarris Posted October 10, 2010 Report Share Posted October 10, 2010 When creating a menu with radio buttons, how do I force selection of the default choice (often, the first button in the list)? All the ones I've created so far consist of a series of buttons with none of them selected until you click with the mouse. Apart from anything else is unusual from a Windows API point of view. Quote Link to comment Share on other sites More sharing options...
paul Posted October 10, 2010 Report Share Posted October 10, 2010 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"/> Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 10, 2010 Author Report Share Posted October 10, 2010 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. Quote Link to comment Share on other sites More sharing options...
paul Posted October 10, 2010 Report Share Posted October 10, 2010 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. Quote Link to comment Share on other sites More sharing options...
terrypin Posted October 11, 2010 Report Share Posted October 11, 2010 ... You're posting examples of actual code. Where do you access that? Hi Martin, and welcome to the forum. In case you didn't locate the Direct editor icon to which Paul referred, here it is: -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 12, 2010 Author Report Share Posted October 12, 2010 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? Quote Link to comment Share on other sites More sharing options...
paul Posted October 12, 2010 Report Share Posted October 12, 2010 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 Quote Link to comment Share on other sites More sharing options...
terrypin Posted October 12, 2010 Report Share Posted October 12, 2010 It seems to me that your macro differs in at least two respects: 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 Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 12, 2010 Author Report Share Posted October 12, 2010 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 Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 12, 2010 Author Report Share Posted October 12, 2010 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. Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 15, 2010 Author Report Share Posted October 15, 2010 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. Quote Link to comment Share on other sites More sharing options...
paul Posted October 15, 2010 Report Share Posted October 15, 2010 Well done for putting the effort in and having success. You've gained far more by doing it yourself than having us send you a completed script, don't you think? Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 15, 2010 Author Report Share Posted October 15, 2010 >>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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.