Jump to content
Macro Express Forums

Array variable

Recommended Posts

When you are editing the macro, click on the Variables tab, and at lower left there are options to add/delete/change variables.


The Macro Express Help example for Text File Process shows an array variable, which is confusing, because it does not HAVE to be an array variable.  It does not much matter whether you give it any content when you define it, because it will be overlaid with file data when the process runs. 


If you want the fields within each record to be placed in an array, look at ASCII File Process instead of Text File Process. 

Link to comment
Share on other sites

If I open the Variables tab and "add" the variable there is an error "A variable with this name already exists". But if I run the macro there is an error "Undefined variable or the variable is the wrong type". As the variable exists (?) it must be the wrong type. If it should not be a string variable (for an array of strings) what type should it be? Or does it matter in what order I write the macro? In Basic or Python one can edit code freely before running it. Perhaps this is not so in Macro Express Pro.

Link to comment
Share on other sites

It's a personal preference, but I use the ME option that does NOT automatically define variables. 

If you set that ME option, you should be able to delete the current variable, and then when you try to save the macro, it will prompt you through defining the variable.

For Text File Process, it should be a Text variable.  If you currently have a text array, possibly ME objects to that and wants a single text variable -- not sure, I haven't tried that. 

Link to comment
Share on other sites

I have written a test macro which I attach here. The file being worked on is a simple text file of short lines and the intention is to display each line in a message box. However, at "Text File Begin Process" the above-mentioned error message occurs, "Undefined variable or the variable is the wrong type". This is despite "images" being set as a string variable of an array type. If there is an order in which I should set the macro up, what is it? If I need to edit it for debugging, how do I do that, or do I have to rewrite the macro from scratch for every bug? Does the error have something to do with the arrangement of percentage signs on the variable name?


Link to comment
Share on other sites

3 hours ago, jsampsonyyyyy said:

This is despite "images" being set as a string variable of an array type.


"images" should not be an array type. 


This macro (below) runs properly if %testvar% is defined as a text variable, not as an array.

If %testvar% is defined as a text array, I get the same error you describe.


Text File Begin Process: C:\Temp\windowlist.txt  (specifies "testvar" to receive lines from the file)
  Text Type (Simulate Keystrokes): %testvar%
Text File End Process
Macro Return


In the macro editor, select the Variables tab, select Properties for your variable, and un-check the "Create as array" box.  See attached screen shot.



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.

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.

  • Create New...