A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: need some help using split()

  1. #1
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320

    need some help using split()

    Right ok i have a submit form for a motocross results db table.

    code:

    for (i=0; i<count; i++) {
    drvPos = this.bobby["cwrRes"+i].drvPos;
    drvNo = this.bobby["cwrRes"+i].drvNo;
    drvDrv = this.bobby["cwrRes"+i].drvDrv;
    drvLaps = this.bobby["cwrRes"+i].drvLaps;
    drvTi = this.bobby["cwrRes"+i].drvTi;
    drvGap = this.bobby["cwrRes"+i].drvGap;
    drvMph = this.bobby["cwrRes"+i].drvMph;
    drvFast = this.bobby["cwrRes"+i].drvFast;
    res += ".::."+drvPos+"|"+drvNo+"|"+drvDrv+"|"+drvLaps+"|" +drvTi+"|"+drvGap+"|"+drvMph+"|"+drvFast;
    }


    res output "=.::.1|4|blahname|5|10:58|0.500|45|1.250.::.2|8|a nothername|5|11:45|1.326|40|1.453.::.3|10|notme|5| 11:67|0.056|40|1.550"

    So you can see how the information is going to be stored in the db
    The problem starts when i try to split it back down.
    code:

    //this part works!

    resArr = res.split(".::.");

    // output: 1|4|blahname|5|10:58|0.500|45|1.250

    // 2|8|anothername|5|11:45|1.326|40|1.453

    // 3|10|notme|5|11:67|0.056|40|1.550

    for (k=1; k<resArr.length; k++) {
    trace("res1="+resArr[k]);
    splitRes2();
    }
    }
    //Function wont start
    function splitRes2() {
    resArr2 = resArr[k].split("|");
    for (j=0; j<resArr2; j++) {
    trace("res2="+resArr2[j]);
    }
    }


    What am i missing?

    cheers

    Paul
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Believe it should be

    code:

    for (j=0; j<resArr2.length; j++) {
    trace("res2="+resArr2[j]);
    }


  3. #3
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    the loop in the function splitRes2 looks like it has an error,

    for (j=0; j<resArr2; j++) {

    should probably be,

    for (j=0; j<resArr2.length; j++) {

    instead.

  4. #4
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    i am soo silly, how did i miss that!
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center