Jump to content
Macro Express Forums

Using multiple variables in one command


Recommended Posts

I'm trying to create a .txt file of multiple random geographic points within a specific boundary. Line 13 is where I'm losing my hair. A test run of the macro returns "Undefined variable or the variable is the wrong type" for line 13, where I'm trying to write both strings to the text file at the same time, separated by a comma.

 

The maddening thing is that the output is EXACTLY what I want! It is writing both variables to the file precisely the way they need to be, but MEPro always returns the debug error! This is, of course, in debug mode; actually running the macro returns the same error within a popup in the first iteration, and will not repeat for the other 99 iterations.

 

I know one workaround would be to append the comma to %Latitude%, then append %Longitude%, then write to the .txt file—that's the way I've been doing it in ME3 for years now—but I'm getting the desired result in the .txt file without that multi-step append. [Do two wrongs make it write? <_< ]

 

Is there special syntax for passing multiple variables in one command? Is it allowed?

 

<VARIABLE SET STRING Option="\x00" Destination="Latitude" Value="40."/>
<VARIABLE SET STRING Option="\x00" Destination="Longitude" Value="-105."/>
<REPEAT START Start="1" Step="1" Count="100" Save="FALSE"/>
<VARIABLE SET INTEGER Option="\x05" Destination="LatSeconds" Minimum="24392" Maximum="280865"/>
<VARIABLE SET INTEGER Option="\x05" Destination="LongSeconds" Minimum="334239" Maximum="575685"/>
<IF VARIABLE Variable="%LatSeconds%" Condition="\x02" Value="100000" IgnoreCase="FALSE" _COMMENT="If value is five digits..."/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%Latitude%" Value="0" _COMMENT="...make six digits."/>
<END IF/>
<VARIABLE MODIFY INTEGER Option="\x04" Destination="%LatSeconds%" Variable="%Lat_seconds%"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%Latitude%" Variable="%Lat_seconds%"/>
<VARIABLE MODIFY INTEGER Option="\x04" Destination="%LongSeconds%" Variable="%Long_seconds%"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%Longitude%" Variable="%Long_seconds%"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%Latitude%,%Longitude%" Filename="C:\\INI\\Coordinates.txt" CRLF="TRUE"/>
<END REPEAT/>

Link to comment
Share on other sites

  • 3 weeks later...

I'm going to answer my own post [gauche as that is], since I just had one of those "Duh!" moments. It may help someone else eventually...

 

I discovered you can parse any number of variables through one command. If MEP balks at the command, there's a tab on the 'Variable Modify' window: "On Error". On that tab, there's an "Undefined variable or the variable is the wrong type" field. This can be toggled to Ignore Error, and, BAM, there's the output I wanted without the annoying errors halting the macro. So now I can append twenty variables using only one Modify String command, if need be, rather than using 19 commands, one after the other.

 

[Note that integer variables were appended to the string without converting the integers to strings beforehand! Another undocumented feature, and one I'm sure Insight will not support...]

 

<VARIABLE SET STRING Option="\x00" Destination="Latitude" Value="40"/>
<VARIABLE SET STRING Option="\x00" Destination="Longitude" Value="-105"/>
<REPEAT START Start="1" Step="1" Count="100" Save="FALSE"/>
<VARIABLE SET INTEGER Option="\x05" Destination="LatSeconds" Minimum="24392" Maximum="280865"/>
<VARIABLE SET INTEGER Option="\x05" Destination="LongSeconds" Minimum="334239" Maximum="575685"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%Latitude%.%LatSeconds%,%Longitude%.%LongSeconds%" Filename="C:\\INI\\test.txt" CRLF="TRUE" _IGNORE="0x0003"/>
<END REPEAT/>

 

My script went from 14 lines to 7. Just ignore the error and keep chugging. Nice override, Insight!

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...
×
×
  • Create New...