Alpha Video Training
Results 1 to 8 of 8

Thread: Topparent.find(vGoToRecord) only accepts numeric values?

  1. #1
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Topparent.find(vGoToRecord) only accepts numeric values?

    I posted this question on another v9 thread I had found earlier. (no response)

    http://msgboard.alphasoftware.com/al...l=1#post597286

    Ironically, for the FORM.find() function/method to work, it seems that you have to pass this function a numeric value by using eval() even when the record you're looking for is indexed, auto-incremented, and designated as type C. ex: "00101" versus 101 - Where in effect you have to send the numeric value 101 to find record "00101" in order for FORM.find() to work.

    It appears that the FORM.find() method presumably searches all indexed fields, which is presumably both risky and inefficient/slow to use. And in doing so, it somehow magically converts all indexes to a numeric field type prior to searching for a match..... Actually, I wonder whether all .dbf indexes are somehow internally stored as numeric values (regardless of actual field type), which could explain why FORM.find(vGoToRecord) needs to be passed a numeric variable??????

    Is there a better function that allows you to explicitly specify the indexed field (in a form based on a set) you're trying to search.....
    (IE: lookup button on an invoice ~ I've found workarounds, but no single line function that can do this.)


    This is what I'm looking for. (It's obviously "pseudo-pseudo code", and won't work): topparent.find_by_key(key_name,key_type,key_value)???


    Maybe this is one of those situations where writing a function and storing it in the code library is the only solution....


    FUNCTION = apply a filter (query) based on an xdialog lookup, and then issue a FORM.show_all() after record is found, so all records in the form are still navigable.) ~ pseudo code: query one record and go to it, then remove all filters (query) without navigating off the record....
    Last edited by SNusa; 01-31-2012 at 08:42 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    Robert, I believe one can do a find by key with character string arguments. However, the sort sequence of the form must be set appropriately beforehand. The form level find by key method uses the current sort sequence of the form and expects the search key that's passed to the function to have the same data type as the field controlling the sort sequence of the form. If the form is sorted on a numeric field, a numeric data type is expected. If the form is sorted on a character field a character data type is expected.

    Take a look at this page from the helps.

  3. #3
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,957

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    If you are getting the key value from somewhere else, and already know what it is, I typically use this syntax:

    say you searched invoices for a specific invoice, so you already know the invoice number and have it in a variable named invnum - like the number is "0001234" (character)

    and you have an index for the the parent table named "invoice_number"

    you can say
    parentform.index_set("invoice_number")
    parentform.find(invnum)

    note this script must know what the variable is, if you are getting it from somewhere else.
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    martin_w_cole@msn.com

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

  4. #4
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    parentform.index_set("Invoice_Nu")
    topparent.find(vc_invoice)

    Got it. Glad I asked... Thanks Tom & Martin!

    I was "testing stuff" using the Alpha invoice form. Apparently the index needs to be explicitly set. (I guess I was thrown off track when I noticed that adding eval() made it work (seemingly, and not invoke the debugger) without explicitly defining any index.) I had also expected the index was automatically / implicitly set due to the set's structure. (Not to mention the fact that the navigational controls are navigating sequentially without setting index.) ~ Note: The index can either be set using code as above, or set in the forms order expression properties.

    So many ways to do the same things in Alpha 1.) topparent.find(vc_invoice) 2.) Set filter/query and then use Form.Show_All() or 3.) use SuperControl..... (And to top things off, there are numerous different ways you can apply the index / sort order too! ~ very cool!)
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  5. #5
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    Robert, I've found that a good way to get familiar with the help documentation is to use it. The wiki format is a bit off-putting. But I get better at finding things the more I try. In this case you would have found the answers explaining the behavior you were seeing if you had searched for form functions and methods. -- tom

  6. #6
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    Thanks Tom. I had searched, but obviously didn't make the connection.

    The help file explicitly indicates (QUOTED FROM WIKI):

    You may want to use the <FORM>.INDEX_SET() or the <FORM>.QUICK_SORT() method first to set the sort order of the table.
    Which implies that specifying the .index_set() is optional. And when it worked by adding the eval() statement, that made matters even more confusing! (Not to mention that I had incorrectly presumed (because of this) the .FIND() method was searching all indexed fields anyways. ~in the order they were entered in the table definitions, because of the following way in which this particular method is displayed in the a5 GUI:


    NOTE: The X-basic explorer displays the FORM.find() function as follows: .find(* [findwhat] ) and I took the * literally as a wildcard!) ~ Hence the added confusion.
    Last edited by SNusa; 02-01-2012 at 12:18 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

  7. #7
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    Robert, your criticism seems a bit unfair. You omitted the sentence immediately preceding the quoted passage. The entire passage reads:

    The search key is determined by the current sort order. You may want to use the <FORM>.INDEX_SET() or the <FORM>.QUICK_SORT() method first to set the sort order of the table.
    In any event you might want to drop Martin Heller a message with suggested language improvements so that the ambiguity that tripped you up is removed for others.

    Thanks.

    -- tom

  8. #8
    Member SNusa's Avatar
    Real Name
    Robert Tupper
    Join Date
    Dec 2007
    Location
    Northeast, USA
    Posts
    893

    Default Re: Topparent.find(vGoToRecord) only accepts numeric values?

    Quote Originally Posted by Tom Cone Jr View Post
    ...Robert, your criticism seems a bit unfair...
    Tom - No criticism here. And you're probably right. (It's just the way I personally interpreted the wiki help page.)
    As I stated, i thought the sort order was already defined, since you can use the record navigation toolbar (in the Alpha Sports Invoice) to move through records. (And I just happened to be using the invoice number field in combination with the .find() method.)

    What I still find strange is this: In this particular case, (using Alpha Sports Invoice form)..... ~ Why do you think that enclosing the character field in the eval() function enabled the .find() method work properly and find/navigate to the correct invoice without manually setting the index?


    ie: using topparent.find(eval(vc_invoice)) was a workaround (that actually worked) when I failed to first set the index using <FORM>.index_set()


    I attribute most of this to my "ignorance." And understanding the reasons as to why my "wrongful workaround" actually worked, just might provide me with additional insight as to how a5 works!
    Last edited by SNusa; 02-01-2012 at 02:33 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

Similar Threads

  1. Problem with Topparent.find(var_key)
    By KDM in forum Alpha Five Version 9 - Desktop Applications
    Replies: 20
    Last Post: 02-18-2012, 01:51 PM
  2. Sets with Numeric Values
    By BarcodeUK in forum Alpha Five Version 9 - Desktop Applications
    Replies: 5
    Last Post: 04-15-2009, 02:19 AM
  3. Passing Numeric Values
    By Jeffrey Wolfe in forum Alpha Five Version 5
    Replies: 5
    Last Post: 08-28-2004, 08:20 PM
  4. Passing Numeric Values
    By Jeffrey Wolfe in forum Alpha Five Version 5
    Replies: 1
    Last Post: 08-28-2004, 01:07 PM
  5. Numeric Values
    By Andy in forum Alpha Five Version 4
    Replies: 2
    Last Post: 09-22-2003, 01:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •