1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How Do I Resume Processing an Array?

Discussion in 'JavaScript' started by roughie, Jun 14, 2015.

  1. #1
    I have this “book” array where numbers identify chpt., paragraph and verse of included text element:

    book = [[1,1,1, “Once upon a time I was born to a diabetic mom”],
    [1,1,2, “They called me Manny the fatty”],
    [1,1,3, “That is because I was blubbery and round”],
    ...
    [34,18,17, “The end”]]

    The processing starts from the array's beginning. I parse out each sentence for its words, and each word for its letters.

    At some point, inside of a word, while examining a letter, I need to halt, to do some tangential search downstream from here.

    Then I need to get back to this same letter I was investigating, and continue processing where I left off.

    for (x = 0; book[x][0] < 35 || book[x] != undefined; x++){
    verseWords = book[x][3].split(" ");
    wordCount = verseWords.length;
    for (y=0; y < wordCount; y++) {
    letterCount = verseWords[y].length;
    for (z=0; z < letterCount; z++) {
    if (verseWords[y][z] == ....​

    How do I get back to where I was (to the word and letter I was at) and resume processing?

    Suppose I want to check if the letter "X" exists 200 letters from where I am, how do I get back to where I was, to continue?

    I would need a function call. Take the code above; Suppose after the line that reads: if (verseWords[y][z] == .... I want to do this "by-the-way" search for letter X;
    I haven't any idea how to code the function or its parameter requirements, because I'm 3 levels deep in FOR loops.
     
    Last edited: Jun 14, 2015
    roughie, Jun 14, 2015 IP
  2. ketting00

    ketting00 Well-Known Member

    Messages:
    772
    Likes Received:
    27
    Best Answers:
    3
    Trophy Points:
    128
    #2
    Can you redo it over?
    I feel something like this could be done a lot easier with object literal or JSON object than with the array.

    If you go that deep for the nested for loop, I can tell that something is terribly terribly wrong.
     
    Last edited: Jun 15, 2015
    ketting00, Jun 15, 2015 IP