cancel
Showing results for 
Search instead for 
Did you mean: 

IF statement not working; sounds unlikely I know but ....

Former Member
0 Kudos

As always - any feedback welcome ...

Regards.

Patrick.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You need to say IF args.error_code - don't forget the "args." part!

Steve.

Former Member
0 Kudos

Ahhhhh... what a relief .... I've been going around that circle for about an hour ... thanks a lot Steve .... I can now walk towards the weekend in a trouble free state of mind

Curios that you can write out variables without reference to the 'args' but must test them with?

Anyway - once again many thanks.

I notice once again I can't mark this a 'correct' - I must be raising these threads the wrong way or something, some I can say correct to and others not?

All the best.

Patrick.

PS. Have a good weekend.

Former Member
0 Kudos

It is an artefact of the Javascript going on behind the scenes. "args." is how you refer in Javascript actions to variables created in regular script actions. This all gets cleaner in V3...:-)

Steve.

Former Member
0 Kudos

Hmmm .. so if I want to slice a variable that I have established in my script (let's call it 'msg' and it contains a value of '1234abcd') to pick up the two characters starting with the 4 (i.e. 4a) what would the jt look like ..

var startpnt = msg.indexof("4");

var mychar = msg.slice(startpnt,2);

OR

args.startpnt = args.msg.indexof("4");

args.mychar = args.msg.slice(args.startpnt,2);

I assumed it would be the second but I'm getting an error?

Regards.

P.

Former Member
0 Kudos

The second looks right. If the "startpnt" variable is only needed to construct mychar, and isn't needed outside of this Javascript action, it doesn't need to go inside args, but putting it there doesn't do any harm. Think of "args" as the environment for the whole script, while anything created as a local variable exists only within in this one Javascript action.

What error are you getting?


Try building it up a step at a time. Start with "args.mychar = args.msg", then "args.mychar = args.msg.slice(4,2)" and so on. There's no easy way to debug this stuff, I'm afraid...


Steve.

Former Member
0 Kudos

Thanks Steve ... pulled it apart and put it back piece by piece and it worked!

Answers (0)