Skipping to a specific place in a recursive function

I wrote a recursive function that recurses Adding times, then calls go (). The entire function will call go () billions of times. When I call this function, I want to only run go () 5,000,000 times. It should run the first 5,000,000 go's if the Part variable is set to 1, the 2nd 5,000,000 go's if Part is 2, etc. The bolded code below is my attempt at implementing this. This code runs the correct 5,000,000-part pieces, but it takes too long because it is still recursing through every part, it's just not calling go () for the other ones. How can I only run the specific piece without recursing through all of the other ones?
Add (int X, int Y, int Adding)
  int Tile;
  while (Y < 12)
    while (X < 16)
      if (aRoom [nRoom] [Y] [X] == 0)
        Changes [Adding - 1] [1] = X;
        Changes [Adding - 1] [2] = Y;
        for (Tile = 0; aTiles [nRoom] [Tile] [0] != 0; Tile++)
          if (aTiles [nRoom] [Tile] [1] > 0)
            aTiles [nRoom] [Tile] [1]--;
            aRoom [nRoom] [Y] [X] = aTiles [nRoom] [Tile] [0];
            Changes [Adding - 1] [0] = aTiles [nRoom] [Tile] [0];
            if (Adding > 1)
              Add (X + 1, Y, Adding - 1);
            else
PartTests++;
if (Part == 0 || Part == Parts)
go ();*}*
if (PartTests == 5000000)
Parts++;
PartTests = 0;
            aTiles [nRoom] [Tile] [1]++;
        aRoom [nRoom] [Y] [X] = 0;
      X++;
    X = 0;
    Y++;
}

what go()?
here's a cleaned up version of the code ( not a soln. ):
Add( int X, int Y, int Adding )
     int Tile;
     while ( Y < 12 )
          while ( X < 16 )
               if ( aRoom [nRoom][Y][X] == 0 )
                    Changes[Adding - 1][1] = X;
                    Changes[Adding - 1][2] = Y;
                    for ( Tile = 0; aTiles [nRoom][Tile][0] != 0; Tile++ )
                         if ( aTiles[nRoom][Tile][1] > 0 )
                              aTiles[nRoom][Tile][1]--;
                              aRoom[nRoom][Y][X] = aTiles [nRoom] [Tile] [0];
                              Changes[Adding - 1][0] = aTiles[nRoom][Tile][0];
                              if ( Adding > 1 )
                                   Add ( X + 1, Y, Adding-1 );
                              else
                                   PartTests++;
                                   if ( Part == 0 || Part == Parts )
                                        go();
                                   if ( PartTests == 5000000 )
                                        Parts++;
                                        PartTests = 0;
                              aTiles[nRoom][Tile][1]++;
                         } // end of if
                    } // end of for
                    aRoom[nRoom][Y][X] = 0;
               } // end of if
               X++;
          } // end of inner while
          X = 0;
          Y++;
     } // end of outer while
}Edited by: scphan on Apr 4, 2009 1:13 PM

