IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#30292 - 08/28/09 05:00 AM Count characters
Mario Offline
OL User

Registered: 05/06/08
Posts: 58
Loc: Holland
Is there a way to create a condition that counts the number of characters on a line.
So that when there are less than 20 the condition is true, above 21 its false.
Off course with trimmed spaces

Top
#30293 - 08/28/09 09:08 AM Re: Count characters
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
Mario,

You can use this condition:

Code:
=length(&variable) <= 20
The "variable" can be any string variable or value. If it's 20 characters or below, it will be true, otherwise it will be false.

Regards,
Rapha

Top
#30294 - 08/31/09 07:22 AM Re: Count characters
Mario Offline
OL User

Registered: 05/06/08
Posts: 58
Loc: Holland
Can i just copy this in the condition line on my data selection or how?

Top
#30295 - 08/31/09 09:28 AM Re: Count characters
Anonymous
Unregistered


You can either put it directly in the condition line of your data selection, or create a condition and add the condition itself to the data selection (this way if your condition changes, it'll be easier to find)

Eric.

Top
#30296 - 08/31/09 09:44 AM Re: Count characters
Mario Offline
OL User

Registered: 05/06/08
Posts: 58
Loc: Holland
I have some problems getting it work right.

I have a data selection on line 1,1,30.
If there are more than 20 charachters on this line the condition must become false.

How must i use this code you gave me?

if i copy this into my condition line it gives some errors.

Top
#30297 - 08/31/09 10:06 AM Re: Count characters
Anonymous
Unregistered


Mario,

Are the characters seperated by spaces? length() only work to check the total number of characters including spaces in a string. You can use either trim() or strip() to remove the spaces, depending on that data:
Code:
These will return 25 as a length:
length('A  B    C    D     E    F')
length('ABCDEF                   ')
.
However, these will return 6 as a length:
length(strip(' ', 'A  B    C    D     E    F'))
length(trim('ABCDEF                   '))
Assuming you've created a condition with type "advanced", paste one of the following in your "Advanced Condition" box:

Using TRIM:
=length(trim(@(1,1,30))) <= 20
OR using STRIP:
=length(strip(' ', @(1,1,30))) <= 20

Top
#30298 - 08/31/09 10:12 AM Re: Count characters
Mario Offline
OL User

Registered: 05/06/08
Posts: 58
Loc: Holland
Thanks those 2 rules (strip and Trim) are just what i was looking for!!

thank you!

Top