Adding Variables Incorrectly?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Adding Variables Incorrectly?

Post by RNIB » Fri May 06, 2016 2:49 pm

I'm not sure what the problem is here so I'll just do my best to explain what is happening.

Earlier in the script the macro moves to a field in a program that should contain either the letter r or s copies it to the clipboard, stores it as a variable (side1R, side1S, side2R, side2S respectively) and then assigns the value of 1 if the letter is there or 0 if it isn't.

Code: Select all

SRT>2PartCheck
If>side1R=r
Let>side1Rcheck=1
Else
Let>side1Rcheck=0
EndIF
If>side1=s
Let>side1Scheck=1
Else
Let>side1Scheck=0
EndIF
If>side2R=r
Let>side2Rcheck=1
Else
Let>side2Rcheck=0
EndIF
If>side2S=s
Let>side2Scheck=1
Else
Let>sideScheck=0
EndIf
End>2PartCheck

This is the end of a pretty long macro

Code: Select all

Srt>2PartReport
//SIDE 1
If>side1Rcheck+side1Scheck=2
Let>Side1Report=Side 1 is correct and can be submitted to the Newsagent portal.
Else
If>side1Rcheck+side1Scheck=0
Let>Side1Report=Side 1 is missing both the S & R markers. This needs to be fixed before it can be submitted.
Else
If>side1Scheck=0
Let>Side1Report=Side 1 is missing the S marker. This needs to be fixed before it can be submitted.
Else
Let>Side1Report=Side 1 is missing the R market. This needs to be fixed before it can be submitted.
Endif
endif
endif
//SIDE 2
If>side2Rcheck+side2Scheck=2
Let>Side2Report=Side 2 is correct and can be submitted to the Newsagent portal.
Else
If>side2Rcheck+side2Scheck=0
Let>Side2Report=Side 2 is missing both the S & R markers. This needs to be fixed before it can be submitted.
Else
If>side2Scheck=0
Let>Side2Report=Side 2 is missing the S marker. This needs to be fixed before it can be submitted.
Else
Let>Side2Report=Side 2 is missing the R market. This needs to be fixed before it can be submitted.
Endif
endif
endif
Message>%Side1Report%, %Side2Report%
end>2PartReport
So, what I mean to happen here but doesn't seem to be working, is that if Side 1 contains the letters R & S adding the variables side1Rcheck & side1Scheck together should have a total of 2. If neither of those letters are there the total should be 0. If the total is 1 then it looks to see which letter was missing i.e. which of the two variables has a value of 0.

So as a test I ran two files through it. Side 1 was missing both R & S and Side 2 had both R&S in place. The message that came up was:
Side 1 is missing the S marker. This needs to be fixed before it can be submitted., Side 2 is missing the R market. This needs to be fixed before it can be submitted.
So in both cases it seems to think the total is 1 instead of 2 0 as it should be.

Obviously I'm doing something wrong but I've no idea where the error is.

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

Re: Adding Variables Incorrectly?

Post by hagchr » Fri May 06, 2016 3:50 pm

Hi,

I have not had to chance to look at it in detail but note that in the first SRT, toward the end you use sideScheck instead of side2Scheck. In the second SRT I think you need to use % around the variables to ensure they get resolved correctly. Use the debugger / step through using F8, then you can see if the variables are ok or not.

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Adding Variables Incorrectly?

Post by RNIB » Fri May 06, 2016 3:54 pm

hagchr wrote:Hi,

I have not had to chance to look at it in detail but note that in the first SRT, toward the end you use sideScheck instead of side2Scheck. In the second SRT I think you need to use % around the variables to ensure they get resolved correctly. Use the debugger / step through using F8, then you can see if the variables are ok or not.
:oops: :oops: :oops:

Oh damn. I got myself all mixed up at one point writing that and thought I had corrected all the mistakes and went through it all 3 times. Obviously I didn't look closely enough :oops: :oops:

lol

I'll put some coffee on and have another look :wink:

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

Re: Adding Variables Incorrectly?

Post by hagchr » Fri May 06, 2016 4:04 pm

Coffee is always good... One more thing, you may need to split it up or use {} to get it to work, eg

Code: Select all

Let>side1Rcheck=1
Let>side1Scheck=1

Let>check=%side1Rcheck%+%side1Scheck%
If>check=2
    MDL>ok
Endif

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