Welcome, Guest
  • Author Topic: DataSet.Find() is abit dodgy  (Read 8384 times)

    da288

    • Server what's that
    • *
    • Posts: 17
      • View Profile
    DataSet.Find() is abit dodgy
    « on: 08/14/07, 08:04 »
    ...or perhaps it's just my AS! Anyway I'm stuck again and turning to you guys for help.

    After lots of debugging I found that dataset.find() only lets you search a dataset with 1 value accurately (specifying multiple values which it is obvious exist in the dataset keeps returning "not found").

    However my main problem that I'm posting about here is the complete opposite: the dataset is returning "found" even when the value doesn't exist!

    Here is my AS:

    if {//dataset length is 0, add a value to the dataset }
    else { // so the dataset length is not 0
          trace("finding context: "+contextvalue);
            if(contextlist3.find([contextvalue])) { // if found
          trace("found context");
            existing=contextlist3.id;
          trace("id found: "+existing);
          return existing;
            }

            else { //if not found
           trace("getting to newpos");
    }

    I realize this is very vague but I think it just may be my if/else structure? I even tried a "if not":

    if(!contextlist3.find([contextvalue])) {
    trace("not found");
    }
    else { // do something else }

    but it still branches to the "else".

    I realize there is an adobe notice regarding binding and the dataset bugs but mine is bound correctly, I can add values etc fine but it always returns a "found"... really wierd. Any feedback/advice much appreciated!

    Update: I have discovered that if I try searching for a string it exhibits the above behaviour, but if it's a numerical value it doesn't. I've been reading about the datatype.setAsString or something but I have no clue what it's on about. Any ideas?

    The values I am searching for are:
    "00000000-0000-0000-0000-000000000001"
    and "Unknown"

    and they both are apparently equal according to dataset.find.
    « Last Edit: 08/14/07, 09:14 by da288 »

    da288

    • Server what's that
    • *
    • Posts: 17
      • View Profile
    Re: DataSet.Find() is abit dodgy
    « Reply #1 on: 08/14/07, 09:30 »
    Ok after hours of debugging found the solution:

    1)You can only accurately search a field that you have sorted using ADDSORT.
    2)(Not so sure about this one but from what it looks like) - you must specify all Sorted fields, in order, in the search term. e.g. to search a dataset with the following structure with 2 columns titled Field1 and 2 populated with Value 1 and 2:

    Field1  | Field 2
    Value1  Value2

    addsort must have both Field1 and Field2 specified.
    and to search the dataset: dataset.find([Value1, Value2]) must both be specified (could be wrong on this one - hope I am!).

    Hope that helps for anyone stumbling accross this in teh future.  ;D