` Printed Icetips Article

Icetips Article



Par2: Locator without a key
2001-12-07 -- Dennis Evans
 
> I'm having trouble getting a locator to work on an unkeyed browse tab.

> So, I created another tab with no key using the Addition Sort Field for
> LastName,FirstName and I hid the default tabs created by the browse
wizard.


     Well this does require several years of study and research to achieve
the correct level of ABC zenness, once you get to the correct level of
zenny, you will simply will the correct record to be found.

   Since your clients are not interested in waiting several years here is
the quick solution,

  add the fields you want to locate on to the screen or allow the user to
enter the values.

  in the accepted embed for the fields,  this assumes you want to locate a
last name

  Pre:FileField = 'entered last name'
  BrwX.ResetFromBuffer()
  select(?ListControlName)

  now if you want to locate the first name,

  Pre:FielLastName = 'entered last name'
  Pre:FileFirstName = 'entered first name'
  BrwX.ResetFromBuffer()

    in the BrowseClass, Reset method, the one with the (BYTE Locate)
parameter,
before the parent call.

  if (choice(?CurrentTab) = X
     if 'entered first name and entered last name'
         Locate += 1
     end
  end

  Adjust the value of locate for the number of fields in the sort order.

Later:
> I made an entry field for user input corresponding to the last name field,
> PRE:LNAME.  So, should this embed read PRE:LNAME = PRE:LNAME ?  (Doesn't
really seem intuitively right to me.)

     If you are using the actual field from the file, skip this step.  I
normally use a local variable for locator input and call a window to enter
the values.   The local is passed as a parameter.  Advantage,   in the near
future your client is going to want to change the sort order and have a
locator for the changed order.   Using locals makes this much simpler.

> In the embed tree, is this the correct embed?:
> LocalObjects->Abc Objects->
> Browse on TblName using ?Browse:1(BrowseClass) ->
> Reset PROCEDURE(BYTE Locate),VIRTUAL

   Yes.

> >   if (choice(?CurrentTab) = X
> >      if 'entered first name and entered last name'
> Given my first question above, how should this IF condition be written
> (explicitly)?
> >          Locate += 1
> >      end
> >   end

   Another advantage to using a local to enter the values.

   if (Loc:FirstName)
      Locate += 1
   end

     If the local first name primed then the user wants one of two things,
Locate one first name using current last name, the last name will contain
the value currently displayed.    So if your data set contains 200 plus
Smiths, the user can locate Hank, Smith without entering the last name.  If
they entered both names, then that will work also.



Printed November 21, 2024, 11:27 am
This article has been viewed/printed 35213 times.