jhdean
March 17, 2020, 1:49am
1
Hi,
I’m getting what seems to be odd behavior with the arrayfilter( function. It’s skipping a line.
arrayfilter(Items,¶,{array(import(),2,"$")})
is returning these 9 lines when Items contains 10.
'94.50
159.50
94.50
59.50
44.50
44.50
109.50
29.50
29.50 ’
It’s skipping: At the Breathing Hole 16x15.25 $99.50 $199.00
Items:
Denali Caribou 12x16 $94.50 $189.00
Seal Moon Rising 12x28 $159.50 $319.00
Salmon Stream 12x16 $94.50 $189.00
At the Breathing Hole 16x15.25 $99.50 $199.00
Bear Trails and Tall Tails 12x11 $59.50 $119.00
Bear Trails and Tall Tales 16x5.5 $44.50 $89.00
Between the Tides 16x5.25 $44.50 $89.00
Unexpected Company 15x16 $109.50 $219.00
Dall Sheep 7.5x8 $29.50 $59.00
Moose 6.5x8 $29.50 $59.00
What am I missing?
Thanks,
Jeff
gary
March 17, 2020, 2:01am
2
I just ran this code:
let Items={Denali Caribou 12x16 $94.50 $189.00
Seal Moon Rising 12x28 $159.50 $319.00
Salmon Stream 12x16 $94.50 $189.00
At the Breathing Hole 16x15.25 $99.50 $199.00
Bear Trails and Tall Tails 12x11 $59.50 $119.00
Bear Trails and Tall Tales 16x5.5 $44.50 $89.00
Between the Tides 16x5.25 $44.50 $89.00
Unexpected Company 15x16 $109.50 $219.00
Dall Sheep 7.5x8 $29.50 $59.00
Moose 6.5x8 $29.50 $59.00}
message arrayfilter(Items,¶,{array(import(),2,"$")})
And got this result:
94.50
159.50
94.50
99.50
59.50
44.50
44.50
109.50
29.50
29.50
As you can see this returns all 10 values so I don’t know what is different with your actual Items data than what is posted.
gary
March 17, 2020, 2:05am
3
Upon further thought, possibly the line “Salmon Stream 12x16 $94.50 $189.00” has a line feed at the end instead of a carriage return.
jhdean
March 17, 2020, 2:26am
4
That must have been it. I had pasted a group in manually. I reselected the items with the popup and it they all show in the result now.
Thanks Gary,
Jeff
You can easily and reliably find out if there are linefeeds or other invisible characters in a variable or field with Gary’s very useful database “Reveal Invisible Text”, which you can download from the Panorama Database Exchange.
admin
March 17, 2020, 8:24am
6
If there is any doubt, I use the lftocr( function.
Here’s an adjusted version of your code.
arrayfilter(lftocr(Items),cr(),{array(import(),2,"$")})
It’s tricky because “Classic” MacOS used carriage returns, while OS X/macOS uses line feeds. Panorama X mostly tries to switch everything to carriage returns for compatibility with Panorama 6 code, but it’s not possible to cover every instance of this.
jhdean
March 17, 2020, 4:13pm
7
Thanks Jim and Tom
Here’s how I’m using it in an invoice rather than using line items:
“Subtotal: “+pattern(arraynumerictotal(arrayfilter(lftocr(Items),¶,{array(import(),2,”")}),¶)," #,##”)