Page 1 of 1
Dictionary error for "lineOffset"
Posted: Mon Jan 27, 2025 11:22 pm
by dunbarx
The lineOffset function returns the line that contains a specified string. All well and good, I use it all the time.
But the dictionary says:
The value returned by the lineOffset function is the number of the line where lineToFind first appears in stringToSearch. If the lineToFind is not in stringToSearch, the lineOffset function returns zero. If the lineToFind spans more than one line, the lineOffset function always returns zero, even if the lineToFind appears in the stringToSearch.
May I assume the terms "lineToFind" and "stringToSearch" in the above are switched?
Craig
Re: Dictionary error for "lineOffset"
Posted: Tue Jan 28, 2025 8:56 am
by SparkOut
I think lineToFind is the needle and stringToSearch is the haystack.
So you can't search for
"Something I
want to get
the line number for" in the haystack, because it can't return a single line for a multiline needle.
Re: Dictionary error for "lineOffset"
Posted: Tue Jan 28, 2025 4:00 pm
by dunbarx
Sparkout.
I can see what you mean. But for me that is very odd phrasing and thinking.
craig
Re: Dictionary error for "lineOffset"
Posted: Tue Jan 28, 2025 6:04 pm
by Klaus
My "memory hook" for "Lineoffset" is: lineoffset(what,where)
So for me the dictionary entry is correct.
Re: Dictionary error for "lineOffset"
Posted: Tue Jan 28, 2025 7:50 pm
by dunbarx
Klaus.
My "memory hook" for "Lineoffset" is: lineoffset(what,where)
Exactly. "What" to be found in "Where". "What" is the stringToFind. "Where" is dataToSearch.
I read that as: lineOffset(stringToFind,dataToSearch). Because we are trying to locate the stringToFind in the dataToSearch. The function actually works that way. But the dictionary says the opposite, lineOffset(lineToFind, stringToSearch)
The dictionary says "... number of the line where lineToFind first appears in stringToSearch."
Really? We want to find the line we need to find in the LineToFind? And the string "seed" is stringToSearch? Should be "stringToSearchFor"?
We are not searching a body of text for lineToFind, we are searching for stringToSearch. We do not find it (our string to search) in stringToSearch, we find it (hopefully) in lineToFind.
I say it should read "... number of the line where stringToFind first appears in dataToSearch."
OK, OK, semantics all.
Craig
Re: Dictionary error for "lineOffset"
Posted: Tue Jan 28, 2025 9:26 pm
by SparkOut
Ah, yes it's more the ambiguity of the example variable names chosen for the function arguments in the dictionary, eg you are reading as stringToSearch[for] rather than stringToSearch[within]
The dictionary is indeed actually correct but could be clearer, without a doubt.