Parentheses in Let? Convert value to String?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Parentheses in Let? Convert value to String?

Post by Me_again » Mon Feb 07, 2005 3:54 am

I need to read a celcius temperature value from a space delimited data file, convert to F and pass the value with degree sign and F to another program.

Q1. Not a big deal because there's a work around. It doesn't seem like I can do a complex calculation like:
Let>temp=(param_5*1.8 )+32

So I have to do:
Let>tx=param_5*1.8
Let>tamb=tx+32
VBEval>Round(%tamb%,0),tamb

Am I missing something?

Q2. The real problem. How can I concatenate tamb with " °F ". Concat won't do it presumably because tamb isn't a string. Can I convert tamb to a string somehow, or what's another solution?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Feb 07, 2005 4:17 am

This works for concatenating, just add the desired string:

Code: Select all

Message>Temperature is %tamb%°F
If I start with 100° then I get a message for "212°F"

But this is not working:

Code: Select all

VBEval>Round(%tamb%,0),tamb
You need to add

Code: Select all

VBSTART
VBEND
somewhere before you do VBEVAL

Results:

Code: Select all

VBSTART
VBEND

Input>param_5,Enter Celsius temperature value
Let>tx=param_5*1.8
Let>tamb=tx+32
VBEval>Round(%tamb%,0),tamb

Message>Temperature is %tamb%°F
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Feb 07, 2005 7:39 am

Or use complex expressions and just do this:


Let>temp={ Round((%param_5%*1.8)+32) }
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Feb 07, 2005 3:11 pm

support wrote:Or use complex expressions and just do this:


Let>temp={ Round((%param_5%*1.8)+32) }
I did have the VBSTART/END in there, guess it pays to post the whole code so as not to waste helpful you folks time :oops:

When I add the {complex expression} I get "Operator opMult incompatible with String" and then "Invalid parameters to ROUND". tamb displays correctly and I did do the trailing spaces thing.


VBSTART
''
VBEND
Message>%number%
Let>rp_wait=1
ReadLn>c:\testdir\clientraw.txt,1,line
If>line=##EOF##,finish
Separate>line, ,param
Let>tempx={ Round((%param_5%*1.8)+32) }
Let>tx=param_5*1.8
Let>tamb=tx+32
VBEval>Round(%tamb%,0),tamb
Message>temp: %tamb% %tempx%
Label>finish



The Separate is working OK, the data string is

12345 10.0 9.6 275 11.2 73 1011.1 0.0 0.0 460.2 0.0 0.0 20.7 48 255.0 2 0.0 0 0 0.0

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Feb 07, 2005 4:12 pm

Hmmmm, I thought that ROUND was available in Macro Scheduler, did a Search and nothing came up. Thought I had confused commands in Macro Scheduler with another unknown program.

Because of this example< I took another look, and it is still not coming up. What is wrong with me? So I did a search on Complex Expressions and ... .... ... voila!.....there it is, along with many other forgotten/hidden functions.

See Arithmetic Expressions in Help
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Feb 07, 2005 4:20 pm

Thanks for the clue, I searched too and only found the vbscript example, I'm off to complex expressions right now :D

The ConCat does work, I don't know what I was doing wrong last night.

Guest

Post by Guest » Mon Feb 07, 2005 5:13 pm

I tried a very simple test and still get the same errors :cry:


Let>tttt=333.33
Let>tamb={Round(%tttt%*1.8)}
Message>%tttt% %tamb%


But this does work

Let>tamb={Round(333.33*1.8)}
Message>%tamb%

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Feb 07, 2005 5:47 pm

Yes, confirmed. Something not right there. It works if you remove decimals. I.e. it appears that it is interpretting 333.33 as a string. 333 works, 333.33 does not in this context. Seems to be an issue with real number variables when being converted into complex expressions.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Feb 07, 2005 6:12 pm

Just to let you know, we've located the cause of this problem and have fixed it for the next release.
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Feb 07, 2005 6:58 pm

You guys are too good!

Are there examples somewhere for complex expressions? I'm sure "function Round(X: Extended): Integer" must conform to some standard but I would have a hard time translating it to "Let>tamb={Round(333.33*1.8)}".

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Feb 07, 2005 7:07 pm

See: Comlex Expressions:
http://www.mjtnet.com/OnlineHelp/index. ... ssions.htm

and: Let:
http://www.mjtnet.com/OnlineHelp/index. ... d370_2.htm

Let has a couple of examples of complex expressions.
MJT Net Support
[email protected]

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