Alpha Video Training
Results 1 to 8 of 8

Thread: Script "Property Type Mismatch" error

  1. #1
    Richard Dean
    Guest

    Default Script "Property Type Mismatch" error

    Hello forum,
    I have the following script attached to a OnChange event and it only sometimes produces the "Property Type Mismatch" error and I can't realiably produce the stopping of the error. The error occurs always on the first start of the form but sometimes stops and the script works properly. Also always works fine on V5 im running V4.5 266.

    dim comp as p
    comp=table.open("main")
    comp.update_production_index()
    ix=comp.index_primary_put("xselect")
    nrec=ix.records_get()
    comp.fetch_first()
    xaxis.choice.list.redim(nrec)
    yaxis.choice.list.redim(nrec)
    for i=1 to nrec
    xaxis.choice.list[i].text=comp.year
    xaxis.choice.list[i].value=comp.year
    yaxis.choice.list[i].text=comp.year
    yaxis.choice.list[i].value=comp.year
    comp.fetch_next()
    next i
    comp.close()

    The error is produced by the line

    xaxis.choice.list.redim(nrec).

    This script is used on other forms and always works fine the only difference is the index which is used. In the case that doesn't work the index has a filter expression of REG=VAR->GROUP, with the VAR->GROUP being the field with the onchange event attached (when removed the scripts works but doesn't do it's job!). This is a problem produced when trying to get a form to do what I decscribed in a post from last week entitled "Changing listbox contents on the fly" which is what this script does in V5 but produces this error in V4.5

    Any help or ideas on how to do this differently will be appreciated.

    Thanks

    Rich

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

    Default RE: Script

    Rich,

    there are several constructs in your code that look unfamiliar to me, but I have little experience with listboxes.

    OnChange event probably doesn't update your index. If your script assumes that the filtered index has been updated when it runs this may be part of an explanation for what you're seeing.

    -- tom

  3. #3
    Richard Dean
    Guest

    Default RE: Script

    Thanks Tom, I thought the line

    comp.update_production_index()

    was producing the index update but after further investigation this is not correct. The error I am experiencing is because the listbox array length is defined as 0 which produces the error! But how do I actually update the index's?

    I have changed the single line to

    index_create_begin("uni", "STUFF(CODE,4,1,YEAR)", "", "I")
    index_add("REG", "REG", "", "IU")
    index_add("YEAR", "YEAR", "", "I")
    index_add("XSELECT", "year", "reg=var->group", "IU")
    index_create_end(db_current(), "MAIN.CDX")

    and this still doesn't work!

    Rich

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

    Default RE: Script

    Richard,

    comp.update_production_index() will update an index, however OnChange is a field event. It fires when the contents of a field in the form layout changes. This has nothing to do with when a record is updated or committed to the table. I think you can update the index all day long, but until the form with pending changes has been committed to the table I don't think the changed values will be reflected in the index list. Still dont' know if this is relevant to your situation, but wanted to clarify further for you.

    -- tom

  5. #5
    Richard Dean
    Guest

    Default RE: Script

    I'm not sure whether it is relevent either as the field is a global variable not part of a record, so at no point is the database written to. What I wanted to do was as the contents of the global variable changed it updated the indexes in the database which were reliant on that global variable. The script below works but when on a button or on a field event for a non related field.

    comp=table.open(A5.get_master_path()+"main.dbf")
    comp.update_production_index()
    comp.close()

    comp=table.open(A5.get_master_path()+"main.dbf")
    ix=comp.index_primary_put("xselect")
    nrec=ix.records_get()
    comp.fetch_first()
    xaxis.choice.list.redim(nrec)
    yaxis.choice.list.redim(nrec)
    for i=1 to nrec
    xaxis.choice.list[i].text=comp.year
    xaxis.choice.list[i].value=comp.year
    yaxis.choice.list[i].text=comp.year
    yaxis.choice.list[i].value=comp.year
    comp.fetch_next()
    next i
    comp.close()
    END

    if on the onchange event then the x and yaxis content are changed one click behind the var->group change. This only happens once for every onarrive event of the changing field. It works as it should in v5.

    p.s. the reason for getting it working in 4.5 is that i have the runtime for that and not for V5

    Thanks again

    Rich

  6. #6
    Richard Dean
    Guest

    Default RE: Script

    if a this.refresh() is added at the beggining of the onchange event then in 4.5 the selected row goes back to the orginal selected row eveytime it is changed. In V5 though the this.refresh() has no effect and the change of the listbox row happens as normal. This appears to be why it works in v5 and not in 4.5 as script needs to run after the value of the list box is changed which is not happening in 4.5 as shown by adding the this.refresh()!

    I have tried reading the listbox.value as a first thing and this is still the previous value not the one changed to!

    If there is a work around for this then that would be good if not then a completely different approach is what is needed!

  7. #7
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,171

    Default RE: Script

    Rich

    Unless I am mistaken, v4.5 doesn't support dot variables. Since that is what you are using, the code will fail in V4.5. Code written in v5 is not backward compatible with v4.5. The best solution is to either do all of your developement in v4.5 or purchase the runtime for v5.

    Jerry

  8. #8
    Richard Dean
    Guest

    Default RE: Script

    I have now got the code to work as I want with adding a

    somethingelse.activate()

    as the first thing in the code!

Similar Threads

  1. Action Script-Variable Type Mismatch
    By Ed Merritt in forum Alpha Five Version 5
    Replies: 4
    Last Post: 04-19-2004, 08:48 PM
  2. Setting up a "TurboTax" type inquiry
    By Mike Marko in forum Alpha Five Version 5
    Replies: 1
    Last Post: 01-31-2004, 01:32 AM
  3. Find/Replace returns "Script Error"
    By Denny Johnson in forum Alpha Five Version 5
    Replies: 0
    Last Post: 08-08-2003, 12:32 PM
  4. Help with "Image File Reference " Type F
    By Graham Wickens in forum Alpha Five Version 5
    Replies: 0
    Last Post: 05-01-2003, 08:27 AM
  5. "Incorrect Data Type" error
    By fairviewcomputing in forum Alpha Five Version 4
    Replies: 6
    Last Post: 02-11-2001, 11:54 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
  •