%string limited to only 50 characters?

286 views
Skip to first unread message

Jim Dolson

unread,
Sep 22, 2008, 1:51:33 PM9/22/08
to ensemble-in...@googlegroups.com
Hi all.

We have a business operation that creates a flat-file given data obtained from an inbound TCPIP business service.

The fields in the delimited flat-file are defined as %string.

Everything works fine as long as each field contains no more than 50 characters.  It appears that a %string is defined as alphanumerics with a length of 50 characters or less.  So what do we call an alphanumeric of 51 characters?

I really don't want to redefine %string to accept longer widths since that is base code and who knows where else %string is used.

I had hoped there was a more generic type such as %text or %varchar or %longstring or %memo but none found.

Does anyone know if there is an easy way to support strings > 50 characters?   Do I have to define my own string type to support strings > 50 characters?

Thanks,

Jim Dolson
Laconic Designs

Jim Dolson

unread,
Sep 22, 2008, 2:36:33 PM9/22/08
to ensemble-in...@googlegroups.com
 
Joel Cooper provided the answer off-list:
 
 ///
Class HH.LongString Extends %Library.String
{

/// The maximum number of characters the string can contain.
Parameter MAXLEN As INTEGER = 255;

}
 
Jim Dolson
Holland Hospital
Holland, MI

Michael Hall

unread,
Sep 22, 2008, 2:40:48 PM9/22/08
to Ensemble-in...@googlegroups.com

When you define the properties in the Caché Class use the parameter MAXLEN=length where length is the string length.  It will look like this:

 

Property Test as %String [MAXLEN=100]

 

Hope this helps

 

Mike Hall


Michael Hall

unread,
Sep 22, 2008, 2:43:49 PM9/22/08
to Ensemble-in...@googlegroups.com

Sorry,

 

Parens not Square Brackets

 

Property Test as %String (MAXLEN=100)

 

Hope this helps

 

Mike Hall


From: Ensemble-in...@googlegroups.com [mailto:Ensemble-in...@googlegroups.com] On Behalf Of Jim Dolson
Sent: Monday, September 22, 2008 10:52 AM
To: ensemble-in...@googlegroups.com
Subject: [InterSystems-EnsHlth] %string limited to only 50 characters?

 

Hi all.

Jill Goldberg

unread,
Sep 22, 2008, 2:58:21 PM9/22/08
to Ensemble-in...@googlegroups.com
And just to clarify a bit more...

The default value for the MAXLEN parameter is 50, which is why you were getting errors when your string exceeded 50 characters.  One way to see this is to use the Inspector window in Studio.  From Studio, open your class and go to the Insepctor window (View>Inspector or Alt-1 will hide/show the inspector window). Select “Property” from the drop-down and then double-click on the property of interest.  If you scroll down to “Parameter”, you’ll see all the parameters defined for that data type.  Then you’ll see 50 as the default value for MAXLEN.  As Mike stated you may set it to any value less than 32K (assuming long strings are not enabled).  

The MAXLEN value is used during validation, so you may also enter an empty string (“”) as the value.  This does no validation on the string, so your property could be a string up to 32K, at which point you’ll run into other problems.  Note that the 32K boundary is in effect if long strings are not enabled (the default setting).

--Jill

Jill Goldberg
InterSystems Corporation
Jill.G...@intersystems.com
617.551.2168

David Loveluck

unread,
Sep 22, 2008, 8:45:57 PM9/22/08
to Ensemble-in...@googlegroups.com

Jim

 

This is a valid suggestion but the simpler approach of adding a parameter (MAXLEN=255) to the property definition would be simpler if there is no other reason to define a custom data type.

 

dave

 

 

David Loveluck

617 225 3122


Reply all
Reply to author
Forward
0 new messages