I didn't know commas were letters

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: I didn't know commas were letters

Post by stam » Thu May 15, 2025 1:46 pm

“Beginner” in this specific instance refers to knowing how to ask a question that will give you the answer you want.

It is not related to how knowledgeable you are, but it is a general developer trait; a key skill is to know how to ask the right question.

The sheer number of posts you’ve made n this forum would suggest you should know better. It’s not about how much you know than I do or vice versa. It’s a basic skill.

Why should I bother answering your question when you then just turn around and state something like yeah but that won’t brew my coffee to my liking (meaning something completely irrelevant to the question asked), instead of actually thanking people taking an interest in your problem and then developing the discussion to the direction you need?

Like I stated before, conversing with you is an exercise in futility and I’ll desist now. Best of luck.
Last edited by stam on Thu May 15, 2025 2:01 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: I didn't know commas were letters

Post by richmond62 » Thu May 15, 2025 1:51 pm

a key skill is to know how to ask the right question.
Well, as Ludwig Wittgenstein pointed out, not many people seem to know how to ask questions.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I didn't know commas were letters

Post by dunbarx » Thu May 15, 2025 1:55 pm

Richmond.

I too find it hard to follow many of your threads. And I know you are a serious person.

Anyway, since you and I are both old-fashioned, at least as concerns this language, it is a shame that the filter command does not deal with words. If it did, you could simply:

Code: Select all

filter words of yourText without "|*"
WildCards are regex "light".

Craig

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: I didn't know commas were letters

Post by stam » Thu May 15, 2025 2:15 pm

Yes, but that’s is not what Richmond wants apparently, even after his explicit explanations what he wanted:
richmond62 wrote:
Thu May 15, 2025 12:28 pm
Yes, it will, but it will not allow you to perform further operations on those words.
Using regex with matchChunk gets the offset of a pattern match.
I had written a function that returns the start and end char number of a match, as well as the matched string for all occurrences of a pattern within a string and posted in my regex primer.

This is a workaround for the lack of global matches in PCRE regex, which is the flavour of regex available in LiveCode. You can find the function here:
https://github.com/stam66/regexPrimerFo ... workaround

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 106
Joined: Thu Jun 07, 2007 1:30 am

Re: I didn't know commas were letters

Post by tetsuo29 » Thu May 15, 2025 3:56 pm

When your item delimiter is a space, and your loop gets to "cheese|pickle," that is a word.

When you put "cheese|pickle," into DIX and then set the item delimiter to "|" then, item 1 of DIX is "cheese" and item 2 of DIX is "pickle,".

You're choosing to just put item 1 of DIX into DUX so DUX just is "cheese".

This ("cheese") is the only part of DIX that you are placing into field 2.

How is the comma supposed to be passed to field 2? It's not part of anything that you are preserving and passing.

Were you expecting the comma to be treated as its own word? Like you were thinking that when the loop got to "cheese|pickle," that that word would only be "cheese|pickle" and that the comma would get picked up as a word on the next iteration of your loop?

Test my theory and see what item 2 of DIX is when "cheese|pickle," is encountered.

If item 2 of DIX has trailing characters that need to be preserved then you will want to find a way to identify them and concatenate them onto DUX when adding more text to field 2.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: I didn't know commas were letters

Post by richmond62 » Thu May 15, 2025 4:01 pm

I am NOT expecting the comma to be treated either as a word or part of a word, I am expecting it to be treated as punctuation: obviously the term word is unable to distinguish that.

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 106
Joined: Thu Jun 07, 2007 1:30 am

Re: I didn't know commas were letters

Post by tetsuo29 » Thu May 15, 2025 7:35 pm

richmond62 wrote:
Thu May 15, 2025 4:01 pm
I am NOT expecting the comma to be treated either as a word or part of a word, I am expecting it to be treated as punctuation: obviously the term word is unable to distinguish that.
If it's not a word or a part of a word how is it supposed to magically be transported into field 2? Nothing goes to field 2 without an instruction to put it there, right? Your code only moves words or items to field 2 or did I miss something?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: I didn't know commas were letters

Post by FourthWorld » Thu May 15, 2025 11:04 pm

richmond62 wrote:
Thu May 15, 2025 4:01 pm
I am NOT expecting the comma to be treated either as a word or part of a word, I am expecting it to be treated as punctuation: obviously the term word is unable to distinguish that.
HyperCard got a lot of things right. Its novel redefinition of "word" isn't among them.

I have no reason to mislead you in suggesting trueWord when you want to parse true words. Try it where using "word" doesn't do what you want and see if the outcome improves.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I didn't know commas were letters

Post by dunbarx » Mon May 19, 2025 4:29 pm

@Richmond.

Did you understand what Richard was suggesting to you?

The number of words in

Code: Select all

aa bb , cc, dd
is 5 whereas number of trueWords is 4.

Won't "trueWords" allow you to parse out commas in your text? It "undoes" the old HC definition of what a word is, in terms of what you consider "punctuation".

@ Richard. I dunno, I do not see the issue with

Code: Select all

 aa, bb, cc
being three words, that is, space is the word delimiter, period. I did always dislike the fact that HC decided that text within parentheses defined words in its own way,

Code: Select all

"aa, bb , cc"
being one word. I thought that was utterly unnecessary and worse, confusing.

Craig
Last edited by dunbarx on Mon May 19, 2025 4:42 pm, edited 3 times in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I didn't know commas were letters

Post by dunbarx » Mon May 19, 2025 4:36 pm

Richmond.
I am NOT expecting the comma to be treated either as a word or part of a word, I am expecting it to be treated as punctuation: obviously the term word is unable to distinguish that.
So you are saying that LC needs to distinguish "punctuation" (the comma in particular?) in some new and different way, that is, not just a character. I mean, I think, it would be a new chunk type.

OK, but why? Where does this cause any additional effort or unwanted confusion? Where would that new state of affairs be useful, or streamline what we already have?

And why stop at the comma? How about the colon or semicolon? But again, where does this either slow us down or confuse us? Think it the other way, can you give an example how it might be of real value?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: I didn't know commas were letters

Post by FourthWorld » Mon May 19, 2025 5:35 pm

dunbarx wrote:
Mon May 19, 2025 4:29 pm
@ Richard. I dunno, I do not see the issue with

Code: Select all

 aa, bb, cc
being three words, that is, space is the word delimiter, period.
Something that offers a space delimiter is useful, and "word" has a feature the standard item delimiter doesn't, in not counting multiple delimiters as delimiting empty chunks.

Useful, but not how we use "word" in any context outside of xTalk.

In natural language words are considered distinct from punctuation.

The redefinition of "word" by the HyperCard team then goes further to define multiple words within double quotes as a single word, which is also useful yet also not how "word" is defined in any natural language.

Learnability is aided by using novel terms to describe novel concepts.

Richmond is not new to xTalk, but as a linguist and a common speaker it isn't surprising that the unusual definition of "word" in xTalk remains a source of confusion.

I suppose spaceDelimitedNoveltySometimesUsefulForCertainParsingTasks might have been a bit much. But if I had been in the room when the behavior of "word" was defined I might have argued as strongly for using a novel term to describe a novel concept almost as strongly as I would have advised against the "sometimes rule" of allowing some function calls to be made with property syntax. 😁

But many human artifacts are accidents of history, and that this is one more is certainly not the worst cognitive challenge our species has faced.

And with the relatively recent addition of "trueWord", at last we have a chunk type that works in LC as words work in the rest of the world.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I didn't know commas were letters

Post by dunbarx » Mon May 19, 2025 8:51 pm

Richard.

Ah, pointing out the "specialNess" of the word delimiter, space, is timely. I haven't thought about this in decades. It is special in just the way you said, a string of spaces of arbitrary length is a countable string of chars, but only one delimiter. I assume that construct is deeply buried in the engine, which is why a brand new chunk, the "trueWord" was required to amend that issue.

Richmond?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: I didn't know commas were letters

Post by FourthWorld » Mon May 19, 2025 11:59 pm

dunbarx wrote:
Mon May 19, 2025 8:51 pm
Ah, pointing out the "specialNess" of the word delimiter, space, is timely. I haven't thought about this in decades. It is special in just the way you said, a string of spaces of arbitrary length is a countable string of chars, but only one delimiter. I assume that construct is deeply buried in the engine, which is why a brand new chunk, the "trueWord" was required to amend that issue.
The trueWord chunk type also supports that useful feature of words, tho in a way more conformant with normal definitions of "word".

Where trueWord differs is counting only actual words. It doesn't include punctuation as part of a word, and it doesn't treat multiple words between double quotes as a single word.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: I didn't know commas were letters

Post by richmond62 » Tue May 20, 2025 8:03 am

My 'problem' with trueWord is that if I throw 'cheese|smelly' at it it splits that up into 2 words when for my needs I need to treat it as a 2 item thing with '|' as the itemDelimiter.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: I didn't know commas were letters

Post by dunbarx » Tue May 20, 2025 2:10 pm

Richmond.

That is the way "trueWords" works. But I do not understand what you said:
... when for my needs I need to treat it as a 2 item thing with '|' as the itemDelimiter.
What about simply:

Code: Select all

set the itemDel to "|"
answer item 1 of "cheese|smelly" & return & item 2 of "cheese|smelly"
You are out of the word world and into the item world. That should obviate all issues, since the itemDel rules.

Craig

Post Reply