MartinMarris Posted October 10, 2010 Report Share Posted October 10, 2010 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? Quote Link to comment Share on other sites More sharing options...
paul Posted October 10, 2010 Report Share Posted October 10, 2010 No, it's not a bug. This happens when the first mention of the variable in the script (i.e. the reference that causes the variable to be created) is such that MEP is unable to determine what kind of variable it is. For example, if the 1st reference to variable %myvar% is Variable Set String %myvar% to topmost window title then %myvar% will be created as a text variable. But if instead you say Text Box Display --%myvar% then %myvar% could be any type of variable, so MEP creates it as a text variable, which may, or may not, be correct. You can always change the type of any variable by editing its definition in the Variables tab. Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 10, 2010 Author Report Share Posted October 10, 2010 No, it's not a bug. This happens when the first mention of the variable in the script (i.e. the reference that causes the variable to be created) is such that MEP is unable to determine what kind of variable it is. For example, if the 1st reference to variable %myvar% is Variable Set String %myvar% to topmost window title then %myvar% will be created as a text variable. But if instead you say Text Box Display --%myvar% then %myvar% could be any type of variable, so MEP creates it as a text variable, which may, or may not, be correct. You can always change the type of any variable by editing its definition in the Variables tab. Quote Link to comment Share on other sites More sharing options...
MartinMarris Posted October 10, 2010 Author Report Share Posted October 10, 2010 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). Quote Link to comment Share on other sites More sharing options...
paul Posted October 10, 2010 Report Share Posted October 10, 2010 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). Actually, for "real" languages, i.e. compiled ones, allowing the language to define your variables is not considered good practice. One reason is efficiency, because the default type for undeclared variables is usually the least efficient, e.g. Variant. Another is debugging: if you require all variables to be predefined, then this code Dim Cabbage as String Dim i as Integer Cabage = "Some text" i = Len(Cabbage) will throw an error (as it should), whereas the other approach will cause you problems at run-time which may not be easy to find! Quote Link to comment Share on other sites More sharing options...
chris Posted October 19, 2010 Report Share Posted October 19, 2010 Thanks for clarifying that, Paul. That was one of the design decisions we had to make when developing the new variable system. In the end, we decided to use strongly-typed variables in order to maintain efficiency (variants are actually very much discouraged by Microsoft, even though they do allow them). Now, as for the variable creation, if you allow MEPro to prompt you for each variable, you will be given a selection of allowed variable types for each variable. It's not always going to default to text variables (for instance, in a "Variable Set Integer" command, the text variable option will not even be available). But, when using the automatic creation MEPro has to make a guess as to what type of variable you were wanting. In the case where the "TextBox Display" command is used, all variable types are supported, so we default to the text variable type as it's the most often used type of variable in that command. We are currently looking into ways to make the automatic variable creation a little more friendly. 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.