Page 1 of 1

Math gives error on execution on some win7 machines

PostPosted: Fri Jan 05, 2018 12:19 pm
by frednet
Picking up development on a data logger pub I run into the strange event that the publication works fine on most window machines.
I managed to pin the fault down to the Math command. Executing the code below. works fine in windows 8.1 and on the xp machines I tested.
However on a windows 7 starter notebook the variable e.g. [waarde1] generated contains the word Error. I tried disabling security essentials, that did not help. The notebook is an aspire one.

testing further on a windows 7 premium computer things are working well. Any idea what could be going on? any known conflicts?
thanks Fred

Code: Select all
SetVar "[mdata12]" "22,88"
SetVar "[mdata22]" "82,88"
SetVar "[mdata32]" "52,88"

Loop "1" "3" "[teller]"
Math "[mdata[teller]2]*6+90" "0" "[waarde[teller]]"
endloop

Re: Math gives error on execution on some machines

PostPosted: Fri Jan 05, 2018 9:43 pm
by Gaev
frednet:

1) What are the versions of NeoBook on each of these machines ? ... more likely a difference in NeoBook versions than Windows versions.

2) Are all versions of Windows setup to recognize comma as the decimal point ?

3) Are results similar if the values are others than 22,88 and 82,88 and 52,88 ? e.g without any decimals (like 22 and 82 and 52)

4) As a workaround, try ...
a)
Code: Select all
Loop "1" "3" "[teller]"
   Math "([mdata[teller]2]*6) + 90" "0" "[waarde[teller]]"
Endloop


b)
Code: Select all
Loop "1" "3" "[teller]"
   SetVar "[thisMdata]" "[mdata[teller]2]"
   AlertBox "thisMdata" '[thisMdata]"
   Math "([thisMdata]*6) + 90" "0" "[waarde[teller]]"
Endloop

Re: Math gives error on execution on some win 7 machines

PostPosted: Sat Jan 06, 2018 4:43 am
by frednet
Hello Geav,

1. I make my neobook publications on one windows 8.1 machine it is the same compiled exe that gives the different result on the machines mentioned.
my neobook versio is 5.8.5.

2. yes they are all set for comma as decimal separator

3. using whole numbers then there is no error

4A. this code sample gives the same error

4B this code sample displays : 22,88 in the alert box and gives the same error next.

But you inspired me to look into decimal point issues and i found this article
https://www.copsmodels.com/gpcommapnt.htm

following its instructions the problem was solved.

so in case someone else runs into this windows 7 bug here are the steps to take:

Open Regional and Language Options
Under "Format" pick another regional setting (eg: English (United States)).
Press "Apply"
Under "Format" pick your original desired locale (ie: Finnish)).
Press OK.

Geav, thanks for putting me on the right track!

Fred

Re: Math gives error on execution on some win7 machines

PostPosted: Sat Jan 06, 2018 10:39 am
by David de Argentina
One of the first declarations on COBOL (wow... pretty older!!!) at the data division is "Decimal Point is Comma"

This issue always be a pain in the neck.

The same with the Name of the days (depending the win version Saturday in spanish could be Sábado or Sabado - note the accent on the first a)

I don't understand why newer languages (and ODBC's) let OS's takes the control. :roll:

Re: Math gives error on execution on some win7 machines

PostPosted: Sat Jan 06, 2018 3:28 pm
by Gaev
frednet:

Open Regional and Language Options
Under "Format" pick another regional setting (eg: English (United States)).
Press "Apply"
Under "Format" pick your original desired locale (ie: Finnish)).
Press OK.

I am glad you were able to narrow it down to the "decimal point setting" ... and found a work around.

However, in case changing the (system wide) Regional Setting messes up other programs on the same computer (or your users do not have the technical savvy to make such changes), you might consider this safer work around ...
Code: Select all
Loop "1" "3" "[teller]"
   SetVar "[thisMdata]" "[mdata[teller]2]"
   ... replace comma with decimal point
   StrReplace "[thisMdata]" "!," "!." "[thisMdata]" ""
   AlertBox "thisMdata" '[thisMdata]"
   Math "([thisMdata]*6) + 90" "0" "[waarde[teller]]"
   AlertBox "waarde[teller]" "[waarde[teller]]"
   ... revert decimal point to comma
   StrReplace "[waarde[teller]]" "!." "!," "[waarde[teller]]" ""
Endloop

Re: Math gives error on execution on some win7 machines

PostPosted: Sat Jan 06, 2018 4:25 pm
by frednet
the original source data has decimal point structure instead of comma. So your suggestion should not be to hard to implement.
My output is an exel file and a comma delimiter is needed there.
Is using a decimal point the common practice in programming? Or is that country specific?
kind regards Fred

Re: Math gives error on execution on some win7 machines

PostPosted: Sat Jan 06, 2018 4:58 pm
by Gaev
fredet:

the original source data has decimal point structure instead of comma. So your suggestion should not be to hard to implement.

So, just eliminate the first StrReplace command inside the loop.

My output is an exel file and a comma delimiter is needed there.

My suggestion was to do the replace/revert immediately before/after each Math command ... so this should not be an issue.

However, I am curious how the same (comma) delimiter can be used to separate both fields (columns) and integer-decimals e.g. is 1,234,275,66 ...

-four cells with integer values of 1 and 234 and 275 and 66 ?
or
- two cells containing 1 point 234 and 275 point 66 ?

... or do you have to surround each cell values with double-quotes ? e.g. "1,234","275,66"

Re: Math gives error on execution on some win7 machines

PostPosted: Sun Jan 07, 2018 2:26 am
by frednet
my application imports temperatures from another aplication, it is a comma delimiter csv. the second column is the temperature value using a decimal point.

Code: Select all
"46000802B344A110",8.81,06.01.2018,21:59:46,,,,,,,


in my output file a tab is used to separate columns like this:

Code: Select all
FileWrite "[naamdatafile]" "Append" "[DateShort][#09][Time24][#09][mdata12]" etc

I made this construction years ago and forgot why since...:)
It has the disadvantage that one has to assign the tab as column separator once

on your question i did a small test saving a ods file to csv libre office puts a number with decimals inside quotation marks

Code: Select all
"12,44",13,