Field data not updating??

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Field data not updating??

Post by azbob » Sun Mar 21, 2021 3:26 am

FCI:
Microsoft Windows 10 Home
Microsoft Windows NT 10.0.19041.0
64-bit Operating System
iMacros Browser (x86) Version 12.6.505.4525
Released on 11/8/19
Licensed Product: iMacros Enterprise Edition
PM: V29

Hi,

I am trying to display decimal field without leading zero, ie: " .00 instead of 0.00"
It works in "MNTH" field but not in the "Comp_Sold" field.
Here are the prompts:
PROMPT 1:
Monthly_Numbers:
Mnthly1: .08
Mnthly2: 1

PROMPT 2:
Num_Sold: 10
MNTH: .8
Comp_Sold: 0.8

My question is if MNTH: displays ".8" , Why does Comp_Sold display " 0.8" since it appears that the all "SET Comp_Sold" line does in this case is set Comp_Sold to whatever is in MNTH (or Mnthly2. if I set Num_Sold to a number >= 12).

Code: Select all

VERSION BUILD=12.6.505.4525
TAB T=1     
TAB CLOSEALLOTHERS  
SET !ERRORIGNORE NO
'SET Num_Sold to number <12 for decimal (<1) or SET to number >12 for whole number ( >=1)  in Comp_Sold 
SET Num_Sold 10
'Determine if monthly number is displayed as decimal or whole number
'Display Decimal when yearly total number is less than 12 per year
SET Mnthly1 EVAL("var w,x,y,z; w=(\"{{Num_Sold}}\" / 12); x=(w.toFixed(1)); x;") 
'Display whole number when yearly total is 12 or more per year
SET Mnthly2 EVAL("var x,y; x=(\"{{Num_Sold}}\" / 12); y=(Math.round(x)); y;")
PROMPT Monthly_Numbers:<BR>Mnthly1:<SP>{{Mnthly1}}<BR>Mnthly2:<SP>{{Mnthly2}}
'If decimal just display numbers after decimal point .00 not 0.00
SET MNTH EVAL("var x,y,z; x=(\"{{Mnthly1}}\"); z=x.slice(1); z;")
'Determine if MNTH is decimal or not(<1). If so put MNTH into Comp_Sold. If not put Mnthly2 in Comp_Sold
SET Comp_Sold EVAL("if ({{MNTH}} > 0 && {{MNTH}} < 1) {{MNTH}}; else {{Mnthly2}}; ")
PROMPT Num_Sold:<SP>{{Num_Sold}}<BR>MNTH:<SP>{{MNTH}}<BR>Comp_Sold:<SP>{{Comp_Sold}}
I have stared at this too long and tried many iterations, but I can't get Comp_Sold to display the right format.

Thanks
Bob
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Field data not updating??

Post by chivracq » Sun Mar 21, 2021 4:54 am

azbob wrote:
Sun Mar 21, 2021 3:26 am
FCI:

Code: Select all

Microsoft Windows 10 Home
Microsoft Windows NT 10.0.19041.0
64-bit Operating System
iMacros Browser (x86) Version 12.6.505.4525
Released on 11/8/19
Licensed Product: iMacros Enterprise Edition
PM: V29
Hi,

I am trying to display decimal field without leading zero, ie: " .00 instead of 0.00"
It works in "MNTH" field but not in the "Comp_Sold" field.
Here are the prompts:

>

PROMPT 1:

Code: Select all

Monthly_Numbers:
Mnthly1: .08
Mnthly2: 1
>

PROMPT 2:

Code: Select all

Num_Sold: 10
MNTH: .8
Comp_Sold: 0.8
My question is if MNTH: displays ".8" , Why does Comp_Sold display " 0.8" since it appears that the all "SET Comp_Sold" line does in this case is set Comp_Sold to whatever is in MNTH (or Mnthly2. if I set Num_Sold to a number >= 12).

Code: Select all

VERSION BUILD=12.6.505.4525
TAB T=1     
TAB CLOSEALLOTHERS  
SET !ERRORIGNORE NO
'SET Num_Sold to number <12 for decimal (<1) or SET to number >12 for whole number ( >=1)  in Comp_Sold 
SET Num_Sold 10
'Determine if monthly number is displayed as decimal or whole number
'Display Decimal when yearly total number is less than 12 per year
SET Mnthly1 EVAL("var w,x,y,z; w=(\"{{Num_Sold}}\" / 12); x=(w.toFixed(1)); x;") 
'Display whole number when yearly total is 12 or more per year
SET Mnthly2 EVAL("var x,y; x=(\"{{Num_Sold}}\" / 12); y=(Math.round(x)); y;")
PROMPT Monthly_Numbers:<BR>Mnthly1:<SP>{{Mnthly1}}<BR>Mnthly2:<SP>{{Mnthly2}}
'If decimal just display numbers after decimal point .00 not 0.00
SET MNTH EVAL("var x,y,z; x=(\"{{Mnthly1}}\"); z=x.slice(1); z;")
'Determine if MNTH is decimal or not(<1). If so put MNTH into Comp_Sold. If not put Mnthly2 in Comp_Sold
SET Comp_Sold EVAL("if ({{MNTH}} > 0 && {{MNTH}} < 1) {{MNTH}}; else {{Mnthly2}}; ")
PROMPT Num_Sold:<SP>{{Num_Sold}}<BR>MNTH:<SP>{{MNTH}}<BR>Comp_Sold:<SP>{{Comp_Sold}}
I have stared at this too long and tried many iterations, but I can't get Comp_Sold to display the right format.

Thanks
Bob

Fouff-fouff, you are a bit "messy", in your way of "Thinking", ah-ah...! OK, don't get "angry", but "follow me"...!"

First, I will simply repost your Script with just a few Returns...:

Code: Select all

VERSION BUILD=12.6.505.4525
TAB T=1     
'TAB CLOSEALLOTHERS  
'SET !ERRORIGNORE NO

'SET Num_Sold to number <12 for decimal (<1) or SET to number >12 for whole number ( >=1)  in Comp_Sold 
SET Num_Sold 10

'Determine if monthly number is displayed as decimal or whole number
'Display Decimal when yearly total number is less than 12 per year
SET Mnthly1 EVAL("var w,x,y,z; w=(\"{{Num_Sold}}\" / 12); x=(w.toFixed(1)); x;") 

'Display whole number when yearly total is 12 or more per year
SET Mnthly2 EVAL("var x,y; x=(\"{{Num_Sold}}\" / 12); y=(Math.round(x)); y;")
PROMPT Monthly_Numbers:<BR>Mnthly1:<SP>{{Mnthly1}}<BR>Mnthly2:<SP>{{Mnthly2}}

'If decimal just display numbers after decimal point .00 not 0.00
SET MNTH EVAL("var x,y,z; x=(\"{{Mnthly1}}\"); z=x.slice(1); z;")

'Determine if MNTH is decimal or not(<1). If so put MNTH into Comp_Sold. If not put Mnthly2 in Comp_Sold
SET Comp_Sold EVAL("if ({{MNTH}} > 0 && {{MNTH}} < 1) {{MNTH}}; else {{Mnthly2}}; ")
PROMPT Num_Sold:<SP>{{Num_Sold}}<BR>MNTH:<SP>{{MNTH}}<BR>Comp_Sold:<SP>{{Comp_Sold}}
=> Re-ouf-ouf, I had some some "Difficulty" reading your one-Block Script, and 4 Vars you define with more or less but still 4 different Naming Conventions..., hum, or 3 actually, but still confusing anyway... :shock:

I won't try (for now at least) to debug your Script, I'm pretty confident you'll find the Solution by yourself, if you follow my "little Advice", and use "my" Syntax... :idea:

>>>

=> Better...:

Code: Select all

