Macro cuts off char

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bjorn82dk
Newbie
Posts: 13
Joined: Sat Jun 23, 2012 10:41 am
Location: Copgenhagen, Denmark

Macro cuts off char

Post by bjorn82dk » Tue Aug 30, 2022 7:39 am

Hi all,
I have a macro that is misbehaving and I hope some of you can provide some insight.

Overall:
I have this macro that copies a text string and split the text string into multiple variables.

Some of the content is:
%BWID% - 6 digit ID (example 123456)
%BWM2% - Size in m2
%BWBUILD% - Build year


First issue:
When I try to do:
Send>http://mywebsite.com/property/%BWID%/details

The result is: http://mywebsite.com/property/%BWID%/details
Where its supposed to be: http://mywebsite.com/property/123456/details

If I do:
Send>http://mywebsite.com/property/
Wait>0.5
Send>%BWID%
Wait>0.5
Send>/details

All works as its supposed to. So why am I unable to do the full string?

Second issue.

When I try to use
%BWM2% - Size in m2 (Example 130)
%BWBUILD% - Build year (Example 1988)

And I test the values after they are captured all is good.
I try and test the variables with "MessageModal" on serveral places and it contains the right data.

However, when I reach the end of my macro and I want to populate the data to a webform like:

Send>%BWM2%
Send>%BWBUILD%

I has cut of some of the data so:
%BWM2% becomes 13
%BWBUILD% becomes 198

But when testing with MessageModal just prior to placing the data in the form the full data is available.

Any help here would be much appreciated.

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Macro cuts off char

Post by hagchr » Tue Aug 30, 2022 8:31 am

Hi! Looks strange... You could try to send the text to Notepad to check if that gives the same result. Also make sure the variables are defined correctly. For example, the first (incorrect) version below would give the (first) problem you encounter:

Let>%BWID%=123456
Let>BWID=123456

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Macro cuts off char

Post by Dorian (MJT support) » Tue Aug 30, 2022 9:01 am

I think hagchr is right on the money regarding the first issue. If you try it in Notepad you'll see it behaves exactly as he describes.

With regards to the second issue - If they look correct just prior to posting, but post incorrectly, I wonder if there are some control characters in there somewhere? What happens if you use Trim?

Code: Select all

Trim>%BWM2%
Trim>%BWBUILD%
Just out of interest, I'd try running it step by step and copying the variable and value from the watch list (right-click on the watchlist line, "copy Line") then pasting somewhere to see what it looks like.
Yes, we have a Custom Scripting Service. Message me or go here

bjorn82dk
Newbie
Posts: 13
Joined: Sat Jun 23, 2012 10:41 am
Location: Copgenhagen, Denmark

Re: Macro cuts off char

Post by bjorn82dk » Tue Aug 30, 2022 9:33 am

All, thanks for your feedback.

So to try and troubleshoot the issue I did:

Code: Select all

Wait>1
Let>%Test%=123456
Wait>0.5
Let>%Test2%=My text followed by %Test%
Wait>0.5
MessageModal>%Test2%
And the expected result would be:
My text followed by 123456

But the result is:
My text followed by %Test2%

bjorn82dk
Newbie
Posts: 13
Joined: Sat Jun 23, 2012 10:41 am
Location: Copgenhagen, Denmark

Re: Macro cuts off char

Post by bjorn82dk » Tue Aug 30, 2022 9:36 am

But this is working:

Wait>1
Let>Test=123456
Wait>0.5
Let>Test2=My text followed by %Test%
Wait>0.5
MessageModal>Test2

So I might overdue the % that when I'm using variables.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Macro cuts off char

Post by Dorian (MJT support) » Tue Aug 30, 2022 9:51 am

The when to use the percent symbol article may help you.

Mis-use can cause havoc! We've all done it at some point, and it can cause a lot of head scratching when looking for it. The following snippet shows how we can turn 1 into 3 by mis-use of the %

Code: Select all

//Let's start with this...
let>a=1

//Then later in the script we erroneousely use the %
let>%a%=3

//We've actually turned 1 into 3.
mdl>1
mdl>we turned 1 into %1%

Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Macro cuts off char

Post by Dorian (MJT support) » Tue Aug 30, 2022 9:53 am

I couldn't resist :D

Code: Select all

//Let's start with this...
let>pet=dog

//Then later in the script we erroneousely use the %
let>%pet%=cat

//We've actually turned dog into cat.
mdl>dog
mdl>we turned dog into %dog%
Yes, we have a Custom Scripting Service. Message me or go here

bjorn82dk
Newbie
Posts: 13
Joined: Sat Jun 23, 2012 10:41 am
Location: Copgenhagen, Denmark

Re: Macro cuts off char

Post by bjorn82dk » Wed Aug 31, 2022 9:05 pm

All,
Thank you so much for all your help. I removed the % in all non needed places and now everything is running smoothly.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Macro cuts off char

Post by Dorian (MJT support) » Wed Aug 31, 2022 10:09 pm

You're very welcome. That's great to hear!
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts