Initializi​ng arrays

Hello!
I'm doing a program which works with arrays. I use initialize block arrays to create them. But it depends on other variables the dimension of these arrays. If I want to change the length of a dimension I wire a variable to the block, but I have no idea what can I wire to the block to modify the number of dimensions....it cannot be modify when the program is running?? How I have to do modify the number of dimensions depends on a variable?
Thank you in advance!
Larson

The initialize array function is a growable function, that is it changes the function inputs by dragging the dimensions not programatically.  There is a work around, you can use a case structure to call different versions of the function.  This will work but will only for a finite number of cases.  The other way is to initialize a multidimensional array as a single dimension and then pass it to the resize array function, i.e initialize ARRAY[i*j*k] and resize to ARRAY[i][j][k].  This is a little unusual to deal with arrays which change at runtime.  The final approach it to write polymorphic functions to handle the different cases, again you will not have full dynamic run-time handling of all possible cases but can handle a few cases easily.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA

Similar Messages

  • How do I initialize an array after getting xml data via httpservice?

    I am having a problem trying to initialize an array with data from an external xml file obtained via httpservice.  Any help/direction would be much appreciated.  I am using Flex 4 (Flash Builder 4).
    Here is my xml file (partial):
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Root>
        <Row>
            <icdcodedanddesc>00 PROCEDURES AND INTERVENT</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.0 THERAPEUTIC ULTRASOUND</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.01 THERAPEUTIC US VESSELS H</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.02 THERAPEUTIC ULTRASOUND O</icdcodedanddesc>
        </Row>
    </Root>
    Here is my http service call:
    <s:HTTPService id="icdcodeservice" url="ICD9V2MergeNumAndDescNotAllCodes.xml"
                           result="icdcodesService_resultHandler(event)" showBusyCursor="true"  />
    (I have tried resultFormat using object, array, xml).
    I am using this following Tour de Flex example as the base -http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500
    and updating it with the httpservice call and result handler.  But I cannot get the data to appear - I get [object Object] instead.  In my result handler code  I use "icdcodesar = new Array(event.result.Root.Row);"  and then "icdcodesar.refresh();".
    The key question is: How to I get data from an external xml file into an array without getting [object Object] when referencing the array entries.  Thanks much!
    (Tour de Flex example at http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500  follows)
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:local="*"
                   skinClass="TDFGradientBackgroundSkin"
                   viewSourceURL="srcview/index.html">
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            @namespace local "*";
            s|Label {
                color: #000000;
        </fx:Style>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                private var names:ArrayCollection = new ArrayCollection(
                    ["John Smith", "Jane Doe", "Paul Dupont", "Liz Jones", "Marie Taylor"]);
                private function searchName(item:Object):Boolean
                    return item.toLowerCase().search(searchBox.text) != -1;
                private function textChangeHandler():void
                    names.filterFunction = searchName;
                    names.refresh();
                    searchBox.dataProvider = names;
                private function itemSelectedHandler(event:SearchBoxEvent):void
                    fullName.text = event.item as String;   
            ]]>
        </fx:Script>
        <s:layout>
            <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" />
        </s:layout>
        <s:Panel title="Components Samples"
                 width="600" height="100%"
                 color="0x000000"
                 borderAlpha="0.15">
            <s:layout>
                <s:HorizontalLayout horizontalAlign="center"
                                    paddingLeft="10" paddingRight="10"
                                    paddingTop="10" paddingBottom="10"/>
            </s:layout>
            <s:HGroup >
                <s:Label text="Type a few characters to search:" />
                <local:SearchBox id="searchBox" textChange="textChangeHandler()" itemSelected="itemSelectedHandler(event)"/>
            </s:HGroup>
            <mx:FormItem label="You selected:" >
                <s:TextInput id="fullName"/>
            </mx:FormItem>
        </s:Panel>
    </s:Application>

    Hello,
    Instead of extracting the first zero element from the vid array, you should take that out and connect it allone.
    Attachments:
    init.bmp ‏339 KB

  • How to initialize the array of hashmap???

    how to initialize the array of hashmap??

    What do you mean by "the array of hashmap"?

  • How to initialize Button Array at "declaration"?

    How to initialize Button Array at "declaration"?
    Button[] b = new Button[2];
    b[0] = "label" ?
    b[1] = "label" ?
    Again,please at declaration not using setText within main program.

    main...
    Button[] btts = {new Button(...),new Button(...), ...)
    that shold be it
                                                                                                                                                                                   

  • Combined declaration and initialization of array

    Hello All,
    What is the difference between the below mentioned arrat initializations?
    int myArray[]=new int[] {1,2,3,4,5};
    int myArray[]={1,2,3,4,5};
    but both of them behaves in same way.
    Regards
    Sojan

    The first creates an anonymous array and copies its reference in the variable myArray. The second implicitly creates and initializes an array (there isn't really a perceptible difference). However, the second can only be used in declarations. Consider the following:
    int[] iArray = {1, 2, 3};
    iArray = new int[] {9, 8, 7}; // works
    iArray = {9, 8, 7}; // doesn't work !!!Hope this helps,
    Pierre

  • Initialize an array of union types

    Hi,
    I'm trying to the use the C99 designated initializer feature to initialize an array of union types, but I'm getting a compiler error as shown below. Am I using the correct syntax?
    #include <stdio.h>
    union U
         struct {int data;} a;
         struct {int type; float data;} b;
    int
    main()
         union U x = {.b.type = 2, .b.data = 1.0};
         union U y[] = {{.b.type = 2, .b.data = 1.0}};
         fprintf(stderr, "x b data: %f\n",    x.b.data);
         fprintf(stderr, "y b data: %f\n", y[0].b.data);
         return 0;
    }% cc u.c
    "u.c", line 13: structure/union designator used on non-struct/union type
    "u.c", line 13: structure/union designator used on non-struct/union type
    cc: acomp failed for u.c
    % cc -Version
    cc: Sun C 5.9 DEV 2006/06/08
    %

        union U x = { .b = { .type = 2, .data = 1.0 } };
        union U y[] = {{.b = { .type = 2, .data = 1.0}}};

  • Initialize indexes array

    Hello!
    I am new to LabView and  I am struggling with this problem for a couple of days...
    I have a 2D array CH x spike_time and on each row (1D array) I need to implement a logic that requires the possibility to dynamically initialize two indexes.  
    To be more clear, if I indicate with CH each row of the 2D array, this is the logic I should implement on each row:
    i=0;
    while i <= N-min_burst_size
    {  j=i+1;
       while ch(j) AND ch(i)-ch(j) <= Inter_spke_interval AND j <= N-1
        {j=j+1;}
        if j-i+1 >= min_burst_size then save(i,j); 
        i=j;
    What is the best way to implement this logic in labview?
    How can I manipulate the value of the indxes i and j to initialize them as in the code? I tried to use the "Subset of Array" function in order to "cut" subset of the row starting from i and j and shift registers to pass the subset again as input of the loop, but I couldn't get to anywhere close to a solution.
    If anyone could share some ideas with me or has a useful similar vi, I would be very thankful!
    Thank you so much!
    Solved!
    Go to Solution.

    MG70 wrote:
    Thank you Hoovahh and GerdW for helping me!!
    No problem.  In the spirit of teaching I'd like to teach you another trick on the forums.  The large majority of us work on these forums for free, and the recognition we get partialy comes from the number of posts we are able to answer, and the number of kudos we get for helping others.  So feel free to give kudos to those that help you, and mark topics solved by a post that solves your question.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Initialize object array without specifying dimention

    Hi,
    Can anybody help me in suggesting a solution for this:
    I have a class called Test. I can create instance array and initialize for class Test using
    Test test[] = {new Test(), new Test()};
    or
    Test test[] = new Test[100];
    statement.
    How can I give infinite initialization for Test
    Thank you
    Regards
    Anoop

    Anoop.Retna wrote:
    Hi,
    Can anybody help me in suggesting a solution for this:
    I have a class called Test. I can create instance array and initialize for class Test using
    Test test[] = {new Test(), new Test()};
    or
    Test test[] = new Test[100];
    statement.
    How can I give infinite initialization for TestYou can't. There's no such thing.
    If you want a container that can expand to accomodate a variable number of items you can use a List.
    %

  • Multiple variable initialization using arrays

    Hi,
    In my program I want to initialize some 20 odd variables(all of the same type) to the same value having their names as Input1, Input 2 .. Input 20. Want I want to do is to use an array to do this rather than writing the 20 variables one after the other. Is there any way to do so ?
    Please help.
    Thanx in advance,
    Gaurav

    Hi Again,
    I am sorry for framing the question wrongly. What i want exactly is this :
    I want to create a variable no. of arrays (the number of arrays will be inputed by the user). I want to initialize them ,something like this
    int Input1 [] = new int [400];
    int Input2 [] = new int [400];
    After this initialization I will then fill these with some info. from a file and then use it in my program.
    So I want to use a for loop or some other loop so that I can achieve this.
    Please help,
    Thanks
    Gaurav

  • Any way to Initialize Java Array to start with 1

    Hi Friends,
    Is there anyway to initialize the java array with starting with 1 instead of normal 0.
    Thanks and Regards.
    JG

    JamesGeorge wrote:
    Hi Jacob,
    Thanks for you time..
    Coding like 1 - n will make everything uneasy, I find in other languages like vbscript,lotusscript it can be done..so just a thought to check in Java too..
    Is there any valid reason for Java/Sun guys to start the arrays,vectors and other collections with 0
    Thanks
    JJShort answer: Java is a C-based language, and C arrays are zero-based so the rest are also zero-based for consistency.
    Long answer: Arrays are implemented as contiguous areas of memory starting from a certain memory address, and loading from a zero-based array implies one less CPU instruction than loading from a one-based array.
    Zero-based:
    - LOAD A, ArrayAddress
    - LOAD B, Index
    - MUL B, ElementSize
    - ADD A, B
    - LOAD (A)
    One-based:
    - LOAD A, ArrayAddress
    - LOAD B, Index
    - ADD B, -1
    - MUL B, ElementSize
    - ADD A, B
    - LOAD (A)

  • Initialization of Array

    Hi
    Is possible to initialize a collection of record (or varray) with values without to need to use a loop ?
    Example I must to initialize a multidimensional array
       TYPE  rec_names IS RECORD (
          cod_cli1    varchar(6),
          zipcode1   char(8),
          city1      VARCHAR2(30),
          state1      char(2),
          cod_cli2    varchar(6),
          zipcode2   char(8),
          city2      VARCHAR2(30),
          state2      char(2)
       Is possible build a array with initialization without to do a loop ?
    tia

    Hi,
    Maybe in the type declaration you can put a default value:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> SET SERVEROUTPUT ON
    SET SERVEROUTPUT ON
    SQL> DECLARE
    DECLARE
      2     TYPE rec_names IS RECORD(
       TYPE rec_names IS RECORD(
      3        cod_cli1 VARCHAR(6) := '0',
          cod_cli1 VARCHAR(6) := '0',
      4        zipcode1 CHAR(8),
          zipcode1 CHAR(8),
      5        city1    VARCHAR2(30),
          city1    VARCHAR2(30),
      6        state1   CHAR(2),
          state1   CHAR(2),
      7        cod_cli2 VARCHAR(6),
          cod_cli2 VARCHAR(6),
      8        zipcode2 CHAR(8),
          zipcode2 CHAR(8),
      9        city2    VARCHAR2(30),
          city2    VARCHAR2(30),
    10        state2   CHAR(2));
          state2   CHAR(2));
    11     v_rec_names rec_names;
       v_rec_names rec_names;
    12  BEGIN
    BEGIN
    13     DBMS_OUTPUT.put_line('v_rec_names.cod_cli1:' || v_rec_names.cod_cli1);
       DBMS_OUTPUT.put_line('v_rec_names.cod_cli1:' || v_rec_names.cod_cli1);
    14     v_rec_names.cod_cli1 := 'b';
       v_rec_names.cod_cli1 := 'b';
    15     DBMS_OUTPUT.put_line('v_rec_names.cod_cli1:' || v_rec_names.cod_cli1);
       DBMS_OUTPUT.put_line('v_rec_names.cod_cli1:' || v_rec_names.cod_cli1);
    16  END;
    END;
    17  /
    v_rec_names.cod_cli1:0
    v_rec_names.cod_cli1:b
    PL/SQL procedure successfully completed
    SQL> Regards,

  • How to initialize Object  Array Data Provider (OADP)with data from txt file

    Hi,
    I want to show in a table some columnar data from a txt file. I ran the creator demo application on OADP successfully. http://blogs.sun.com/divas/entry/using_the_object_array_data
    I created a javabean class to read a txt file.However, I am stuck at how I can fill the data into an OADP array:
    I am familiar with C extensively but not much at java. can anyone help??
    thanks..
    dr.am.mohan rao

    Thanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
    end;
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
    AND voucher_line_num = v_line_in;
    BEGIN
    --voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
    --' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
    voucher_comment := sysadm.ap_comment_coll(null);
    IF v_line_in = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              if i > 1
              then
                   voucher_comment.EXTEND;
              end if;
    voucher_comment (i) := ap_comment_type (v_bu_in,
    v_voucher_in, v_line_num, v_userid,
    TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.extend(6);
    voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;

  • Attempting to initialize an array of MAX Aliases is throwing an error on first loop's iteration.​..

    Hey folks, 
    I'm gonna ttach a photo of what's in place right now.
    I think the DELAY init vi is good to go for this application because I have it working in another vi but it's just not applied in the same array/for-loop config.  
    However inside that init vi, I get an error from the VISA Open. (Only when I try to execute the code in the looped fashion at the top of the picture).  Do any of you guys see anything I'm missing here?   It's almost like the string element (alias name) isn't being indexed into place?
    Thanks for your time!
    -pat
    Solved!
    Go to Solution.
    Attachments:
    thanks for looking.JPG ‏126 KB

    These are two other attempts I couldn't get to work either (the init vi is the same).
     EDIT: just noticed that my error in isn't wired up... but it still doesnt work with it wired in, I thought maybe I got the old error on the first iteration... got excited.
    Attachments:
    Delay DVR Array.jpg ‏100 KB
    Delay DVR Array 2.jpg ‏127 KB

  • How Do I Initialize an Array of Array Objects?

    I have an NSMutableArray object that stores NSMutableArray objects.
    For example
    - (void)loadMainArray
    NSMutableArray *tempAry = [[NSMutableArray alloc] init];
    //mainArray defined in header
    self.mainArray = tempAry;
    self.mainArray = [self loadSubArrays];
    [tempAry release];
    - (NSMutableArray *)loadSubArrays
    NSMutableArray *tempAry = [[NSMutableArray alloc] init];
    self.subArray = tempAry; //subArray defined in header
    [tempAry release];
    //populate subArray with data using [subArray addObject:blah]
    return self.subArray;
    This works perfectly when first running the app. Each successive call however to loadMainArray fails, causing a “EXCBADACCESS” error. I'm assuming that once that mainArray is populated, it isn't as easy as just re-assigning it. I have tried running through the array and removing the objects one by one. That doesn't work. I have tried re-initializing the entire array (as shown)...doesn't work...I'm stuck...any ideas what might be the problem?
    If it helps, this is how I have defined mainArray and subArray in my headers:
    NSMutableArray *mainArray;
    @property (nonatomic, retain) NSMutableArray *mainArray;

    mnemonic_fx wrote:
    Why do it in such a inconvenient way ?
    - (NSMutableArray *)loadSubArrays
    self.subArray = [NSMutableArray array]; //subArray defined in header
    // populate subArray with data using [subArray addObject:blah]
    return self.subArray;
    - (void)loadMainArray
    //mainArray defined in header
    self.mainArray = [NSMutableArray arrayWithArray:[self loadSubArrays]];
    Message was edited by: mnemonic_fx
    Unfortunately, this gives the same exact error. Just to be a bit more clear, my mainArray consists of n subArray objects. Each subArray object consists of m objects. (where 'n' and 'm' are variable depending on the data I'm loading)
    When I first launch my app, my mainArray object loads just fine. However, when I try to alter my mainArray object in ANY way once it is populated, it crashes with the above error. I have tried to manually go through and do a replaceObjectAtIndex for each individual element. I have tried to just release the entire array, I have tried to call my loadSubArray method which returns a full new list. I'm not finding any debug info that is helping me with the issue.
    any info would be great!

  • How to initialize the array with object?

    Here is type I have.
    CREATE OR REPLACE TYPE SYSADM.AP_COMMENT_TYPE AS OBJECT
    BU_AP VARCHAR2(5),
    VOUCHER VARCHAR2(10),
    V_LINE INTEGER,
    USERID VARCHAR2(20),
    COMMENT_DTTM DATE,
    COMMENT VARCHAR2(254)
    CREATE OR REPLACE TYPE SYSADM.AP_COMMENT_COLL AS VARRAY(1000) OF SYSADM.AP_COMMENT_TYPE;
    Then I created a procedure to grab some data.
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed
    FROM ps_fas_ap_comment
    WHERE business_unit = voucher_comment (i).bu_ap
    AND voucher_id = voucher_comment (i).voucher;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed
    FROM ps_fas_ap_comment
    WHERE business_unit = voucher_comment (i).bu_ap
    AND voucher_id = voucher_comment (i).voucher
    AND voucher_line_num = voucher_comment (i).v_line;
    BEGIN
    voucher_comment (1) := ap_comment_type (' ', ' ', 0, ' ', '', ' ');
    --voucher_comment (1) := ap_comment_type (null, null, null, null, null,null);
    IF voucher_comment (i).v_line = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              voucher_comment.EXTEND;
    voucher_comment (i) :=
    ap_comment_type (v_bu_in,
    v_voucher_in,
    v_line_num,
    v_userid,
    TO_DATE (TO_CHAR (SYSDATE,
    'DD-MON-YYYY HH24:MI:SS'
    'DD-MON-YYYY HH24:MI:SS'
    v_comments
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.EXTEND;
    voucher_comment (i) :=
    ap_comment_type (v_bu_in,
    v_voucher_in,
    v_line_num,
    v_userid,
    TO_DATE (TO_CHAR (SYSDATE,
    'DD-MON-YYYY HH24:MI:SS'
    'DD-MON-YYYY HH24:MI:SS'
    v_comments
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;
    But when I tried to test the procedure, got error: ORA-06531: Reference to uninitialized collection. Does anyone have experience of handling array with object?
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL;
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 1, 'KEHE', O_voucher_comment);
    end;

    Thanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
    end;
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
    AND voucher_line_num = v_line_in;
    BEGIN
    --voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
    --' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
    voucher_comment := sysadm.ap_comment_coll(null);
    IF v_line_in = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              if i > 1
              then
                   voucher_comment.EXTEND;
              end if;
    voucher_comment (i) := ap_comment_type (v_bu_in,
    v_voucher_in, v_line_num, v_userid,
    TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.extend(6);
    voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;

Maybe you are looking for