Alpha Video Training
Results 1 to 12 of 12

Thread: Script to fill price on form - default limit to size of field?

  1. #1
    Member
    Real Name
    Terri Hernacki
    Join Date
    Dec 2000
    Location
    South Elgin IL
    Posts
    167

    Default Script to fill price on form - default limit to size of field?

    I have a script that fills in pricing in an embedded browse on a tabbed form. The pricing is for a type of inspection. This script has always worked (since 2003)until now. A new client demands we use their naming convention for the types of inspections we provide for them. I have noticed that if the inspection type field goes over 20 characters, the price will NOT fill in. The "inspection" field itself (or clienttype as referenced in the script below) is set to be 35 characters long in every table where it is needed or referenced to, so why will the price not fill in? Is there some sort of default that restricts this to 20 characters? I am attaching the script that is on the OnWrote event of the field rules for the inspection field.
    (I did not originally design this database)

    xbasic_wait_for_idle()
    if is_object(topparent.this)
    f=topparent.this
    else
    end
    end if

    vmode=f.mode_get()
    if"ENTER" $ vmode
    vKey=alltrim(parentform:clientidentifier.text)+alltrim(parentform.type.text)
    t=table.open("billtoclient")
    t.index_primary_put("clienttype")
    vreturn=t.fetch_find(vKey)
    else
    end
    end if

    if vreturn < 1
    t.close()
    else
    f.gs_pr.value=t.Clientscost
    f.gs_pr.refresh()
    t.close()
    end if


    Thanks for any help !

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

    Default Re: Script to fill price on form - default limit to size of field?

    Suggest you use debug() to find out where the script is failing. Is it failing because the search key (vkey) cannot be found in the billtoclient table? If so, why?

    Also, the syntax for the assignment statement looks wrong, especially if you're trying to fill in a cell in an embedded browse.

    Instead of

    Code:
    f.gs_pr.value = t.clientscost
    I'd expect something like

    Code:
    f:browse1:gs_pr.value = t.clientscost

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Script to fill price on form - default limit to size of field?

    Shouldn't this

    +alltrim(parentform.type.text)

    be

    +alltrim(parentform:type.text)

  4. #4
    Member
    Real Name
    Terri Hernacki
    Join Date
    Dec 2000
    Location
    South Elgin IL
    Posts
    167

    Default Re: Script to fill price on form - default limit to size of field?

    Hi Tom and Stan -

    Tom the script does not "fail" ....at least not completely. It only does not fill in if the "clienttype" is MORE than 20 characters. Which is why I asked if it is some type of default in A5 since the size of the field is 35 characters.

    Stan - that was my mistake in typing it out for the message board - it is parentform:type.text

    Any ideas as to why it does not fill ?

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

    Default Re: Script to fill price on form - default limit to size of field?

    so what does debug() show you?

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Script to fill price on form - default limit to size of field?

    that was my mistake in typing it out for the message board
    Why would you not copy and paste to the message board instead of retyping?

    On the fill question, no idea. You should follow Tom's advice and debug() the script or attach a sample database here that exhibits the issue. Even if the script does not fail, debug() will let you examine the values being processed at each step.

  7. #7
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Script to fill price on form - default limit to size of field?

    In your script, you use:
    Code:
    vreturn=t.fetch_find(vKey)
    No problem there, with 2 exceptions:
    1-The key length that you are searching for MUST, MUST, match the key length in the index. Alpha takes care of that up to a point. If the searched key is smaller, alpha will pad it with spaces, but if it is longer.. you are out of luck. First order of business is to update your index
    2-I am pretty sure, but I don't quite remember the number, but I think it's around 200 chr for the key length. (I posted that in a thread long long time ago and it doesn't match what the help file says).

    I think that's where your problem is, in the index key.
    As I said, first update the index and see if that works, if not, replace the full name in the index and the script with a truncated name.

  8. #8
    Member
    Real Name
    Terri Hernacki
    Join Date
    Dec 2000
    Location
    South Elgin IL
    Posts
    167

    Default Re: Script to fill price on form - default limit to size of field?

    Stan - Normally I would copy and paste, but I was working remotely from home and always learning. I find typing things out helps me learn and understand a little more. Someday hope to have the time to REALLY learn all of Alpha5!

    Tom - I ran the debug and no errors showed at all.

    Not sure how to attach a sample database - please advise as our database is huge

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Script to fill price on form - default limit to size of field?

    It would seem your form is built on a set. You can right click on the set in the control panel and choose Zip. That should be all that is needed if billtoclient is a part of the set. If it is not you would need to zip it separately.

  10. #10
    Member
    Real Name
    Terri Hernacki
    Join Date
    Dec 2000
    Location
    South Elgin IL
    Posts
    167

    Default Re: Script to fill price on form - default limit to size of field?

    Hi All

    Tom Cone helped figure this out. He changed a line in the script to be specific to the form and browse involved and it now fills in.

    if "ENTER" $ vmode
    'vKey = alltrim(parentform:clientidentifier.text) + alltrim(parentform:type.text)
    vKey = alltrim(:ordersnew:clientidentifier.text) + alltrim(:ordersnew:Browse1:Type.text)

    THANK YOU all for all help suggested and provided!
    Terri

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

    Default Re: Script to fill price on form - default limit to size of field?

    Terri and I got this sorted.

    Her script was running in the OnWrote field event in the field rules of the table being displayed in the browse object on her form. The field value was populated using a table lookup field rule. The onWrote field event field rule fired when she tabbed out of the column. The script did not throw any syntax errors and ran fine with short client "type" strings. We tried a number of things before determing that the following syntax changes did the trick. Did not have a problem with the index specifications. Seemed to be a timing issue. Possibly Alpha was taking too long to resolve the relative object addresses. Incomplete (truncated) field values were being assigned to the search key variable. When we went with absolute object addresses the problem was resolved.

    Instead of:
    Code:
    vKey=alltrim(parentform:clientidentifier.text)+alltrim(parentform:type.text)
    We did:
    Code:
    vKey=alltrim(:Ordersnew:clientidentifier.text)+alltrim(:OrdersNew:Browse1:type.text)
    Last edited by Tom Cone Jr; 07-05-2011 at 12:42 PM.

  12. #12
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default Re: Script to fill price on form - default limit to size of field?

    Wow! Very interesting Tom.

    However, for the benefit of TerryH and other readers, my first reaction to that is that I would prefer not to to use references to a form in the table's OnWrote event. That means the table can ONLY be used in that one form. It won't work very well at all if you try to edit the table in the default browse or in a different form. (I know. I know. That's the only form that is used with this table. I've heard it before. Even said it myself. But I've learned. Just because it's that way now doesn't mean it will remain that way in the future and it may take a long time to figure out why things aren't working when a new form is created a year from now and nobody remembers how/why it was set up this way. Or when some error/update requires someone to edit the default browse and ends up having all kinds of trouble.)

    For something like this (as best I can tell from what I see in these posts), I'd prefer to either use table references in the OnWrote event or put that in the OnDepart (or maybe the CanDepart) event on the form since it's referencing values on the form.

Similar Threads

  1. Memo Field Size Limit
    By jbk in forum Alpha Five Version 9 - Desktop Applications
    Replies: 7
    Last Post: 01-17-2010, 11:52 AM
  2. Size Limit on X-Basic Script?
    By Louis Nickerson in forum Alpha Five Version 5
    Replies: 8
    Last Post: 03-04-2004, 04:17 PM
  3. Field Rule size limit
    By PCS in forum Alpha Five Version 5
    Replies: 3
    Last Post: 10-20-2003, 09:15 AM
  4. Field Rule size limit
    By PCS in forum Alpha Five Version 5
    Replies: 6
    Last Post: 10-17-2003, 02:55 PM
  5. Field Rule size limit
    By PCS in forum Alpha Five Version 5
    Replies: 0
    Last Post: 10-17-2003, 10:43 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
  •