jacque wrote: ↑Mon Feb 08, 2021 11:58 pm
I concede this is confusing at first. Both examples include a reference to a field. There are quotes around the stack path in the first example because all URLs need to be quoted (or put into a variable) since a slash is the division operator.
Without the quotes,
which force a string evaluation, LC may try to do division on the text and would throw an error.
This is exactly the problem I'm having understanding how to tell what you should be getting back. I was told the selectedLine returns a quoted value, so you can not just say, for instance,
and get the actual word (chunk) the selectedLine points out. Instead, if you use that code, you will get "of", which is what is in the text returned from the function.
I actually *did* expect the chunk to be returned from that statement, but it isn't, and as you point out in a few lines, you *do* get the chunks from other versions of selected such as the selectedText or the selection.
I haven't tested either of those yet (but will this morning) because I don't believe it will work in this situation. Here is the goal I am trying to achieve (and have already solved in a completely different manner by shunning things I obviously have a miserable ability to understand).
1. you have a field someone is typing in, which contains the caret.
2. you want to check if the word previous to the caret is part of one of several groups of words while the person typing is still typing.
If the selectedLine worked as I expected it too, this would be childs play. I should add, btw, it was still childs play the way I finally arrived at, but, not quite as simple.
That aside, both examples reference a field and should behave the same way.
"Line 3 of fld 1" is the same as
Code: Select all
line 3 of fld id 1003 of group id 1008 of card id 1002 of stack "/home/bogs/LC-Projects..."
Long field references and short ones behave the same, assuming there's a field 1 on the current card.
But I don't think this addresses your real question.
Well, that (in bold) is the problem, really. If I looked in the debugger returns, and saw the selectedLine return (in quotes) "line 3 of field 1", I would immediately have known I would need to put "the value of " or similar to get what it is supposedly pointing too. Instead, all you see is
line 3 of field 1
in the debugger, which looks just exactly as it would if you typed it out yourself long hand in code. Why would you not expect to be able to use it as a short cut to typing it out long hand? I dunno, to me it seems a loss.
The selectedText does not work this way, you get whatever is selected returned, in other words, you get the chunk expression. This is what I expected to see from the selectedLine, the chunk expression, i.e. the last word of the selectedLine, not the last word of what is returned from issuing the command.
You might still wonder how you'd know. I think basically you need to look in the dictionary to see if the function returns a descriptive (chunk) expression or not.
I did, and it says in there that the selectedLine returns a chunk as you point out, which is what I would have thought (at least, what I think based on reading the description of chunks
here, or even in the glossary), but it does not in fact return a chunk unless you modify it with a pre-qualifier or descriptor, or unless you use specific items of the return such as writing it like this
put the last word of
line (word 2 of the
selectedLine) of field "this field"
which seems really redundant to me, as the selectedLine has all the information you already need returned but in an unusable format for direct manipulation, none of which you need for the selectedText, for instance, which returns the actual selected text, which is what I would have expected it to do.
Like I said earlier, I probably just expect WAY too much.