PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Weird programming result  (Read 162 times)

michaelgreer

  • Silver Member
  • ***
  • Posts: 26
    • View Profile
Weird programming result
« on: September 17, 2019, 10:45:11 AM »
On PxPlus 12.51 I see this:
2260 print (10)@(30),fnif(sorsop.type$="D",num(sorsop.orig_amt$),-num(sorsop.amount$)):y3$+" "+tbl(pos(sorsop.type$="DEORAT")-1,"",sorsop.reason$+" "+forfeit_reason$,"",sorsop.memo$,"",sorsop.note$); l=l+1; goto NEXT_DEP_TRANS

The contents of sorsop.memo$+sorsop.notes$ is ABCABCABCABCABCABC BLUE BUBBLES.  All of the B's are dropped, whether printing to a device (notepad) or to the console.  Note what should probably throw an error is that the first output is a masked numeric field passed through y3$ which is concatenated to a string value.  Simply changing that "+" to a comma rectifies the issue.  Attached doc shows this.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Weird programming result
« Reply #1 on: September 17, 2019, 10:56:58 AM »
Evidently, the implicit numeric formatting into the string uses "y3$+...,sorsop.note$)" as the mask applied to the numeric value. If the code is change to use the STR() function, it should work fine:
str(fnif(sorsop.type$="D",num(sorsop.orig_amt$),-num(sorsop.amount$)):y3$)+" "+...
A "B" in a mask is used to indicate a blank space position, which is why the "B"s disappeared.
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

michaelgreer

  • Silver Member
  • ***
  • Posts: 26
    • View Profile
Re: Weird programming result
« Reply #2 on: September 17, 2019, 11:11:31 AM »
Thanks James. I did fix the issue, but I didn't realize that everything after that "+" sign got interpreted as part of the mask.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Weird programming result
« Reply #3 on: September 17, 2019, 11:13:34 AM »
Yep. It's just one BIG string/mask expression when using "+".
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3185
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Weird programming result
« Reply #4 on: September 19, 2019, 04:34:32 PM »
Just to clarify; in a PRINT directive a numeric variable followed by a ":" indicates that a string expression follows which till define the format to use when outputting the number.

In your case the '+' was considered part of the string expression and thus the subsequent string text was included as the format.   To avoid this use a comma to separate the values.