"result = " vs "v-run = "

Discuss your general Proclaim related queries here.
Post Reply
David P
Posts: 30
Joined: Thu Jan 11, 2018 10:33 am
Has thanked: 3 times
Been thanked: 4 times

"result = " vs "v-run = "

Post by David P » Thu May 09, 2019 3:50 pm

I'm investigating an issue with a linked action that creates conveyancing cases and noticed a maths item being called in the linked case by using the following:

Code: Select all

result = {Conveyancing.Case Start Date (put).Text}
I would normally call maths as follows:

Code: Select all

v-run = {Conveyancing.Case Start Date (put).Text}
Can anyone shed any light on the difference between the two? I've only used result in tests, so I can't see why you would want to use it when nothing is actually done with the result.

steve
Posts: 393
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 82 times

Re: "result = " vs "v-run = "

Post by steve » Thu May 09, 2019 4:49 pm

As you probably know, "result" is both a local variable (a named pot to store a value in temporarily) and a special keyword that returns/outputs whatever you assign to it back to any calling maths/linked actions.

"v-run" is just the name of a local variable to hold a value. Eclipse's preference for variable naming is "v-something"

Say you have a maths field that adds up two numbers:

[maths field {M add.Text}]

Code: Select all

v1 = {value1.Value} + {value2.Value}
result = v1
You can then 'call' that maths in, say a linked action, to use the result.

[linked action]

Code: Select all

#make a variable "v-run" and store the result of the maths into it.
put (1,{value1.Value})
put (2,{value2.Value}) 
v-run = {M add.Text}
#since the 'result' of M add is 3, we have set our variable v-run to the value 3
MESSAGE ("Sum: ",v-run)
# alternatively , just use the result of the maths directly.
MESSAGE ("Sum: ",{M add.Text})
In your code, 'result' is used as a local variable just like 'v-run'. If you use 'result' in a linked action, it doesn't go anywhere upstream (unless you are doing some funky CALL-ACTION stuff) and is treated just like a variable.

Why would you use 'result' in a linked action to call a Maths field? It's probably a bit of code re-use from a previous Maths field, copied and pasted into a Linked Action. Thee is the above command "CALL-ACTION" that lets you call a linked action from within Maths, but is only used in very specific circumstances (caseless autoroutines such as MOJ portal autoroutine)

David P
Posts: 30
Joined: Thu Jan 11, 2018 10:33 am
Has thanked: 3 times
Been thanked: 4 times

Re: "result = " vs "v-run = "

Post by David P » Fri May 10, 2019 11:14 am

Cheers, didn't realise a keyword could also be used as a local variable so that makes sense now.
Not that I'd use it myself though, seems like dangerous territory to me.

ISimpson
Posts: 8
Joined: Mon Mar 18, 2019 5:14 pm

Re: "result = " vs "v-run = "

Post by ISimpson » Thu May 16, 2019 8:02 am

If you follow the examples that Eclipse have in linked actions and maths then you can see that maths fields which directly return a value back have 'result=' in them which you can then use in the linked action (or other maths fields) - essentially a 'Function' in programming speak (shame you can't directly pass values into the function without having to store first in other fields). In linked actions the returned value can then be read and used to determine flow either by reading into a local variable or directly: -

v-calc-date = {xxxxxxxxxxxxx.text} or IF {xxxxxxxxxxx.text} = TRUE

'v-run' is used to call a maths field which is essentially a 'Procedure' which does something but does not return a value directly.

So 'v-run' (it could be called anything actually) to execute some code in a maths field that does not send back a direct value.
'result' part of executed code to send back to the calling routine a direct value.

When creating code to return a direct value then there should only be one 'result' that gets called otherwise you may not get the result you want.

IF x=y THEN
result = 1
ELSE
result = 0
END

Post Reply