Similar Messages

  • My Itunes library is skipping some songs which is also affecting my ipod, it is always the same songs that skip at the same place, it is not all songs.

    Since moving my Itunes to a Vista, it found songs that I downloaded a long time ago and added them to my library but now some songs (not just the ones that were lost in apple land) are skipping after playing a few seconds then it moves onto another song.  The same songs are skipping at the same place when played on a computer and also my ipod.

    i noticed this as a bug in iTunes. make sure the correct file is selected in the preferences menus. It does not have to be the default location directiory as Vazandrew stated. your iTunes music library can be anywhere you want it. i have mine on an external cuz i'm a dj and have over 80,000 songs.
    once you select/verify the location of your music library, simply drag the folder into the left panel in iTunes from a finder window. iTunes does not automatically add the items like it use to for some reason.

  • How do I link to a specific place on a "different" page?

    I understand how a Named Anchor works on a given page. How do I click a link on one page, and go to a specific place on another page? Can that be done?
    Thanks!

    Same page anchor:
    <a href ="#anchoronthispage">
    Different page anchor:
    <a href="anotherpage.html#anotheranchor">

  • Putting a Jlabel in a specific place in JPanel

    Hi,
    I have created a JApplet where I fill it up with some JPanels. Inside a JPanel i want to put some Jlabels on a specific place. However, it doesn't work.
    Whenever i try to put a setLayout(null), the application doesn't show my modifications. If don't use this command, the modification are loaded.
    I don't know what happes with this layout. Is it a problem of layout or a problem of JPanel references?
              canvas = new AVLTreeAnimation();
              //canvas.setLayout(null);
              JLabel label = new JLabel("trestadf");
              label.setLocation(10, 10);          
              canvas.add(label);
              canvas.setBorder(new TitledBorder(null,"AVL-Tree Animation",
                        TitledBorder.LEFT, TitledBorder.TOP));
              canvas.repaint();          
              return canvas;thanks for your help

    man, this same problem's come up a lot this week.
    If you set the layout to null, you have to set the size and the location, not just the location. All components have a size of 0 x 0 initially.

  • I am wanting to add picture and designs to my form how do I place it in a specific place on my form?

    I am wanting to add picture and designs to my form how do I place it in a specific place on my form?

    Currently we only support one field/item on a line. We are working on adding a feature that allows you to put multiple fields/items on a single line. We hope to have that out in a few months.
    Randy

  • External hyperlink to specific place in a PDF file?

    Is it possible to have an external hyperlink on a webpage to a specific place in a PDF file? If so, how is it done? I would be creating the PDF file in InDesign. Thanks

    Great...many thanks
    Mark

  • I want to link to a specific place within a document from Captivate4

    Hi all,
    I want to link to a specific place within a document from Captivate4.
    I have no trouble linking to the beginning of a document; however I want to be able to link to a specific chapter/area of a document I am creating. My plan is that as people progress through the e-learning they can link back to the electronic manual I am creating from where they left off.
    I have a workaround of creating separate documents and linking to them, but this is time consuming and messy.
    Does anyone have any ideas of what I can do; I have looked around the forums and, unless I am blind, can't find anything like I am looking for.
    Cheers
    thedarf

    Hi there
    What type of document are you trying to link to? PDF? Word Doc?
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Linking to specific place in newsletter

    Hello:
    I am trying to find out how to link from an email digest to a specific place in our newsletter. The newsletter page will have several stories on it, which can be read by scrolling down. I would like to email a digest with brief synopsis of the stories, which will link back to the exact story on the newsletter page, not just the newsletter page itself.
    Thanks for any help you can offer.
    Chip Mitchell

    You could use anchors, then set the links to those specific anchors.
    Unless I'm missing something.

  • Problem with recursive function & Exception in thread "AWT-EventQueue-0"

    I hope that title doesn't put everyone off :)
    I have a recursive function that takes in a list of words, and a reference to my current best board. I am kludging the escape function +(tryWords.size() == 0 || mTotalBlankBlocks < 200)+ atm, but eventually it will escape based on whether the current bestBoard meets certain requirements. The function makes iterates through a list of words, and finds all the spaces that the word would fit into the puzzle: getValidSpacedPositions(currentWord); - it then iterates through each of these; placing a word, removing that word from the iterator and the relevant arrayLists and then recurses the function and tries to do the same with the next word etc.
    private void computeBoards(ArrayList<Word> tryWords, Board bestBoard) {
         if (tryWords.size() == 0 || mTotalBlankBlocks < 200)
              return;
         for(Iterator<Word> iter = tryWords.iterator(); iter.hasNext(); ){
              Word currentWord = new Word();
              currentWord = iter.next();
              ArrayList<Position> positions = new ArrayList<Position>();
              positions = getValidSpacedPositions(currentWord);
              if (positions.size() != 0)
                   iter.remove();
              System.out.println();
              int placedWordsIndex = tryWords.indexOf(currentWord);
              System.out.print(placedWordsIndex+". "+currentWord.getString()+" with "+positions.size()+" positions / ");
              for (Position position : positions) {
                   System.out.println("Pos:"+(positions.indexOf(position)+1)+" of "+positions.size()+"  "+position.getX()+","+position.getY()+","+position.getZ());
                   int blankBlocksLeft = placeWord(currentWord, position);
                   if(blankBlocksLeft != 0)
                        mPlacedWords.add(currentWord);
                        // TODO: Kludge! Fix this.
                        mUnplacedWords.remove(placedWordsIndex+1);
                        System.out.println("adding "+currentWord.getString()+" to added words list");
                        Board compareBoard = new Board(blankBlocksLeft, mPlacedWords.size());
                        if (compareBoard.getPercFilled() > bestBoard.getPercFilled())
                             bestBoard = new Board(blankBlocksLeft, mPlacedWords.size());
                        //**RECURSE**//
                        computeBoards(tryWords, bestBoard);
                        mUnplacedWords.add(currentWord);
                        removeWord(currentWord);
                        System.out.println("removing "+currentWord.getString()+" from added words list");
                   else
                        System.out.println("strange error, spaces are there but word cannot place");
              System.out.println("**FINISHED ITERATING POSITIONS");
         System.out.println("**FINISHED ITERATING TRYWORDS");
    }This all seems to work fine, but I add it in for completeness because I am not sure if I have done this right. The Exception occurs in the placeWord function which is called from the recursive loop, on the line bolded. For some reason the Arraylist Words seems to initialise with size 1 even though it is a null's when I look at it, (hence all the redundant code here) and I can't seem to test for null either, it seems to works fine for a while until the recursive funciton above has to back up a few iterations, then it crashes with the exception below.
         private int placeWord(Word word, Position originPosition) {
              ArrayList<Word> words = new ArrayList<Word>();
              switch (originPosition.getAxis().getCurrInChar()) {
              case 'x':
                   // TODO: This is returning ONE!!!s
                   words = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords();
                   int tempword1 = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords().size();
                   for (int i = 0; i < word.getLength(); i++) {
                        *if (words.get(0) == null)*
                             mBlockCube[originPosition.getX() + i][originPosition.getY()][originPosition.getZ()] = new Block(word, word.getChar(i));
                        else
                             mBlockCube[originPosition.getX() + i][originPosition.getY()][originPosition.getZ()].addWord(word);
                   break;
              case 'y':
                   words = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords();
                   int tempword2 = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords().size();
                   for (int i = 0; i < word.getLength(); i++) {
                        *if (words.get(0) == null)*
                             mBlockCube[originPosition.getX()][originPosition.getY() + i][originPosition.getZ()] = new Block(word, word.getChar(i));
                        else
                             mBlockCube[originPosition.getX()][originPosition.getY() + i][originPosition.getZ()].addWord(word);
                   break;
              case 'z':
                   words = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords();
                   int tempword3 = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords().size();
                   for (int i = 0; i < word.getLength(); i++) {
                        *if (words.get(0) == null)*
                             mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ() + i] = new Block(word, word.getChar(i));
                        else
                             mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ() + i].addWord(word);
                   break;
              mTotalBlankBlocks -= word.getLength();
              word.place(originPosition);
              String wordStr = new String(word.getWord());
              System.out.println("Word Placed: " + wordStr + " on Axis: " + originPosition.getAxis().getCurrInChar() + " at pos: "
                        + originPosition.getX() + "," + originPosition.getY() + "," + originPosition.getZ());
              return mTotalBlankBlocks;
    Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
         at java.util.ArrayList.RangeCheck(Unknown Source)
         at java.util.ArrayList.get(Unknown Source)
         at com.edzillion.crossword.GameCube.placeWord(GameCube.java:189)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:740)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.generateGameCube2(GameCube.java:667)
         at com.edzillion.crossword.GameCube.<init>(GameCube.java:42)
         at com.edzillion.crossword.Crossword.actionPerformed(Crossword.java:205)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    Any ideas? I've looked up this exception which didn't shed any light...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    ArrayList<Word> words = new ArrayList<Word>();See the API Javadoc for ArrayList: this creates an empty ArrayList.
    if (words.get(0) == null)This tries to read the first element of the (still empty) array list -> throws IndexOutOFBoundsException
    If you want to stick to that logic (I am too lazy to proof-read your whole algorithm, but that should at least unblock you), you should first check whether the list actually contains at least one element:
    if (!words.isEmpty()) {...}

  • Finder can't continue recursive function

    I'm trying to write a recursive function that returns a nested list representing the directory structure (including files) below a starting path. When I run my function, I get an error: "Applescript Error: Finder got an error: Can't continue getDirectoryStructure." This error appears at the first subfolder encountered.
    This is one of those "spot my mistake" kind of posts, because I am completely lost. I don't see why it shouldn't be able to continue with my recursive function. Here's the code:
    on getDirectoryStructure(startPath)
    tell application "Finder"
    set dirList to {}
    set tempDirList to (get items of folder startPath)
    repeat with curItem in tempDirList
    if (class of curItem is folder) then
    set end of dirList to getDirectoryStructure(startPath & ":" & name of curItem)
    else
    set end of dirList to curItem
    end if
    end repeat
    end tell
    return dirList
    end getDirectoryStructure
    getDirectoryStructure("Filibuster II:Users:ryos:Documents")

    I didn't realize I could display this a little better, I'm new to the list, and slowly getting it figured out.
    This is a re-post of my previous message...
    on script_title()
       Filename : minimaldirtraversal.scpt (Script Debugger)
       Author : Bill Hernandez
       Version : 1.0.0
       Updated : Saturday, December 16, 2006 ( 3:18 PM )
    end script_title
    -- ---------+---------+---------+------------------
    on script_notes()
       I took one of my directory traversal routines, and took a bunch of stuff
       out of it, to create this for you...
       Hope it helps,
       Bill Hernandez
    end script_notes
    -- ---------+---------+---------+------------------
    property gtimestart : ""
    property gtimeend : ""
    -- ---------+---------+---------+------------------
    -- PROPERTIES REQUIRED FOR PROCESSING TRAVERSAL
    -- ---------+---------+---------+------------------
    property aFound : {}
    property aIgnored : {}
    property aFileTypes : {"TEXT"}
    property aExtensions : {"txt", "text", "applescript", "html", "php"}
    -- ---------+---------+---------+------------------
    -- SYSTEM PATHS
    -- ---------+---------+---------+------------------
    property gdirpathhome : ""
    property gdirpathdesktop : ""
    property gdirpathdocs : ""
    property gdirpathprefs : ""
    property gdirpathtemp : ""
    -- ---------+---------+---------+------------------
    property gtextdelim : ":"
    property g_Divider : "--------------------------------------------------" & return
    -- ---------+---------+---------+------------------
    property aErrors : {} -- list of errors
    property gshow_errormessages : true -- set to false to prevent error messages from displaying
    property gsend_error_messages_tolog : true
    property g_continue : true -- use this instead of [if (not(g_abort)) then]
    -- ---------+---------+---------+------------------
    on run
       set w_props to {contents:""}
       --set w_id to my bb_CkWindowExists("Dummy Work Document", "", w_props) -- REMOVE THIS LINE, USED FOR TESTING
       tell me
          InitGlobals()
          set which to "selectchoosefolder" -- aChoices -> { "selectcurrentdocument", "selectopendocuments", "selectchoosefolder"}
          main(which) -- place your code in [main]
       end tell
    end run
    -- ---------+---------+---------+------------------
    on main(whichAction) -- This is the [main handler] called by [on run]
       -- THIS IS A BASIC SHELL FOR ANY SCRIPT
       my ProcessRequest(whichAction)
       if (g_continue) then
          set str to "" -- If this set to "", the following will be used "Would you like to continue processing now?"
          -- REMOVE NEXT LINE, USED FOR TESTING
          set str to str & "Found : ( " & (count items in aFound) & " ) files..." & return & "Time to process : " & (gtimeend - gtimestart) & " seconds..." & return & return
          if (my ConfirmRequest(str)) then
             repeat with thisItem in aFound
                -- PROCESS EACH (FILE, WINDOW, or DOCUMENT) HERE
                -- ******* DO THE WORK HERE
             end repeat
          end if
       end if
       set error_title to "Problem Found:" & return & "NOTIFY APPLE COMPUTER"
       my error_HandleErrors(aErrors, error_title, gshow_errormessages, gsend_error_messages_tolog)
       tell application "BBEdit" to activate
    end main
    -- ---------+---------+---------+------------------
    on ProcessRequest(whichAction)
       -- Having "if (whichAction..." here is redundant, instead of having it below, but makes it easier not having to repeat "set gtimestart..." several times
       if (whichAction = "selectchoosefolder") then
          set startFolder to my ChooseFolder("Select the folder where the files you want to combine are stored?")
       end if
       -- MAKE SURE "set gtimestart..." COMES AFTER "ChooseFolder(...)"
       set gtimestart to (current date) -- REMOVE THIS LINE, USED FOR TESTING
       if (g_continue) then
          if (whichAction = "selectopendocuments") then
          else if (whichAction = "selectchoosefolder") then
             my processDirectory(startFolder)
          else if (whichAction = "selectcurrentdocument") then
          else
             set aFound to {}
          end if
       end if
       set gtimeend to (current date) -- REMOVE THIS LINE, USED FOR TESTING
    end ProcessRequest
    -- ---------+---------+---------+------------------
    on InitGlobals()
       set aErrors to {} -- list of errors
       set gdirpathhome to (path to home folder from user domain as text)
       set gdirpathdesktop to (path to desktop from user domain as text)
       set gdirpathdocs to (path to documents folder from user domain as text)
       set gdirpathprefs to (path to preferences folder from user domain as text)
       set gdirpathtemp to (path to temporary items folder from user domain as text)
       set g_continue to true
       set aFound to {}
       set aIgnored to {}
    end InitGlobals
    -- ---------+---------+---------+------------------
    on ChooseFolder(s)
       tell application "Finder"
          activate
          if (s = "") then
             set str to "Select the folder you wish to traverse?"
          else
             set str to s
          end if
          try
             return choose folder with prompt str
          on error
             set g_continue to false
             tell application "BBEdit" to activate
          end try
       end tell
    end ChooseFolder
    -- ---------+---------+---------+------------------
    on ConfirmRequest(s)
       tell application "BBEdit"
          activate
          set b1 to "Go Ahead..."
          set b2 to "Forget It!"
          set str to s & "Would you like to continue processing now?"
          set aResult to display dialog str buttons {b1, b2} default button {b1}
          if ((button returned of aResult) = b1) then
             return true
          else
             return false
          end if
       end tell
    end ConfirmRequest
    -- ---------+---------+---------+------------------
    on date_GetFullDate(theDate)
       set ds to date string of (theDate)
       set TS to time string of (theDate)
       tell application "Finder"
          set TS to ((get characters 1 thru -7 of TS) & (get characters -3 thru -1 of TS)) as string
       end tell
       set FD to (ds & " (" & TS & ")")
       return FD
    end date_GetFullDate
    -- ---------+---------+---------+------------------
    on processDirectory(thisFolder)
       tell application "Finder"
          set aItems to (get every item of folder thisFolder)
       end tell
       repeat with I from 1 to the count of aItems
          set thisItem to (item I of aItems as alias)
          set itemInfo to info for thisItem
          set itemName to (name of itemInfo)
          if ((folder of itemInfo) is true) then
             my processDirectory(thisItem) -- It is a FOLDER
          else if ((visible of itemInfo is true) and (alias of itemInfo is false)) then
             if (((file type) of itemInfo) is in aFileTypes) then
                set aFound to aFound & thisItem -- It is a valid file
             else if (((name extension) of itemInfo) is in aExtensions) then
                set aFound to aFound & thisItem -- It is a valid file
             else
                set aIgnored to aIgnored & thisItem -- It is NOT a valid file
             end if
          else
             set aIgnored to aIgnored & thisItem -- It is NOT a valid file
          end if
       end repeat
    end processDirectory
    -- ---------+---------+---------+------------------
    on error_HandleErrors(aErrorList, header_str, display_error, send2log)
       if (header_str = "") then
          set myheaderstr to "Errors were encountered during script execution..."
       else
          set myheaderstr to header_str
       end if
       if ((count of aErrorList) > 0) then
          set s to ""
          repeat with my_error in aErrorList
             set s to s & my_error & return & return
          end repeat
          set s to header_str & return & return & s
          if (display_error) then
             display dialog s buttons {"OK"} default button {"OK"} with icon stop giving up after 15
          end if
          if (send2log) then
             -- NEED TO INCLUDE ROUTINE TO SEND ERRORS TO THE LOG
             -- next line is normally enabled
             -- my writetofile(s, gfilepathlog, true) -- { (true -> append_data), (false -> overwrite) }
          end if
       end if
    end error_HandleErrors
    -- ---------+---------+---------+------------------

  • How do I make a settings shortcut on the iphone 5? Specifically the do not disturb function??

    How do I make a settings shortcut on the iphone 5? Specifically the do not disturb function??

    Is there an app that does it? I found a brdrck website but it is unavailable now  

  • Is there any recursive function in DB2

    Hi all,
    Could you please tell me is there any recursive function in DB2 and if yes then please provide me a sample code.
    I want to write a function as below but it's giving me following error:
    >[Error] Script lines: 1-33 -
    ( DB2 SQL error: SQLCODE: -440, SQLSTATE: 42884, SQLERRMC: SCF_MC2;FUNCTION
    Message: No authorized routine named "SCF_MC2" of type "FUNCTION" having compatible arguments was found.
    Line: 11 )
    create FUNCTION scf_mc2 (@@certname varCHAR(20),@@assignee varCHAR(20),@@currentUser     varCHAR(20), @@javaLocale
    varCHAR(20) )RETURNS float
    LANGUAGE SQL
    READS SQL
    DATA format:
    BEGIN ATOMIC 
        declare @n_cost float;
        declare @n_cost1 float;
        set @n_cost1 =0.00;
    FOR @n_cost as
        select
        COALESCE ((CASE substr(ep.part_id,1,5) when 'cours' then tp2.scf_nc(ep.part_id,@@assignee,@@currentUser,@@javaLocale)  else
        tp2.scf_mc2(ep.part_id,@@assignee,@@currentUser,@@javaLocale) end ),0) cost
        from
        tpt_ext_ce_certification certi
        inner join tpt_ext_ce_track tr  on tr.certification_id = certi.id
        inner join tpt_ext_ce_group gr  ON gr.track_id = tr.id
        inner join tpt_ce_education_plan ep  ON ep.owner_id = gr.id
        WHERE
        tr.locale_id = @@javaLocale
        AND
        gr.locale_id = @@javaLocale
        AND
        certi.locale_id = @@javaLocale
        and
        substr(tr.flags,2,1) = '1'
        and
        certi.id=@@certname
    DO
    SET @n_cost1 = @n_cost+@n_cost1;
    END FOR;
    return @n_cost1;
    end format
    Regards
    Vishal

    Java is an object-oriented language, so you're not just searching for a method to do what you want, but for a Class, that provides that ability.
    And since you don't define what "the date that I want" means I can only guess.
    If you've got the date value in a String in some format, then you might look into the DateFormat or SimpleDateFormat classes.

  • Validation of recursive function call fails

    We want to use a call to a recursive function from a HTMLDB application. It should be used in a page region to generate a query string ("PL/SQL function body returning SQL query"). Everything works fine with a call to a non-recursive function. The recursive function also works fine when called from SQL+.
    After pressing "Apply changes" on "HTML DB Home>Builder - Application 148>Page Definition>Edit Page Region"-page I get the following error message after a long delay:
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing
    (ORA-00600: internal error code, arguments: [kohdtf048], [], [], [], [], [], [], [])
    I assume that the validation routine follows the recursion until the memory limit is reached.
    Please give me a hint how to solve this problem.
    DB version: 10.1.0.2.0
    HTMLDB version: 1.5.0.00.33
    running on Win2000 server

    Since the original function is confidential, I have created a simple one showing the same behavior (and the same error). Termination does not depend on session state:
    Called function (to replace spaces with #):
    create or replace function MF_Test
         p_querystring     varchar2     
         return varchar2 is
         v_position integer;
    begin
         v_position:=instr(p_querystring,' ');
         if v_position=0 then     /* termination condition */
              return p_querystring;
         else
              return substr(p_querystring,1,v_position-1)||'#'||MF_Test(substr(p_querystring,v_position+1));
         end if;
    end MF_Test;
    calling function (from the page region, to generate a query string):
    declare
    q varchar2(500);
    begin
    q:='select * from hardware where model=''';
    q:=q||mf_test(:P3_SEARCH);
    q:=q||'''';
    end
    Validation seems not to terminate in case of recursive function calls.
    Thanks for your input.

  • Help with recursive function to print number patterns

    I'm sorry for having to ask for homework help - I'm badly stuck on this! Can someone give me a kick in the right direction with this?
    need a recursive function with a single positive int parameter n. the function should write (2^n - 1) integers and should be in the following pattern...
    n = 1, Output: 1
    n = 2, Output: 1 2 1
    n = 3, Output: 1 2 1 3 1 2 1
    n = 4, Output: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
    n = 5, Output: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
    function should valid for all positive integer values of n
    This was tagged as a 'short' problem...so it shouldnt take too much code...I am hung on on the following:
    *Do I keep track of the numbers printed, if so how?  I only have a single parameter to call with so I am confused as to how I could get an entire pattern without keeping track of the history
    *I had initially thought it would be necessary to cut it in half and do the 2nd half backwards (ie: for n=3, I would take care of the 1 2 1 - then 3 - then 1 2 1...but even then it seems like I could cut 1 2 1 in half the same way and therefor I should be able to do ALL of it in single parts...
    Can someone veer me in the right direction here? I'm really lost with this.

    This was tagged as a 'short' problem...so it shouldnt
    take too much code...Yeah, the method body could be done in a few lines.
    I am hung on on the following:
    *Do I keep track of the numbers printed, if so how?Not explicitly. Use the call stack. That is, use the fact that when you're recursing, the previous values of numbers are preserved in the previous method invocation.
    I only have a single parameter to call with so I am
    confused as to how I could get an entire pattern
    without keeping track of the historyYou don't have to store anything across method invocations.
    I had initially thought it would be necessary to cut
    it in half and do the 2nd half backwards (ie: for
    n=3, I would take care of the 1 2 1 - then 3 - then 1
    2 1...but even then it seems like I could cut 1 2 1
    in half the same way and therefor I should be able to
    do ALL of it in single parts...No, it's MUCH simpler than that. It's easier than yo uthink.
    Can someone veer me in the right direction here? I'm
    really lost with this.Try this simpler version of the problem:
    Write a recursive method that creates this output:
    n = 1: 1
    n = 2: 1 2
    n = 3: 1 2 3
    And try this simpler version:
    n = 1: 1
    n = 2: 2 1
    n = 3: 3 2 1

  • Calling Recursive function in a transaction

    Hello All
    I have a requirement calling Recursive function in Transaction.Means inside a transaction, i want to call the same transaction.Is it possible to do like this?
    Because when i am calling like this,transaction is running contineously without stop.
    Any help would be highly appreciated.
    Thanks,
    Manisha

    Manisha,
    take a look on this thread:
    Does xMII support recursive Business Logic Modules
    Hope Ricks solution can help you.
    Regards
    Pedro
    Edited by: Pedro Iglesias on Dec 19, 2008 9:56 AM

Maybe you are looking for