1. Heiko Bergner
  2. PowerBuilder
  3. Monday, 3 September 2018 11:28 AM UTC

Hello,

I created a support ticket for this, but maybe someone had a similar problem and found a solution.

*Phenomenon:
If I use the dw_1.describe("evaluate('"+ls_eval+"',1)") function to calculate some decimal values
this works fine on a real PC. If I run the same on a virtual machine the result is wrong.
Example: 3.5 * 3.5 = 12.25 on PC but on VM the result is 9  (see attachment)

The wrong calculation was reproduced on a Micrsoft Hyper-V machine running Windows 10 and
also on a VMWare running on Windows Server 2008

The error can be reproduced using the 'evaluate()' function and with modify(...expression)


*Reproduce Steps:
// script estimates you have a datawindow dw_1
// test the functionality of evaluate /expression
string ls_eval
string ls_result_eval
decimal lc_result_express
string ls_ret
long ll_row

// the string that should be evaluated
ls_eval = "3.5 * 3.5"

// test with evaluate
ls_result_eval = dw_1.describe("evaluate('"+ls_eval+"',1)")

// test with expression
ls_ret = dw_1.modify('create compute(band=foreground alignment="0" expression="'+ls_eval+&
                '" border="0" color="0" x="394" y="400" height="1" width="1" format="[general]"  '+&
                'name=evalresult  font.face="Arial" font.height="-6" font.weight="400"  '+&
                'font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" )')

// normaly here are some checks for coltype,...
lc_result_express= dw_1.getitemnumber(1,"evalresult")

Messagebox("Result for evaltest","Result for: "+ls_eval+"~r~n~r~nevaluate: "+string(ls_result_eval)+"~r~nexpression: "+string(lc_result_express))
dw_1.modify("destroy evalresult")


Best Regards,

Heiko

Attachments (2)
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 4 September 2018 22:03 PM UTC
  2. PowerBuilder
  3. # 1

If possible, try running all math calculations outside of the EVALUATION string, and outside of any EVALUATION process.

In your example
decimal {4}     ld_val1, ld_val2, ld_result
string             ls_eval, ls_evalresult


ld_val1 = 3.5          // Loaded from a CASE statement or by parameter
ld_val2 = 3.5
ld_result = ld_val1 * ld_val2

ls_evalresult = String (ld_result)           // Can specify decimal spaces if you wish

// test with expression
ls_ret = dw_1.modify('create compute(band=foreground alignment="0" expression="'+ls_eval+&
                '" border="0" color="0" x="394" y="400" height="1" width="1" format="[general]"  '+&
                'name=ls_evalresult  font.face="Arial" font.height="-6" font.weight="400"  '+&
                'font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" )')


Olan

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 3 September 2018 20:50 PM UTC
  2. PowerBuilder
  3. # 2

Make sure there is a current printer set.

Comment
There are no comments made yet.
Martin Roth Accepted Answer Pending Moderation
  1. Monday, 3 September 2018 14:54 PM UTC
  2. PowerBuilder
  3. # 3

Maybe a problem with different Regional Settings on the VM (Decimal Separator?) ?

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.