Jump to content
Macro Express Forums

Trouble with Modify String


Recommended Posts

Next... I am working on a complicated macro, that’s basically parsing text strings in many different ways.

 

One procedure became too complicated in the main macro. So I first constructed it in a macro by itself, and I finally got everything to work in that. It proceeded by my "hard-wiring" a string variable.

 

Then I proceeded testing the new procedure by calling the new macro from my main macro, passing the same string variable to my new macro from the main macro, the one I had hard-wired for constructing the sub macro.

 

One crucial part of the sub-macro is a "Variable Modify String" command whereby part of the text is deleted, from Starting Position 2, up to 99 characters in length.

 

This works perfectly in the sub-macro, if I run it by itself with the hard-wired text string to begin with. But when I comment out the hard-wired text string, and instead pass the identical string variable from the main macro to the sub-macro, the process fails. I cannot figure out why.

 

I’ve checked to see what the length of the text string is that Macro Express thinks it is, before the text deletion. When run by itself, the sub-macro returns "1". But when called by the main macro, the sub-macro then returns "2," even though the string is only one character long.

 

I’m not posting anything here script-wise yet, as the whole thing is very convoluted. Just out of curiosity, though: are there some pitfalls I need to consider? I have analyzed and re-analyzed this, and I cannot see why calling the sub macro from the main macro should cause this problem.

 

ADDENDUM: as a desperation move, I just inserted at "trim" modification on the offending text string (the fact that the string length reported being 2 characters long, though only one was visible, led me to investigate). This has now fixed the problem. The remaining mystery, however, is why that string has an added space character, when called from the main macro, but not when called within the sub-macro itself.

 

I just don’t have the energy to troubleshoot this further... but if someone has an idea of the pitfalls, I’d like to hear it.

 

Otherwise... just ignore this post. Cheers!

Link to comment
Share on other sites

Yes. When you defined the variable there's a box which controls scope. "Make this variable available to macros called by this macro".

If that doesn't fix it. I'd suggest creating a simple demonstration macro and post it here for us to look at. 

Link to comment
Share on other sites

8 minutes ago, Cory said:

Yes. When you defined the variable there's a box which controls scope. "Make this variable available to macros called by this macro".

If that doesn't fix it. I'd suggest creating a simple demonstration macro and post it here for us to look at. 

 

Yes, that option is checked.

 

Cory, I don’t want to waste your time... I suspect there is a logical flaw in my script(s). For now, it appears that my "trim" command, though a klutz, has fixed this particular problem.

 

Thank you, as always.

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