Solved: How to prevent leading spaces being clipped?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
MichaelQ
Posts: 122
Joined: Mon Aug 22, 2016 12:14 am
Location: UK

Solved: How to prevent leading spaces being clipped?

Post by MichaelQ »

I have a text attribute that contains leading spaces for formatting purposes.
How can I prevent them automatically being clipped when displayed in a query?

Thank you.
Last edited by MichaelQ on Mon Mar 05, 2018 2:07 pm, edited 1 time in total.
Michael Q
Devon, UK
MichaelQ
Posts: 122
Joined: Mon Aug 22, 2016 12:14 am
Location: UK

Re: How to prevent leading spaces being clipped?

Post by MichaelQ »

Anyone?
Michael Q
Devon, UK
Jaymer
Posts: 2475
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to prevent leading spaces being clipped?

Post by Jaymer »

what if you had a 2nd field (Field2) that was always initialized to your desired field.
Field2 is a type HTML.
You do a REPLACE (or whatever) to change leading spaces to  
Display this field in the query

jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
aware_support
Posts: 7527
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How to prevent leading spaces being clipped?

Post by aware_support »

The TRIM function clips both leading and trailing spaces. Check it out.
Aware IM Support Team
MichaelQ
Posts: 122
Joined: Mon Aug 22, 2016 12:14 am
Location: UK

Re: How to prevent leading spaces being clipped?

Post by MichaelQ »

Thanks Jaymer.
I didn't understand what you meant by "Field2 is a type HTML". I couldn't find an HTML field type. So I just used a text attribute and added leading spaces using '  ' as you suggest, which worked!

Thanks Support.
I searched for 'TRIM' in the User Guide & Rule Language pdfs but couldn't find any reference to this function. Anyway Jaymer's solution worked.
Michael Q
Devon, UK
Jaymer
Posts: 2475
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to prevent leading spaces being clipped?

Post by Jaymer »

glad that worked

the HTML is an option for FORMAT on a Plain Text field. (see pic)
Screen Shot 2018-03-03 at 4.16.20 PM.png
Screen Shot 2018-03-03 at 4.16.20 PM.png (45.33 KiB) Viewed 16009 times
I was suggesting you'd have a rule to pad with the blanks. In this example, I just typed this in using the HTML formatter.

Here's how it would look in a Query
Screen Shot 2018-03-03 at 4.14.22 PM.png
Screen Shot 2018-03-03 at 4.14.22 PM.png (16.03 KiB) Viewed 16009 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2475
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to prevent leading spaces being clipped?

Post by Jaymer »

Here is whats stored in the database for the HTML field:
Screen Shot 2018-03-03 at 4.21.05 PM.png
Screen Shot 2018-03-03 at 4.21.05 PM.png (13.83 KiB) Viewed 16009 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
MichaelQ
Posts: 122
Joined: Mon Aug 22, 2016 12:14 am
Location: UK

Re: How to prevent leading spaces being clipped?

Post by MichaelQ »

Thank you.
This solution raises a question about programming elegance.

I am displaying a nested hierarchy by padding spaces using a 'TreeDepth' attribute which may be 0-9. Currently I have to write a rule for each level like this (each level is indented by 4 spaces):

If Item.TreeDepth=1 Then
Item.Name4Tree='    '+Item.Name

Is there a way that I could write one rule which will add the required number of spaces according to the TreeDepth?
Michael Q
Devon, UK
MichaelQ
Posts: 122
Joined: Mon Aug 22, 2016 12:14 am
Location: UK

Solved: How to prevent leading spaces being clipped?

Post by MichaelQ »

I figured out how to compose this action more concisely so that each level in the hierarchy is indented by an additional 6 spaces:

Item.Name4Tree=''
Item.Name4Tree=PAD_LEFT(Item.Name,' ',Item.TreeDepth*6+LENGTH(Item.Name))
Michael Q
Devon, UK
Post Reply