Peculiar problem with length(


#1

Trying to make a text display list using arrayselectedbuild. I want to have the column line up, so have to adjust spacing on the fly.

I am using this formula:
arrayselectedbuild lvDailyList,¶,"",datepattern(«DF_Date»,“DAY”)+rep(" “,2)+rep(” “,switch(length(str(«Gross»)),
3,4,
4,3,
5,2,
6,1,
0))+pattern(«Gross»,”#.##")+"–"+str(length(str(«Gross»)))

Using three different data sets, I get the below results (I’m using a fixed width font). They all line up correctly except one per set. I included the length at the end to see that the length is being read wrong in the marked items:

FRI  1113.18--7
SAT  1800.45--7
SUN  1169.55--7
MON   120.45--6
TUE      435.00--3 << Should be 6
WED   317.27--6
THU   447.73--6

FRI   517.73--6
SAT   814.55--6
SUN  736.82--17<< should be 6
MON   162.27--6
TUE   143.18--6
WED    61.82--5
THU   267.73--6

FRI  1187.27--7
SAT  1793.64--7
SUN   843.64--6
MON   151.36--6
TUE   493.18--6
WED   454.55--6
THU  0.00--1 << should be 4

Any idea what is causing the length( to be misread?


#2

str(«Gross») isn’t going to return the same value as your pattern( function. str(435.00) will return 435. That’s just 3 characters. str(736.82) is probably 736.8200000000001 or 736.8199999999999. str(0.00) is just 0.

Instead of using the switch( function, you can do it the old way.

arrayselectedbuild lvDailyList,¶,"",datepattern(«DF_Date»,“DAY”)+rep(" “,2)+(rep(" ",7)+pattern(«Gross»,”#.##"))[-7,-1]

#3

Oh well, it was an interesting try. The way I had it before was even more complicated - nested ?( . Your’s looks easier.
Thanks
Martin

Martin McCaffery


#4

BTW that part of the formula could also be written

fixedwidthright(pattern(«Gross»,"#.##"),7)

It’s another way of writing exactly the same formula.


#5

Thanks

Martin McCaffery


#6

Martin, at the risk of telling you something you already know, which I have done several times in the forum, you know you can build the array with tabs separating the data and display it in a multi-column text list and the alignment is all taken care of, right? Tom