Need help cleaning a recursive loop, please.

Hello again,

I'm on another quest to write a function completely fool proof to a very specific task in Illustrator. The task is to create a new work plan in the target document (determined by a guest of small script user interface) which is a certain distance from the existing chart with the highest index Board (so I'm still putting the new plan of work at the end). After I created the work plan, I want to activate the source document and duplicate all the layers (a few layers are empty but will be used later) and work in the doc of the target and place them on the newly created artboard.

With the help and advice of Silly-V , I wrote a recursive loop to handle the situation of nested layer. This brings me to the first part of my question. Please take a look at recursion and let me know if there is anything I can do to clean it up and simplify as much as possible. (I know it looks really messy. I've learned how do on the fly and I changed a lot of variables and loops after the fact, just trying to make it work). I hope also that somehow slightly more efficient to work this will improve stability as well. As it is, I can only run this script 3 or 4 times (if I'm lucky), before I get persistent errors of MRAP on trivial things such as: layers.getByName("Information").visible = false; At this point, the only recourse is to stop illustrator and reopen files. So I'm usually good for a few runs more...

Part 2 of my question is the following. Is there a way to reproduce the work from one document to the other, and place it on the new artboard rather than the artboard [0]? Currently, art is duplication of artboard [0] the doc from the source to the artboard [0] the doc of the target and then I manually manipulate the implementation by defining: this.left this.left = + (artboards.length * 2100). First, it is just steps adding too much to the script and slow things down I'm sure. The second problem that is after 4 work plans, I need down another line (to keep from spilling onto the pasteboard). That adds another layer of complexity and a lot more if statements to determine how far from move it and in what direction.

Here's the script in its entirety. Please do not hesitate to rip it and ask me WTH I thought. According to carloscanto, script.elegant is definitely fake.