'Determine if monthly number is displayed as decimal or whole number
'Display Decimal when yearly total number is less than 12 per year
'SET Mnthly1 EVAL("var w,x,y,z; w=(\"{{Num_Sold}}\" / 12); x=(w.toFixed(1)); x;")
SET Monthly_Nb_1 EVAL("var ns='{{Num_Sold}}'; var x,y,z; x=ns/12; z=x.toFixed(1); z;")
>

=> Better...:

Code: Select all

'Display whole number when yearly total is 12 or more per year
'SET Mnthly2 EVAL("var x,y; x=(\"{{Num_Sold}}\" / 12); y=(Math.round(x)); y;")
SET Monthly_Nb_2 EVAL("var ns='{{Num_Sold}}'; var x,y,z; x=ns/12; z=Math.round(x); z;")
PROMPT Monthly_Numbers:<BR>Monthly_Nb_1:<SP>_{{Monthly_Nb_1}}_<BR>Monthly_Nb_2:<SP>_{{Monthly_Nb_2}}_
(+ 'PROMPT' with Underscores to display Vars...!! :!: :idea: )

>

=> Better...:

Code: Select all

'If decimal just display numbers after decimal point .00 not 0.00
'SET MNTH EVAL("var x,y,z; x=(\"{{Mnthly1}}\"); z=x.slice(1); z;")
SET Monthly_Nb_1_Dec EVAL("var m1='{{Mnthly1}}'; var x,y,z; z=m1.slice(1); z;")
Hum..., 'slice()' is a 'String' Method, not "meant" for Numbers...
But OK, "luckily" for you, iMacros has "difficulties" with Vars, especially in 'EVAL()' and finally treat them all as 'String', so you are fine, ah-ah...! :P

And re-hum, "If decimal => whatever", but you don't have any 'if' Condition (and even less 'else'), so you are truncating the first Char of all Input Strings/Nb's in that 'EVAL()'... Not sure that's the Result you want... :?

>

=> Orig..:

Code: Select all

'Determine if MNTH is decimal or not(<1). If so put MNTH into Comp_Sold. If not put Mnthly2 in Comp_Sold
SET Comp_Sold EVAL("if ({{MNTH}} > 0 && {{MNTH}} < 1) {{MNTH}}; else {{Mnthly2}}; ")
PROMPT Num_Sold:<SP>{{Num_Sold}}<BR>MNTH:<SP>{{MNTH}}<BR>Comp_Sold:<SP>{{Comp_Sold}}
=> Hum..., I don't know this (simplified) 'if'/'else' Syntax... But OK, you have some 'PROMPT' to follow your Vars, I guess you've already checked that you don't get any "_Undefined_" in the 'PROMPT'... (for your "Comp_Sold" Var...).

=> Better anyway...:

Code: Select all

'Determine if MNTH is decimal or not(<1). If so put MNTH into Comp_Sold. If not put Mnthly2 in Comp_Sold
'SET Comp_Sold EVAL("if ({{MNTH}} > 0 && {{MNTH}} < 1) {{MNTH}}; else {{Mnthly2}}; ")
SET Comp_Sold EVAL("var m1='{{Monthly_Nb_1}}', m2='{{Monthly_Nb_2}}', m1d='{{Monthly_Nb_1_Dec}}'; var x,y,z; if((m1d>0)&&(m1d<1)){z=m1d;} else{z=m2;}; z;")
PROMPT Num_Sold:<SP>{{Num_Sold}}<BR>MNTH:<SP>{{MNTH}}<BR>Comp_Sold:<SP>{{Comp_Sold}}
OK, I didn't correct your last 'PROMPT', you know how "now"... :wink:

And integrate all Parts together to debug your Script... :idea:
+ One final 'PROMPT' with all Vars used in your Script...! :idea:
(=> Notice the '_' (Underscore) I re-added to your/my Script around Vars in a 'PROMPT', very useful, trust me, ah-ah...! :roll: )

