I know I have code where I did this somewhere but can't find it...  But it's 
tricky
if you want to split the text at a space.  I think I did something like this 
(assumes
a length of 20 chars);

SET VAR vText = 'Let us type in a full sentence that will split at 20 
characters'

-- a While loop would start here
SET VAR vText1 = (SGET(.vText, 20, 1))
-- the above will get you: Let us type in a ful
SET VAR vCount = (SLOCP(.vText1, ' ',-1))
-- the above uses SLOCP with a -1 parameter, which will find the LAST 
occurrence of a space
-- this gives us a value of 17
SET VAR vTextLine1 = (SGEt(.vText, .vCount, 1))
-- the above will get you: Let us type in a 

You then reset vText for what's "remaining"
SET VAR vText = (SGET(.vText, 1000, (.vCount+1) ))

 
I know I did this in a loop, with a test for when SLEN(.vText) is <= 20 and 
that would
be your last line.

I think that's how I did it....

Karen


 

-----Original Message-----
From: dkfowler6179 <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Thu, Feb 12, 2015 7:16 pm
Subject: [RBASE-L] - Re: Counting characters


That looks like it is just what I need.  

Thanks for the help!
David Fowler

Sent from my android device.

-----Original Message-----
From: "A. Razzak Memon" <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Thu, 12 Feb 2015 8:08 PM
Subject: [RBASE-L] - Re: Counting characters


At 07:44 PM 2/12/2015, [email protected] wrote:

>Is there a way to count the characters within a text variable?  Or 
>better yet,
>is there a way to have R:Mail split an email after a set number of 
>characters?
>Using R:Mail with most recent version of R:Base 9.5 (32) to send 
>emails to text
>and need to limit each one to stay within character limits of 
>wireless carriers.


David,

The R:BASE (SLEN(.varname)) is the typical function to count characters.

-- Example 01
    SET VAR vText TEXT = 'The Next BIG Version of R:BASE!'
    SET VAR vLength INTEGER = (SLEN(.vText))
    The resulting value should be 31

-- Example 02
    SET VAR vText TEXT = 'The Next BIG News for R:BASE Technologies, Inc.'
    SET VAR vLength INTEGER = (SLEN(.vText))
    The resulting value should be 47

Keeping that simple exercise in mind, you should be able to implement such
logic in your specific circumstances.

Once you know the exact length of a given TEXT/NOTE/VARCHAR string, you may
use the (SGET(text,nchar,pos)) function to split the text string, if you wish.

For more details and examples:

HELP SLEN
HELP SGET

Very Best R:egards,

Razzak.



Reply via email to