var copyToMaster = function(){
  var docRef = app.activeDocument;
  var layers = docRef.layers;
  var masterFile = getTargetDoc();
  if(masterFile == null){
  return;
  }
  var master = app.documents.getByName(masterFile);
  var sourceDoc = app.activeDocument;
  var move;
  var myLayer;
  var targetLayer;
  var innerTargetLayer;
  var outerTargetLayer;


  //Logic Container//

  function outerRecursive(layer){
  var name = layer.name;
  try{
  outerTargetLayer = targetLayer.layers.getByName(layer.name);
  }
  catch(e){
  outerTargetLayer = targetLayer.layers.add(ElementPlacement.PLACEATBEGINNING);
  outerTargetLayer.name = name;
  }
  if(layer.pageItems.length>0){
  for(var b=layer.pageItems.length-1;b>-1;b--){
  var curItem = layer.pageItems[b];
  var copyCurItem = curItem.duplicate(outerTargetLayer,ElementPlacement.PLACEATBEGINNING);
  copyCurItem.left = curItem.left+move;
  }
  }
  if(layer.layers.length>0){
  for(var e=layer.layers.length-1;e>-1;e--){
  var subSubLayer = layer.layers[e];
  innerRecursive(subSubLayer);
  }
  }
  }

  function innerRecursive(subLayer){
  try{
  innerTargetLayer = outerTargetLayer.layers.getByName(subLayer.name);
  }
  catch(e){
  innerTargetLayer = outerTargetLayer.layers.add();
  innerTargetLayer.name = subLayer.name;
  }
  if(subLayer.pageItems.length>0){
  for(var g=subLayer.pageItems.length-1;g>-1;g--){
  var curItem = subLayer.pageItems[g];
  var copyCurItem = curItem.duplicate(innerTargetLayer,ElementPlacement.PLACEATBEGINNING);
  copyCurItem.left = copyCurItem.left + move;
  }
  }
  if(subLayer.layers.length>0){
  for(var h=subLayer.layers.length-1;h>-1;h--){
  innerRecursive(subLayer.layers[h]);
  }
  if(name == "Information"){
  layer.locked = true;
  layer.visible = true;
  }
  else if(name == "Prepress"){
  layer.locked = false;
  layer.visible = false;
  }
  }
  if(subLayer.name == "Information"){
  subLayer.locked = true;
  subLayer.visible = true;
  }
  else if(subLayer.name == "Prepress"){
  subLayer.locked = false;
  subLayer.visible = false;
  }
  }

  function getTargetDoc(){

  var docs = [];


  for(var a=0;a<app.documents.length;a++){
  docs.push(app.documents[a].name);
  }


  var targetIndex = new Window("dialog", "Which is Master");
  var newTextGroup = targetIndex.add("group");
  newTextGroup.text = targetIndex.add("statictext",undefined,"Which file do you want to merge to?");
  newTextGroup.align = "center";
  var radioGroup = targetIndex.add("group");
  radioGroup.alignChildren = "left";
  radioGroup.orientation = "column";
  for(var a=0;a<docs.length;a++){
  radioGroup.add("radiobutton",undefined,docs[a]);
  }
  radioGroup.children[0].value = true;

  var buttonGroup = targetIndex.add("group");
  var ok = buttonGroup.add("button", undefined, "OK");
  var can = buttonGroup.add("button", undefined, "Cancel");


  function selected(which){
  for(var c=0;c<which.children.length;c++){
  if(which.children[c].value == true){
  return which.children[c].text;
  }
  }
  }


  if(targetIndex.show() == 1){
  return (selected(radioGroup));
  }
  else{
  return;
  }


  targetIndex.show();
  }

  function createNewArtboard(){
  master.activate();
  move = ((master.artboards.length) * 2100)
  var aBcount = master.artboards.length;
  var lastAB = master.artboards[master.artboards.length-1];
  var aB = lastAB.artboardRect;
  var left = aB[0];
  var top = aB[1];
  var right = aB[2];
  var bot = aB[3];
  var moveRight = 2100;
  var moveDown = 2100;
  if(aBcount != 5 && aBcount != 10){
  var newLeft = left + moveRight;
  var newRight = right + moveRight;
  var rect = [newLeft,top,newRight,bot];
  var newAb = master.artboards.add(rect);
  }
  else{
  var originAb = master.artboards[0].artboardRect;
  var oLeft = originAb[0];
  var oTop = originAb[1];
  var oRight = originAb[2];
  var oBot = originAb[3];
  oTop = oTop - moveDown;
  oBot = oBot - moveDown;
  var rect = [oLeft,oTop,oRight,oBot];
  var newAb = master.artboards.add(rect);
  }
  sourceDoc.activate();
  }

  //Function Calls

  createNewArtboard();

  for(var a=0;a<layers.length;a++){
  layers[a].locked = false;
  layers[a].visible = true;
  }
  for(var a=0;a<master.layers.length;a++){
  master.layers[a].locked = false;
  master.layers[a].visible = true;
  }

  for(var a=layers.length-1;a>-1;a--){
  var curLayer = layers[a];
  try{
  targetLayer = master.layers.getByName(curLayer.name);
  }
  catch(e){
  targetLayer = master.layers.add();
  targetLayer.name = curLayer.name;
  }
  if(curLayer.pageItems.length>0){
  for(var k=curLayer.pageItems.length-1;k>-1;k--){
  var curItem = curLayer.pageItems[k];
  var copyCurItem = curItem.duplicate(targetLayer,ElementPlacement.PLACEATBEGINNING);
  copyCurItem.left = copyCurItem.left + move;
  }


  }
  if(curLayer.layers.length>0){
  for(var f=curLayer.layers.length-1;f>-1;f--){
  var curSubLayer = curLayer.layers[f];
  outerRecursive(curSubLayer);
  }
  }
  }

  //re-lock/hide layers;

  for(var a=0;a<master.layers.length;a++){
  if(master.layers[a].name == "Guides" || master.layers[a].name == "BKGRD, do not unlock"){
  master.layers[a].locked = true;
  }
  else{
  for(var b=0;b<master.layers[a].layers.length;b++){
  var level2 = master.layers[a].layers[b];
  if(level2.name == "Prepress"){
  level2.locked = false;
  level2.visible = false;
  }
  else if(level2.name == "Information"){
  level2.locked = true;
  level2.visible = true;
  }
  }
  }
  }








}
copyToMaster();
copyToMaster = null;

How is that?

function duplicateToMaster(){
    function pasteInMaster(){
        if(app.pasteRemembersLayers === false){
            app.pasteRemembersLayers = true;
            app.executeMenuCommand('pasteInPlace');
            app.pasteRemembersLayers = false;
        }else{
            app.executeMenuCommand('pasteInPlace');
        }
    }

var aDoc = app.activeDocument;
app.executeMenuCommand('selectall');
app.executeMenuCommand('copy');
var bDoc = app.documents[1];
bDoc.activate();
pasteInMaster();
}
duplicateToMaster();

