Re: How to tell what a function is returning
Posted: 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.
That aside, both examples reference a field and should behave the same way. "Line 3 of fld 1" is the same as
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. "The selectedLine" returns a chunk expression -- i.e., text -- and any operations on it will use the text in that chunk expression. This is a common way to identify which line or which field is selected, though there are specific functions for that. "The mouseloc" returns two integers, but since everything under the hood is really text, you could treat it that way and "get item 1 of the mouseloc". Some functions are specific in what they return so you don't have to parse them yourself. Check the differences between clickChunk and clickText.
This is true of selectedLine as well. If you want the actual text, you can either include the "text of" or you can use a specific function that does it for you: either "the selection" or "the selectedText".
Or for mouseLoc (item 1 of the mouseLoc, item 2 of the mouseLoc):
For fields (word 4 of the selectedLine):
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.
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..."But I don't think this addresses your real question. "The selectedLine" returns a chunk expression -- i.e., text -- and any operations on it will use the text in that chunk expression. This is a common way to identify which line or which field is selected, though there are specific functions for that. "The mouseloc" returns two integers, but since everything under the hood is really text, you could treat it that way and "get item 1 of the mouseloc". Some functions are specific in what they return so you don't have to parse them yourself. Check the differences between clickChunk and clickText.
This is true of selectedLine as well. If you want the actual text, you can either include the "text of" or you can use a specific function that does it for you: either "the selection" or "the selectedText".
Code: Select all
put the selection
put the selectedTextCode: Select all
the mouseH
the mouseVCode: Select all
the selectedField