dunbarx wrote: ↑Thu Jan 31, 2019 3:16 am
Klaus' array is compact and modern.
But in more basic LC-ese you might think of inserting an unprintable character at the break point. Then you can use the itemDelimiter to separate the text. So if you had a large body of text in a variable "longText", you could:
Code: Select all
on mouseUp
set the itemDel to numToChar(202) --my favorite
put trunc(the length of longText / 2) into tMiddle -- about the middle of any string
put numToChar(202) after char tMiddle of longText
put item 1 of longText into firstPortion --about half the string
put item 2 of longText into secondPortion --the other half
--do whatever here with your two halves
end mouseUp
Reassembling is straightForward. And when you separate longText using an item, the item itself is not included in either portion of the resulting two strings. Note that you do not NEED to use an unprintable character, anything above 127 might do, but strange extended ASCII chars to oftentimes work themselves into text.
I mention all this because I think it is important to play with LC string functionality at a low level; it helps with the fancier stuff later on.
Craig Newman
You might want a non type-able non displaying character in something like that, like null.
Lc Dictionary wrote:
null
Type: constant
See Also: space Constant, constant Command
Introduced: 2.0
Platforms: Desktop, Server, Web and Mobile
Summary:
Equivalent to the null character (ASCII zero).
Examples:
read from file modem: until null
Use the null constant as an easier-to-read substitute for numToChar(0).
Comments:
The null constant is needed because you can't type the character it represents in a script.
I love null from the days where I wrote batch scripts in dos, because I often used your favorite ctn(202) as part of the *display design. I also think it is what csv files should have used (cnv?)
@Kaveh,
You can find a chart of all ascii text in any search, like this
result.
In this case, ASCII code 202 = ╩ ( Box drawing character double line horizontal and up )
*Display design - before real gui desktops, it was all crafted at the CLI