need to stop "stxt" and "kstylstyl" from appearing in lists

Thanks to Nigel for his help with my previous post, but my post actually got clipped, so the problem wasn’t there…

I can get a list to save to disk, but when I put items in a list through variables and not with “quotes” I get entries like “kstylstyl” and “stxt” in the list which throws off the referencing to list items.

What are these things? And how can I simply get them to go away?


What you’re probably getting is a glimpse of how more complex data is often stored, Mark. This kind of thing can be reproduced by trying something bizarre (not that I ever do) like this:

{{t:"t" as Unicode text as string}} as string

--> "dle2TEXTfusrflistRTEXTtSTXT8ktxtTEXTtkstystyl"

(Actually, while the above result might look like that returned from such a contortion, I cleaned it up to avoid potential problems displaying it here. In reality, these codes also contain a bunch of non-printing characters - normally representing numerical data used to parse the code.)

However, interesting though all that might be, it doesn’t explain why you’re experiencing the issues you are. Truth is, it’s hard to say without a better indication of what you’re actually doing. Could you possibly extract a snippet or two of code (covering both the write and read operations) so that we can replicate the behaviour - and thus get a better handle on what might be going on?

And not easy to clean up, either - if you try to copy it into TextEdit or BBEdit, you see almost none of it unless in BBEdit, you fiddle with the encoding.

Yeah - the lower part of the ASCII range includes characters that might, in certain circumstances, be taken to mean something else (null, end of text, backspace, line feed, vertical tab, form feed, cancel, escape, etc.)

They’re usually a lot easier to clean out immediately:

set t to ""
repeat with c in {{t:"t" as Unicode text as string}} as string
	if (ASCII number c) > 31 then set t to t & c
end repeat
--> "dle2TEXTfusrflistRTEXTtSTXT8ktxtTEXTtkstystyl"

Thanks to Kai et al,

I thought the crazy list was causing another problem, turned out it was something else, so I can just leave the lists crazy!


This shows what they are - lots of nulls in there:

set t to {}
repeat with c in {{t:"KAI" as Unicode text as string}} as string
	tell (ASCII number c)
		if it > 31 then
			set end of t to contents of c
			set end of t to it
		end if
	end tell
end repeat

--> {"d", "l", "e", "2", 0, 0, 0, 0, "T", "E", "X", "T", 0, 0, 0, "h", 0, 0, 0, 1, 0, 0, 0, 0, "u", "s", "r", "f", "l", "i", "s", "t", 0, 0, 0, "T", 0, 0, 0, 2, 0, 0, 0, 0, "T", "E", "X", "T", 0, 0, 0, 1, "t", 0, "S", "T", "X", "T", 0, 0, 0, ":", 0, 0, 0, 2, 0, 0, 0, 0, "k", "t", "x", "t", "T", "E", "X", "T", 0, 0, 0, 3, "K", "A", "I", 0, "k", "s", "t", "y", "s", "t", "y", "l", 0, 0, 0, 22, 0, 1, 0, 0, 0, 0, 0, 16, 0, 14, 0, 3, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0}

I once wrote a routine that parsed this kind of data quite well. Can’t lay my hands on it at the moment - and data structures have changed a bit since then, anyway. I’ve just cobbled together a draft replacement (currently a bit too rough to post here) that returns the data like this:

From this, you can see some of the patterns and numerical values to which I referred earlier. Take, for example, the above “TEXT” entries, each of which is followed immediately by a value. After the first occurrence, you’ll see a value of 104 (derived in part from the ASCII value of “h”). This indicates that there are 104 characters remaining before the end of the entire string. The value after the second “TEXT” is 1 - denoting the length of the subsequent string, “t”. The third occurrence is followed by a 3 - this time indicating a string of 3 characters, “KAI” (whatever that means).

Of course, it’s a bit more complicated than that, and this may not be the time or place to go into more detail - but it should at least demonstrate some of the logic behind what might otherwise appear to be total gobbledygook. :wink: