xsharp.eu • Report Pro 2.30a - concatenating variables
Page 1 of 1

Report Pro 2.30a - concatenating variables

Posted: Mon Nov 11, 2019 2:50 am
by Anonymous
I would like to have a string appear like:

DDH X 2, HIAB X 5, FLATBED X 2, TABLETOP X 4

etc up to 10 different type trucks and the number used. Due to field length limitations in ReportPro, I've had to break it into 4 different variables, as shown below:

//TrucksUsed1
iif( Empty(Costings.T1) == .F. , AllTrim(Costings.T1) + " x " + AllTrim(Str(Integer(Costings.Tq1))) + ", ", "") + iif( Empty(Costings.T2) == .F. , AllTrim(Costings.T2) + " x " + AllTrim(Str(Integer(Costings.Tq2))) + ", ", "") + iif( Empty(Costings.T3) == .F. , AllTrim(Costings.T3) + " x " + AllTrim(Str(Integer(Costings.Tq3))) + ", ", "")

//TrucksUsed2
iif( Empty(Costings.T4) == .F. , AllTrim(Costings.T4) + " x " + AllTrim(Str(Integer(Costings.Tq4))) + ", ", "") + iif( Empty(Costings.T5) == .F. , AllTrim(Costings.T5) + " x " + AllTrim(Str(Integer(Costings.Tq6))) + ", ", "") + iif( Empty(Costings.T6) == .F. , AllTrim(Costings.T6) + " x " + AllTrim(Str(Integer(Costings.Tq6))) + ", ", "")

//TrucksUsed3
iif( Empty(Costings.T7) == .F. , AllTrim(Costings.T7) + " x " + AllTrim(Str(Integer(Costings.Tq7))) + ", ", "") + iif( Empty(Costings.T8) == .F. , AllTrim(Costings.T8) + " x " + AllTrim(Str(Integer(Costings.Tq8))) + ", ", "") + iif( Empty(Costings.T9) == .F. , AllTrim(Costings.T9) + " x " + AllTrim(Str(Integer(Costings.Tq9))) + ", ", "")

//TrucksUsed4
iif( Empty(Costings.T10) == .F. , AllTrim(Costings.T10) + " x " + AllTrim(Str(Integer(Costings.Tq10))), "")


Problem is when TrucksUsed1 runs out and TrucksUsed2 starts, theres a large gap between the two:
Display Problem.JPG
Display Problem.JPG (10.91 KiB) Viewed 270 times


Alltrim doesn't seem to work - it produces a runtime error using this code in ReportPro:

Alltrim(TrucksUsed1) + ", " + Alltrim(TrucksUsed2) + ", " + Alltrim(TrucksUsed3) + ", " + Alltrim(TrucksUsed4)

error1.JPG
error1.JPG (21.08 KiB) Viewed 270 times
Error2.JPG
Error2.JPG (20.95 KiB) Viewed 270 times



But the query builder says the expressions are valid. What am I missing please?

Thanks again guys.

Jeff

Report Pro 2.30a - concatenating variables

Posted: Mon Nov 11, 2019 12:37 pm
by robert
Jeff,
Can you include an example report and its datafiles ?
Alltrim should work, so there must be another reason why this fails.
Most likely the order in which you have defined the expressions is the reason for the problem. Make sure that the variable that uses TruckUsed 1 .. 4 is later in the list than the variables that it uses.

Robert

Report Pro 2.30a - concatenating variables

Posted: Mon Nov 11, 2019 11:28 pm
by BiggyRat
Genius! Thank you Robert..

"the variable that uses TruckUsed 1 .. 4 is later in the list than the variables that it uses." That fixed it!