Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for proper embed point

Status
Not open for further replies.

A Brayshaw

Programmer
Dec 23, 2020
2
US
I am using Clarion 8.0. I have a form on which I have a browse list containing a list of PDF files which serves as a "pick list". One field on the form contains a choice from this browse list. I can use the BrowseReset method to position the browse list on the matching record (if a match exists), but I can only make this work by embedding the code in the Accepted embed point of a button control. I've set up the button merely to test the record positioning code - I don't really want to use a button.
What I would prefer to have happen is to have the proper record in the browse selected automatically once the window opens (i.e. using the code my test button currently executes), but have not been able to find the proper embed point to make this work. It seems it needs to be the step just before the window is ready for user interaction. I've experimented with more than a dozen possibilities with no luck.
Can anyone suggest the est embed point to accomplish this?
TIA
 
It sounds like what you are looking for is a Locator. That's behaviour already built into the browse. It sounds like you already have the field you want to use as the locator. Right click on the browse, choose actions and browse box behaviour. Click on the Locator Behaviour button (which will be greyed out if your browse does not have a sort order, but I assume you do). Change the locator type to Entry, and use the control you already have set up as the new locator control.

When you put a value in that field and press enter you will be placed on that item, or on the nearest item if it exists. You can prefill it on entering the window if you like.

 
Getting the browse set to a prefilled value is not obvious.

Towards the end of the window.init, put (replace the bits in angle brackets to suit) :
<BRW5::Sort0:Locator>.SetShadow('<your starting value>')
post(event:accepted,<?yourlocatorcontrol>)
 
Jon -
Thanks for your responses. Your idea almost worked for me :)
I hadn't set up a locator (more on that later), as I really wanted to get the browse list's record located without user intervention (hence my reference to having the record located "automatically").
But, I added a locator control to try your solution, but it only worked about 99% of the time. Every so often, it would "miss" the expected value by 1 position -- it would select the record above the expected one. Could not figure out why. Strange that it worked when it did.
But, your idea brought me to a solution that works ever time: I had written this code and put it on the Accepted embed point of a button, just for testing purposes:
PDF:FileName =RecVar:FileNameOnly)
If Access:pDFRecipeFiles.Fetch(PDF:ByFilename) = Level:Benign
BRW:pDFFileList.ResetFromBuffer
.
That works, but I didn't want to have to click that button every time the window opened. BUT, your solution reminded me about posting the accepted event to a control. So, at the end of the Init embed point, I added Post(Event:Accepted, ?Button:LocateFile), then hid the button control. Works like a charm.
Thanks again for your help. I hadn't ever used Tek-Tips before - glad to see there's still an active Clarion forum available.
Happy Holidays!
 
Not really active, I was just here by chance looking at something that someone else had referred to.

You're much more likely to get help on the newsgroups on the clarion server @ news.softvelocity.com,

or the other place that is active is Clarionhub:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top