Jump to content
Macro Express Forums

Strange non-computing decimal variable?


Recommended Posts

I an trying to use the modify decimal command to subtract one decimal variable from another. But I get odd results.

 

 

Top level macro A contains sub-macro B that populates a decimal variable %DTV% (A decimal time value)

 

Further on in A sub-macro C is called and it in turn has sub-macro D. D uses %DTV% and subtracts another decimal (Called from the registry and parked in %TEMP_REG[%n%]%). The result is placed in %TEMP_DONE[%n%]%. n is incremented and a loop populates n=1 to n=4

 

Problem is the subtraction gives a strange result: it isn't happening and the result is negative and off by many thousands. What should be 10.789etc. is -40644.789etc.

 

I check A, B, C and D and check that %DTV% is being correctly declared, populated and it is in each macro (Using the debugger).

 

I check %TEMP_REG[%n%]% to make sure it is being populated from the registry correctly and it is.

 

If put macro B (that populates %DTV% in the first place) at the top of macro D so I am creating %DTV% right fresh on the spot then everything works perfectly. Yet the debugger shows the same values for %DTV% and %TEMP_REG[%n%]% no matter how I play it. Only the results in %TEMP_DONE[%n%]% are screwy.

 

 

<VARIABLE MODIFY DECIMAL Option="\x01" Destination="%TEMP_DONE[%n%]%" Value1="%DTV%" Value2="%TEMP_REG[%n%]%"/>

 

 

If there is a nesting limit of some sort the debugger isn't showing it---a problem with the calculations?

Link to comment
Share on other sites

As a side note, I tried a Variable restore in D to maybe freshen up %DTV% and it didn't work.

 

 

I tried passing %DTV% from Macro B (where it was populated) to Macro D (where it is used) via a registry write/read and that does seem to work....at the cost of the write read move and an extra registry entry.

 

Value of %DTV% in the debugger still looks the same either way but the computation works with the 'fresh' %DTV%

Link to comment
Share on other sites

If I understand you correctly, then you have this calling hierarchy of macros:

Macro A

-- Macro B

-- Macro C

---- Macro D

 

I assume that a decimal variable %DTV% is declared in each macro, and that when one macro calls another, it always waits for the called macro to finish.

 

I have created the following code, and it works as expected. In other words, the two display boxes of the value of %dtv% in both macros D and A show the same value of 0.5.

 

My guess is that you may not have declared %dtv% in Macro A when you first tested your code, in which case it may be that MEP has got confused (MEP gets quite easily confused about variables if they're not declared right the first time). If I'm right, I suggest recreating the 4 macros, making sure you declare the relevant shared variables right the first time (you can easily copy the code from your existing macros to the new ones).

MacroA
------
Macro Run: MacroB
Macro Run: MacroC
Text Box Display: MacroA

MacroB
------
Variable Set Decimal dtv to 1.05

MacroC
------
Macro Run: MacroD

MacroD
------
Variable Modify Decimal: %dtv% = %dtv% - .55
Text Box Display: MacroD

MacroA
------
<MACRO RUN Use_ID="FALSE" Name="MacroB" ID="-1" Wait="TRUE"/>
<MACRO RUN Use_ID="FALSE" Name="MacroC" ID="-1" Wait="TRUE"/>
<TEXT BOX DISPLAY Title="MacroA" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 dtv = %dtv%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

MacroB
------
<VARIABLE SET DECIMAL Option="\x00" Destination="dtv" Value="1.05"/>

MacroC
------
<MACRO RUN Use_ID="FALSE" Name="MacroD" ID="-1" Wait="TRUE"/>

MacroD
------
<VARIABLE MODIFY DECIMAL Option="\x01" Destination="%dtv%" Value1="%dtv%" Value2=".55"/>
<TEXT BOX DISPLAY Title="MacroD" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 dtv = %dtv%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Link to comment
Share on other sites

  • 2 weeks later...

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...
 Share

×
×
  • Create New...