Tags: Illustrator

Similar Questions

  • Need help of LabView on loops

    I'm doing a LabVIEW MyRIO project on how to display the values. Basically, I give myself a LCD screen and a keyboard. I'm supposed to show three sequences in the order. First, it must ask the user to enter a number on the keyboard to choose his field of interest. Then depending on the number, the user is prompted again to choose another number to specify the particular value he or she wants to watch. Finally, the value is displayed and the user can choose to return to the previous sequence interface by pressing a key. Each of the three sequences are able to "hold" until the user presses a button.

    I am able to attend the second interface using all loop inside a structure of the case, but I don't know how to start pressing a button to return to previous sequences. I need help on this particular part.

    Thanks in advance!

    The code that looks way too complicated for the problem you described.  Where is the state machine that we suggested to you?  Why so many useless people sequence structures?

  • BlackBerry smartphones, that I need help as soon as POSSIBLE please

    Hey, I need help with ym Blackberry Curve 9300

    I tried to download the new update to 6OS but it won't work, I downloaded the latest version of Blackberry Desktop software but every time I try and update my phone it just comes up with "a updated Blackberry Desktop software component must be installed to continue" but then when I click on 'install' it happens to not even 1/10th of a full bar and it's freezing I left it on all night and it still did not move 1 cm, someone please help as I really want to download the new software but ive been trying for days to do and it still does not work

    help would be appretiated,

    Thank you

    Do this way:

    See the link below to download it and follow these simple instructions.

    First find your operator and the system operating file that you want to use.
    http://NA.BlackBerry.com/eng/support/downloads/download_sites.jsp

    Make a backup of your device first, using Desktop Manager > backup. Close the office at the end Manager.

    1. download the OS files to the PC then install on the PC by running (double click) the downloaded file.
    2. go in c:\program files Research in motion\apploader and delete the file named "vendor.xml."
    3. plug in the BB and double-click on "Loader.exe." It is located in the same place as the above vendor.xml file.

  • Need help, cleaning of viruses on the computer purchased in 2001

    original title: I'm pleased if you help me with my Vista

    Hello

    My name is Boryana K. Kosseva and I'm from Bulgaria, Sofia.A years out, maybe to 2002 or 2001 even, I'm sorry but I don't remember not the data and year, my dad bought a computer from the U.S.The computer was with Windows installed, so I what is original. That's why I was wondering is it possible Microsoft to help me clean some viruses from my computer.

    I look forward to hearing from you soon.

    Your B.K.Kosseva

    Microsoft cannot help you with that, but here are two tutorials on the elimination of the virus:
    http://teengeek.freehostingcloud.com/help/scanforviruses/
    http://teengeek.freehostingcloud.com/help/scanforviruswithmrt/

    (they are on a site that I'm hosting)

    teengeek.freehostingcloud.com

  • Need help with a DC load, please help.

    OK, so I installed CC, and when I try to open it, it has a constant loading screen. PLEASEEE help I need PS for the work. I'm on a Macbook air.

    Hello

    Please try the steps of troubleshooting here App does not open. Wheel of progress constantly calls and let me know how it goes.

    ^ Ani

  • Need help to use while LOOP to run immediately

    Hello

    I use the Oracle 11 g R2 database.

    I need to use 'while' below statement so that I'm going to immediate execution with the following ranges in a LOOP.

    USING 100, 200
    USING 201, 300
    WITH THE HELP OF 301, 400
    USING 401, 500
    declare
    v_maxseq_id number:=100;
    v_minseq_id number:= 500;
    
    begin
    --WHILE LOOP
    
    EXECUTE IMMEDIATE 'insert /*+APPEND*/all into stage_parsed_while
    select * from STAGE_PARSED_h2 WHERE src_file = ''a'' AND load_date = ''03-apr-2013''
    and seq_id between :1 and :2'
    USING v_minseq_id , v_maxseq_id ;
    
    
    end;
    Kindly help... Thank you

    Your syntax for the While loop:

    set serveroutput on;
    declare
      i pls_integer := 101;
    begin
      while i < 500 loop
        dbms_output.put_line('Min :: ' ||i || '; Max :: ' || to_char(i + 99));
        i := i + 100;
      end loop;
    end;
    
    anonymous block completed
    Min :: 101; Max :: 200
    Min :: 201; Max :: 300
    Min :: 301; Max :: 400
    Min :: 401; Max :: 500
    

    And Yes, I'm agree with suggestion of knapen to accomplish the task with a single static SQL, rather than go for dynamic SQL (which is the first wrong approach) and then using loops to slow further (which would be another mistake).

  • I need help for Adobe Flash Player, please!

    I've been on several site trying to play games or watch videos (YouTube, for example) and get an error message saying that I need to install Adobe Flash Player in order to play/view.  I did this several times and currently have 11 ActiveX of Flash Player and Flash Player 11 Plugin.  That I do because it still doesn't let me see the video or play games.

    PLEASE HELP ME!

    Additional information: I found myself just download Google Chrome (but don't like) and do not have the same problem.  So, it happens only when I'm doing all this on Internet Explorer 9.

    Flash Player Help. Installation problems | Flash Player | Windows

    Mylenium

  • Need help with an Audio loop with ACE

    I built a graphic in which audio fades out on a button click. I need also the audio loop, but I can't understand how do. I fiddled it of some old code that I had, probably found on the net, and I don't know where to put the parameters in a loop. Everything that it works just like I need to, I just need the looping sound. Can anyone help? Here is the code:


    Create sound objects *.


    this.createEmptyMovieClip ("holder1", this.getNextHighestDepth ());
    var mySound1:Sound = new Sound (holder1);
    mySound1.loadSound ("yourmusicgoeshere.mp3", true);


    action button *.

    necessary variables:
    var onFaded:Function;
    var currentSound:Number = 1;
    var occupied: Boolean = false;
    var counter: Number;
    //

    B2.onRelease = function() {}
    fadeOut (mySound1);
    };

    B3.onRelease = function() {}
    fadeOut (mySound1);
    };

    bStop.onRelease = function() {}
    mySound1.stop ();
    currentSound = 0;
    };


    fade out function *.


    function fadeOut(theSound:Sound) {}
    counter = 100;
    busy = true;
    clearInterval (nInterval);
    nInterval = setInterval (adjustSoundDown, 10, theSound);
    }
    function adjustSoundDown(theSound:Sound) {}
    If (counter < = 1) {}
    clearInterval (nInterval);
    theSound.stop ();
    busy = false;
    onFaded();
    } else {}
    -counter;
    theSound.setVolume (counter);
    }
    }

    the best you can do if you are streaming your sound is to use a listener onsoundcomplete to restart your sound when it is finished.

  • I need help for a simple task (Please HELP)

    Hi, you know how you can create a badge and link it to another site with ActionScript in this program? Well I need to know in a way like... to make a button and... Bind it to the next section. OK, here is what im trying to do happen... the user presses a button in the flash program and an apperars comment. then they tap it once and a newcomer to the top... and so on... I do like 50 different frames with new comments on them and then create on each link of weft to the next section. is it possible to do? If there is I REALLY need your help. Please

    Thanks :)

    on (release) {}
    nextFrame();
    }

    the help documentation (F1):

    function nextFrame
    nextFrame(): Void

    Sends the playhead to the next section.

    Availability: ActionScript 1.0; Flash Player 2

    Example of
    In the following example, when the user presses the right or down arrow, the playhead goes to
    the next frame and stops. If the user presses the left or the arrow key, the playhead goes to the
    previous image and stops. The listener is initialized to wait the arrow key to be pressed, and
    the init variable is used to prevent the listener to be redefined if the playhead returns to
    Framework 1.

    Stop();

    If (init == undefined) {}
    someListener = new Object();
    someListener.onKeyDown = function() {}
    If (Key.isDown (Key.LEFT) |) {Key.isDown (Key.UP))}
    _level0.prevFrame ();
    } Else if (Key.isDown (Key.RIGHT) |) {Key.isDown (Key.DOWN))}
    _level0.nextFrame ();
    }
    };
    Key.addListener (someListener);
    init = 1;
    }

    ******************************************
    --> * Adobe Certified Expert *.
    --> www.mudbubble.com
    --> www.keyframer.com

    mybluehair wrote:
    > Hi, you know how you can create a badge and bind it to another site with the
    > actionscript in this program? Well I need to know in a way like... to make a
    > button and... Bind it to the next section. OK, here is what im trying to do
    > happen... the user presses a button in the flash program and a comment
    > apperars. then they tap it once and a newcomer to the top... and so on... I have
    > could make like 50 different frames with new comments on them and then make the
    > on each link of weft to the next section. is it possible to do? If
    > It is I REALLY need your help. Please
    >
    > Thanks :)
    >

  • Need help with lack of divers please

    Hello, my first post here (I don't know if this is the right forum to post this in)

    I just reformated laptop HP and it lacks a certain pilots, it is also unable to connect to the internet to update the drivers of my laptop could not be done, I tried looking for these drivers, but I hesitated because I was afraid I might mess up my laptop.

    I know it's a lot and I'm really sorry, but if someone could help me with this, it would be amazing.

    Here is the hardware ID I found, please let me know if one is bad, and I'll try to get the right pair.

    PCI VEN_1180 & DEV_0843 & SUBSYS_172B103C & REV_14

    PCI\VEN_8086 & DEV_10EA & SUBSYS_172B103C & REV_05

    PCI\VEN_8086 & DEV_4239 & SUBSYS_13118086 & REV_35

    PCI\VEN_8086 & DEV_3B67 & SUBSYS_172B103C & REV_06

    PCI\VEN_8086 & DEV_3B64 & SUBSYS_172B103C & REV_06

    PCMCIA\RICOH-Bay8Controller-F1B2

    And an unknown device with ID: ACPI\HPQ0004

    Again, I am sorry.

    Thank you

    Ricoh:

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?sp4ts.oid=4095873&spf_p.tpst=swdMain&spf_p.prp_swdMain=wsrp-navigationalState%3Didx%253D%257CswItem%253Dob_79317_1%257CswEnvOID%253D4059%257CitemLocale%253D%257CswLang%253D%257Cmode%253D%257Caction%253DdriverDocument&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

    Intel Lan:

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?sp4ts.oid=4095873&spf_p.tpst=swdMain&spf_p.prp_swdMain=wsrp-navigationalState%3Didx%253D%257CswItem%253Dob_101142_1%257CswEnvOID%253D4059%257CitemLocale%253D%257CswLang%253D%257Cmode%253D%257Caction%253DdriverDocument&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

    Intel wlan:

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?sp4ts.oid=4095873&spf_p.tpst=swdMain&spf_p.prp_swdMain=wsrp-navigationalState%3Didx%253D%257CswItem%253Dob_108502_1%257CswEnvOID%253D4059%257CitemLocale%253D%257CswLang%253D%257Cmode%253D%257Caction%253DdriverDocument&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

    other stuff of intel:

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?sp4ts.oid=4095873&spf_p.tpst=swdMain&spf_p.prp_swdMain=wsrp-navigationalState%3Didx%253D%257CswItem%253Dob_118167_1%257CswEnvOID%253D4059%257CitemLocale%253D%257CswLang%253D%257Cmode%253D%257Caction%253DdriverDocument&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

    HP 3d drive guard:

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?sp4ts.oid=4095873&spf_p.tpst=swdMain&spf_p.prp_swdMain=wsrp-navigationalState%3Didx%253D%257CswItem%253Dob_105198_1%257CswEnvOID%253D4059%257CitemLocale%253D%257CswLang%253D%257Cmode%253D%257Caction%253DdriverDocument&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

  • Laptop of HP Envy m6: really bad mistake (I still need help, an expert could you please help?)

    Hello. Recently, a Chair falls on my laptop... Don't ask me why. When I tried to start it, he said:

    Now, I just assumed it was a minor mistake, so I reinstalled all of my hard drive. He failed to solve the problem.

    The next day, when I tried to start my computer, my computer screen was black and issued a series of beeps. (They

    went as follows: Beeeeeep Beeeeep Beeeeep beep beep. BEEEEEEP Beeeeep Beeeep beep beep, etc...

    For your conviencance, I downloaded a video of the RAM sounds here:

    http://Tinypic.com/player.php?v=2cwwos7%3E&s=8#.VLbY9vm-2SP

    One of my RAM cards

    seems to be a little loose. (The card won't click into place and slide out of position, if I just tap). Help, please. Thank you!

    I hope this helps!
    If you think that I helped you, give me a little push upwards the button and press the button "accept as answer" so that others can find the answer so .

    Never mind, I fixed myself. Thanks to all who helped.

  • I need help for error #800070645 code please.

    When I install updates to the framework of microsoft automatic updates will not install help

    Microsoft .NET Framework 3.5 Family Update (KB959209) x 86
    they are not installed:
    family update Microsoft.net 3.5
    Security for microsoft 1.1SP1 framework update
    for framework 3.5 SP1 microsoft security update
    framework 4 microsoft security update
    I'm running Vista Home premium please help me

    Follow the steps in this article: http://support.microsoft.com/kb/KB976982

  • I NEED HELP FOR ERROR SYSTEM 70190610 PLEASE!

    I ASKED MY DAUGHTER TO SET UP A PASSWORD FOR ME, AND NOW I CAN'T ENTER NEW

    HE ME GIVES A 701906 ERROR CODE, THEN IT CRASHES PLEASE HELP THANKS!

    DIANA C.

    Hi Diana,

    Try to enter: 65898236

    Kind regards

    DP - K

  • Need help to upgrade my laptop please

    I have a 2100 g7z, series Pavilion G7 and want to add more memory and a disk hard ssd but do not know what ssd, I can get cause I did not open upward my and the specs I found don't say what are connections in there. So I was wondering if someone could help point me in the right direction for one SSD for laptop series Pavilion G7.  Thank you.

    Hey Bluice,.

    You have 2 available memory slots, with a maximum of 8 GB. It is possible to add an SSD, but you would need to remove the drive you currently have, because there is only 1 drive Bay.

    I hope this helps!
    Sean

  • Need help with the recursive query

    I have test table

    Create table test (key primary number col_pk,)

    number of fins,

    number of fo_fv

    number of jup_fv

    action varchar2 (10)

    );

    Insert into test values(1,1,1,1,'LOAD');

    Insert into test values(2,2,null,2,'ROLL');

    Insert into test values(3,3,null,3,'ROLL');

    Insert into test values(4,4,null,4,'ROLL');

    Insert into test values(5,5,null,5,'ROLL');

    Insert into test values (6, null, null, 5.1, 'FLATTEN');

    Insert into test values (7, null, null, 5.2, 'FLATTEN');

    Insert into test values(8,null,null,1,'SIGNOFF');

    Insert into test values (9, null, null, 1,001, 'SIGNOFF');

    Insert into test values(10,6,2,6,'LOAD');

    Insert into test values (11, null, null, 6.1, 'FLATTEN');

    Insert into test values(12,7,1,7,'RELOAD');

    Insert into test values(13,null,null,1,'SIGNOFF');

    Select * from test;

    I want the result of the query in the form below:

    COL_PK FINS FO_FV JUP_FV ACTION

    ---------- ---------- ---------- ---------- ----------

    1 1 1 1 LOAD

    --------------------------------------------------

    2 2 1 2 ROLL

    --------------------------------------------------

    3 3 1 3 ROLL

    --------------------------------------------------

    4 4 1 4 ROLL

    --------------------------------------------------

    ROLL 5 5 1 5

    --------------------------------------------------

    5.1 6 5 1 FLATTEN

    --------------------------------------------------

    7 5 1 5.2 FLATTEN

    --------------------------------------------------

    8 5 1 1 APPROVAL

    --------------------------------------------------

    9 5 1 APPROVAL 1,001

    --------------------------------------------------

    10 6 2 6 LOAD

    --------------------------------------------------

    11 6 2 6.1 FLATTEN

    --------------------------------------------------

    12 7 1 7 RELOAD

    --------------------------------------------------

    13 7 1 1 APPROVAL

    --------------------------------------------------

    Help, please

    Hello

    This sounds like a job for the analytical LAST_VALUE function:

    SELECT col_pk

    LAST_VALUE (fins IGNORE NULLS)

    COURSES (ORDER BY col_pk) AS fins2

    LAST_VALUE (fo_fv IGNORE NULLS)

    COURSES (ORDER BY col_pk) AS fo_fv2

    jup_fv

    action

    OF the test

    ORDER BY col_pk

    ;

    Output:

    COL_PK FINS2 FO_FV2 JUP_FV ACTION

    ---------- ---------- ---------- ---------- ----------

    1 1 1 1 LOAD

    2 2 1 2 ROLL

    3 3 1 3 ROLL

    4 4 1 4 ROLL

    ROLL 5 5 1 5

    5.1 6 5 1 FLATTEN

    7 5 1 5.2 FLATTEN

    8 5 1 1 APPROVAL

    9 5 1 APPROVAL 1,001

    10 6 2 6 LOAD

    11 6 2 6.1 FLATTEN

    12 7 1 7 RELOAD

    13 7 1 1 APPROVAL

Maybe you are looking for