Jump to content
Macro Express Forums

MartinMarris

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by MartinMarris

  1. >>Try these 2 scripts - they work as I expected.<< I took your two scripts, created a new macro for each of them, with the macro names xx1 and xx2, and put them in the same Category in the editor. When I run xx1, I get this: Undefined variable or the variable is of the wrong type %nVar1% Macro Name xx2 Line Number 4 Not sure what I'm getting wrong ... it did ask me several times to define my variables when I tried to save xx2 in the first place (after saving xx1 first). This is precisely what I've been struggling with: I don't seem to be able to get the child macros to work properly unless I re-define the variables that were already defined in the main routine. >>I don't follow. You can have nested Repeat loops without any problems. What am I missing?<< I'm sure I'm just making another elementary blunder in logic or in the order of operations, but here is an example of something that triggers an infinite loop. The examples in my own code are more complex, so I've stripped it down to a bare example: <VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/> <VARIABLE SET INTEGER Option="\x00" Destination="%y%" Value="1"/> <REPEAT UNTIL Variable="%x%" Condition="\x00" Value="5"/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%x%" Value1="%x%" Value2="1"/> <REPEAT UNTIL Variable="%y%" Condition="\x00" Value="10"/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%y%" Value1="%y%" Value2="1"/> <END REPEAT/> <END REPEAT/> Thanks again.
  2. When I create the more complex macros in MacExPro, I make one "main" macro that then calls a series of smaller macros to accomplish a series of tasks. However this also seems to result in problems with variables. Even if you declare and type all your variables at the start of the "main" macro, the "child" macros know nothing about those variables (even if they have been explicitly typed as Global) so you have to declare them all over again in each macro that will use the variable, and try to avoid typos in the process! Helpfully, MacExPro does warn you if you forget to do this. But am I right that there is no way to get around this? More generally, do the more experienced users on this forum agree that building a "modular" sequence of macros is the right way to go when addressing complex processes? Am I creating problems for myself by doing so? When I tried to stuff everything into a single macro, I was having quite a lot of trouble and in particular, it seemed that you cannot nest one "return" loop inside another. That seems rather unusual compared to other languages. Or perhaps I was doing something wrong. Thanks.
  3. >>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.
  4. 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.
  5. 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.
  6. 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?
  7. Hi again Paul, Judging from their website, AutoIt is very interesting, especially as an alternative to Macro Pro for additional data handling, conditional branching and user menu complexity. I was actually beginning to lean toward returning to VB (which I haven't coded in several years) but now I will check it out AutoIt first. Thanks for the advice!
  8. Thanks, I'll now be more careful in declaring variable types (I have gotten rather used to software that defines them on the fly if needed).
  9. 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.
  10. Am I right that there is no way to create a data entry field into which you could type information that would be fed to the program? Neither are there any formatting or validation options for such fields? So far I've resorted to using multiple-choice menus, but this forces you to provide what can turn out to be a vast array of choices. For instance, one of my macros asks the user to enter a value between 0.10 and 0.95, in increments of .05 units, which yields a column of nearly 20 radio buttons. It would be more elegant to provide a data entry field with up/down arrows, with formatting and validation to prevent out of bounds data entry by the user. I actually wanted to allow a choice in increments of 0.01 but couldn't face creating more than 80 radio buttons. I am a recent adopter of Macro Pro and find it extremely impressive apart from what appear to be very limited menu creation options, compared to VB and VBA which I am quite familiar with. (Admittedly that is an unfair comparison.)
  11. 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.
  12. When doing Create Dialog -> Message Box, if I try to insert a variable into the Message field I get this error message: "The variable, "%s," is the wrong type." Please use a variable of the following type: Please correct." It happens regardless of the type of variable (Text, Integer, whatever) and there is never any advice after the colon. Seems to happen only with the Message Box created via the Dialog menu. Doesn't happen with the "If Message" method in the Logic menu, or with any of the other situations where you can enter a variable (unless, of course, you actually do use an inappropriate variable type). Am actually thinking it might be a genuine bug. Suggestions?
×
×
  • Create New...