>>>

And "again" I didn't run your Script, only vaguely "mentally", and I don't know the 'if'/'else' Syntax you used, so hum..., I didn't "try my best", but I honestly think that if you follow my "Principles", you should find the Sol by yourself... (and probably won't ever need any Help from me or the Forum anymore, ah-ah...!) :P

And mini-Remark, but it took me more than 1 Hour to prepare and post this Reply, while I would have probably found "the" Solution to your Pb in less than 5 Min if I had run your Script and done the Debugging myself, but I think it's more useful to you (and to other Users) if you find the Sol by yourself... :P
Last edited by chivracq on Sun Mar 21, 2021 10:46 pm, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Field data not updating??

Post by chivracq » Sun Mar 21, 2021 5:48 pm

And hum..., for the Functionality that you want, ("I am trying to display decimal field without leading zero, ie: " .00 instead of 0.00""), a simple "replace('0.','.')" would already "do the Trick", I would think, and also taking care of the Conditional Part... :idea:
... Well..., if I understood correctly that your Nb's are always in Range [0-1]... Yeah, well, of course, or you wouldn't want to remove the Leading "0" otherwise, ah-ah...! :P
But there will be several Solutions anyway...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Field data not updating??

Post by azbob » Sun Mar 21, 2021 11:28 pm

Problem solved.

I never realized that vars had to be defined within conditional statements. I would always jump through hoops to try and make them work correctly.
Now I know!

I completely spaced on the "replace". However, what I didn't explain(sorry for the omission) is that the " Num_Sold" ( which can range from 1 to into 1000's) is expressed as a "yearly total". I needed to convert to approximate monthly number. So if "Num_Sold" is below 12 I have to allow for decimal places.
Hence why I used the "toFixed or Math.round" expressions and the conditional.

Either way your Re-casted "Comp_Sold" statement solved it.

Thanks
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Field data not updating??

Post by chivracq » Mon Mar 22, 2021 12:53 am

azbob wrote:
Sun Mar 21, 2021 11:28 pm
Problem solved.

I never realized that vars had to be defined within conditional statements. I would always jump through hoops to try and make them work correctly.
Now I know!

I completely spaced on the "replace". However, what I didn't explain(sorry for the omission) is that the " Num_Sold" ( which can range from 1 to into 1000's) is expressed as a "yearly total". I needed to convert to approximate monthly number. So if "Num_Sold" is below 12 I have to allow for decimal places.
Hence why I used the "toFixed or Math.round" expressions and the conditional.

Either way your Re-casted "Comp_Sold" statement solved it.

Thanks

"I never realized that vars had to be defined within conditional statements."
=> Well, no, not really, you could use previously defined (iMacros) Vars "directly" in your Expressions or 'if' Statements but I prefer indeed to declare all those Vars with a short Alias at the Beginning of the 'EVAL()' as it has several Advantages: It's easier ad shorter if you need to use any Var several times inn the 'EVAL()', in most Cases, it takes care of the Escaping, especially when using/reusing those Vars inside some JS Command, and by also declaring 3 "x,y,z" Vars, those can be used to "slowly" build your Expression towards the final "z" Result returned by 'EVAL()', and for complex Expressions, by temporarily returning "x" or "y", you can also easily follow those Vars and debug your full Expression if you don't get "directly" the expected Result... :idea:

And the Syntax I use is pretty secure and easy to reuse for (more) complex Expressions, like for example the User in this Thread did, with much more complex Expressions than in your Case/Thread, with up to 9 Steps in the 'EVAL()', while being new to iMacros, and with no Programming Experience... :D
(And in the same Link/Post, I also posted another Implementation of the Functionality they wanted, a bit simpler and where I managed to reduce the Steps to only 3 with only "x,y,z"...)

But OK, glad it's now working, and Thanks for the Feedback..., and I guess, we probably won't see you on the Forum anymore, ah-ah...! :( :P
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply