How limit the number of characters maximum in a text field?

If you made a template for printing or HTML export, you can offer it to the others here. You can also ask here for help about these templates
Post Reply
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

How limit the number of characters maximum in a text field?

Post by RANICUAJO »

In the print template that I use (create with "designer"), I would like to limit the number of characters that can appear in each text field.
Exists some form to do it with "script option" when the field is created? :hum:
Image

Also I would like to know as a text can be put in vertical position :??:

Thanks :wow:
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Hi,
By vertical you mean rotated of 90/270°, or with letters like
T
E
X
T
?
in first case, you can chose the orientation of text blocks using a button of the toolbar. In second case it is not possible.

To limit the Length of a field, you can do the following:
Instead of having for example [Actors] in the text block, enter a new name, e.g. [shortActorsList]
Then check the "Script" option and enter the following in the bottom area:

Code: Select all

begin
  shortActorsList := Copy([Actors], 1, 50);
end;
To keep 50 characters starting at the 1st one.
Of course it may cut in the middle of a name...
You can add "(...)" at the end:

Code: Select all

begin
  shortActorsList := Copy([Actors], 1, 22) + '(...)';
end;
The report preview window of AMC may throw an error about a not found field when you refresh a template containing a script after having modified it, but it should work if you go to another template in the list then go back to your template.
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

Post by RANICUAJO »

antp wrote:Hi,
By vertical you mean rotated of 90/270°, or with letters like
T
E
X
T
?
in first case, you can chose the orientation of text blocks using a button of the toolbar. In second case it is not possible.
Hi
Finally i see the button :ha: I was thinking in the easy mode (rotate 90/270) but my eyes don´t see very well :badidea:

To limit the Length of a field, you can do the following:
Instead of having for example [Actors] in the text block, enter a new name, e.g. [shortActorsList]
Then check the "Script" option and enter the following in the bottom area:

Code: Select all

begin
  shortActorsList := Copy([Actors], 1, 50);
end;
To keep 50 characters starting at the 1st one.
Of course it may cut in the middle of a name...
antp wrote: You can add "(...)" at the end:

Code: Select all

begin
  shortActorsList := Copy([Actors], 1, 22) + '(...)';
end;
Really you are in thel ine, but I have tried the 2 options (2ª is really better), but it use same "actors" data for all the films
(you will understand better in the image), and i have and error message when i try to print in a PDF "undefined symbol "actors"

Thanks for your help Antp :grinking:

Image
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I do not know why it does not work.
This script things often has a quite random behavior. Sometimes it works, sometimes not.
It is a ready-to-use component that I integrated in AMC, so I do not know what causes that. Someday I should find why such errors occurs.
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

Post by RANICUAJO »

I do not understand either so that it does not work, but don't worry too much antp.
Thanks again for your help and your patience :grinking:
Bye :wink:
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

Post by RANICUAJO »

Hi antp
I have a partial solution.
I have created a new variable in the “variable editor” with the following expression


Image
The variable it initially stored in the group of "movie fields"

This is the result

Image

The print report work properly all time,. but the problem now is that when I open designer again, non encounter the new variable that I have created with object to edit it :??:

Where is stored the new variables? :??:
Bye :grinking:
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I didn't even know that it was possible to add variables like that :lol:
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

Post by RANICUAJO »

antp wrote:I didn't even know that it was possible to add variables like that :lol:
I hope that it can serve to you for something. New things are always discovered. I found it by chance, and knew that to put, thanks to the data that you gIve me. :D



I have a new question. :ha:
in a simple field of text (non variable for the moment :??: ...) for example “actors list” is possible to do that:
If “actors” lenght >0 then insert the text “actor list”
If “actors” lenght =0 then don't insert the text “actor lists”
When "actors" is the variable originated in AMC?

Thanks again
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

But if the text length is 0 there is nothing to insert, so the result will be the same, no ? :??:
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

Post by RANICUAJO »

I'm thinkin in the label before the AMC information.

Image

Sorry for my bad english. It is so difficult to make understand me :ha: :ha: :ha:
I hope you understand the image.

Bye :grinking:
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

ok ;)
in the Script box of these text blocks, you can try to enter this:

Code: Select all

begin
  Visible := [Actors] <> '';
end;
RANICUAJO
Posts: 33
Joined: 2006-12-03 11:01:14

Post by RANICUAJO »

Script really works fine. :)
A million of thanks antp :grinking: :grinking: :grinking:
Post Reply