Page 1 of 1

how to get to the top of a table field

Posted: Wed Jul 11, 2018 7:22 pm
by THOLIEN
This should be a very simple thing to do but ...
I have a small table field on a card that contains 10 rows and 11 columns.
My script finds a line in the table and uses the information from the line to calculate a bunch of stuff.
The next time I run the script the find does not find the thing that I knowe is in the table.
In the API dictionary I found this little tidbit:
"The find command starts searching after the previously-found text (if there was a previous find command)"
I want to start from the top of the list every time I use the find command.
What is the best way of doing that?

Re: how to get to the top of a table field

Posted: Wed Jul 11, 2018 7:25 pm
by Klaus
Hi THOLIEN,

do not use FIND but lineoffset() or something!
What did you script so far?


Best

Klaus

Re: how to get to the top of a table field

Posted: Wed Jul 11, 2018 7:56 pm
by THOLIEN
It's too bad the find command gets no love.

FIND was there before I started on this script.
After a few trials and errors lineOffset looks like it is going to work.

Thanks.

Re: how to get to the top of a table field

Posted: Wed Jul 11, 2018 9:04 pm
by dunbarx
Hi.

"Find" is a little odd in that, if after a successful find the little block is drawn around the foundText, and you try to find something again, it will often (not always) simply erase that box and stare at you.

Here is a little demo. Make a button near your table field. Put this in its script:

Code: Select all

on mouseUp
   find string any char of "abcdfsert" in fld "yourTableField"
   wait 10
   find ""
end mouseUp
Assuming those chars live somewhere in your table field, hit the button a few times. Always works. But this begs the issue above.

Craig

Re: how to get to the top of a table field

Posted: Wed Jul 11, 2018 11:15 pm
by dunbarx
Do not dismiss "find" just yet.

Invariably, one collects information about a successful find immediately, using the foundChunk, foundLine or foundWhatever. In that way, it is not important that the "foundBox" might foul up successive manual find operations. In other words, if any of the above functions are used for whatever purpose, it is perfectly reasonable and straightforward to, say:

Code: Select all

on mouseUp
   repeat 10
   find string any char of "abcdfsert" in fld "xx"
   put the foundChunk & return after temp
   --processAway
   find ""
end repeat
answer temp
end mouseUp
This happens in an instant, and all is well.

Craig

Re: how to get to the top of a table field

Posted: Wed Jul 11, 2018 11:41 pm
by dunbarx
It appears I have not used "Find" in quite a while, though I used to.

After a little testing, each instance of a string is found during successive manual finds, but once the last one is found, the next attempt will fail. If one tries after that, the whole thing starts over, working just fine, until the inevitable failure.

It is almost as if a "find empty" took place, which resets the find sequence.

I don't see where it says either that "Find" does not start over from the beginning after finding the last instance, or that it just doesn't work for one time if it has already found that last instance.

Is it worth a report to QCC?

Craig

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 5:20 pm
by jacque
It's not a bug, it's by design. If you check the result you'll see that the find command reports "not found" after the last successful search. That's how you know you've found every instance. Then it resets.

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 6:00 pm
by dunbarx
OK.

So this is different than if one finds successive text on different cards in a stack, where LC (and HC before it) will cycle back to the start after text was found on the lastmost card, ad infinitum.

Craig

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 6:34 pm
by jacque
In LC the final result should be the same "not found", regardless of the navigation.

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 6:47 pm
by dunbarx
Jacque.

It never happens. The process goes back to the beginning and continues...

It works differently than finding text limited to a designated field.

Craig

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 8:52 pm
by THOLIEN
I'm totally fine with the way it works, but I would like to be able to start searching from the top of the list if I want to. I was deceived and glad I found this before I released the product to users.

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 9:58 pm
by jacque
It never happens. The process goes back to the beginning and continues...

It works differently than finding text limited to a designated field.
So it does. I don't think it always did that.
I would like to be able to start searching from the top of the list
For that case, use this:

Code: Select all

find empty
find <whatever>

Re: how to get to the top of a table field

Posted: Thu Jul 12, 2018 10:31 pm
by dunbarx
Tholien.

What Jacque said, and if you look through the thread, you will see why. Remember what you read in the dictionary. "Find Empty" resets the find "queue". Once that happens, all subsequent finds start from the beginning.

Craig