Create static references array

Hello,
i have done a labview program which controls six different test machines.
the different tests are VIs which are kept by the main program in an array of static references. this way i have to write the vi only once. afterwards i create six different references of the same vi, each of them managing one test machine.
everything is working fine. the only drawback I have found, is how to create the six references of each VI.
the first thing I tried, was to locate the static reference function inside a loop. I enabled indexing, and i expected to obtain an array of six different references of the same vi. unfortunately this is not working: i obtain an array with six times the same reference.
to fix this, i located the static reference function inside a switch with six cases. all of this, inside the same loop. i have to use the static reference function six times, one for each test machine. this is working, but is more work. everytime a add a new test vi, I have to add the switch with the six cases. it is a lot of copy & paste work, and errors are likely to be done doing this.
I would like to know if there is any other (and simpler) way of obtaining this array.
enclosed you find an example showing this: the upper loop creates an array of six references but all of them are the same. the other one, uses a switch-case so that different references are generated.
thank you in advance
Attachments:
static references array.zip ‏11 KB

I think you missed the point of what I was getting at. If you create a template VI and programmatically open a reference to it 6 times you will get references to 6 independent instances of the template all running in memory. Nothing needs to get saved to disk. If the template changes simply close the 6 old references and open 6 new ones.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

Similar Messages

  • Static references to images

    Adobe RoboHelp 7 creates static references for images I
    import into my webhelp pages. Aside from manually converting the
    references to relative references, how can I get RH7 to correctly
    reference my images?

    Hi there
    I'm not sure what's up with your version of RoboHelp 7. Maybe
    it's how you are inserting images? I've never known RoboHelp to
    ever really create absolute references to images. It has always
    been quite adept at creating relative references.
    Are you absolutely certain absolute references are being
    created? I ask, because when you initially select an image by
    browsing to it, the reference may look like an absolute reference
    until you click OK to commit the information to the page. If you
    examine the properties later, the image has been copied to the
    project and bears a relative path.
    Cheers... Rick

  • How to assign values to instances of a method created via an array

    i have created an array of the PlayerRecord instance called currentPlayers and im trying to use another array of Strings to give names to the players (currentPlayers[instance].name) but it is failing horribly
    when i try to name them one at a time as seen in the code here it seems to compile fine, but when i test it with a System.out.println(currentPlayers[0].name); it tells me "Exception in thread "main" java.lang.NullPointerException"
    Im assuming this happens because the instances of PlayerRecord were created using an array, therefore i could not give the PlayerRecord a name value to begin with, but shouldnt currentPlayers[0].name = namesarray[0]; make up for that and give the value in namesarray[0] to currentPlayers[0].name? therefore allowing me to display the value held in currentPlayers[0].name without the error?
    public class Round
         public static PlayerRecord[] currentPlayers = new PlayerRecord[15];
         public Round(String[] namesarray)
         currentPlayers[0].name = namesarray[0];
         System.out.println(currentPlayers[0].name);     
    public class test
      public static void main (String[] args)
      String[] namelist= {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l","m", "n", "o", "p"};
      Round one = new Round(namelist);
    public class PlayerRecord
         public String name;
         public PlayerRecord(String playername)
              name = playername;
    }

    unfortunately the rest of the program relies on being
    able to change the number of elements in the array,
    so in the end a variable would take the place of the
    15 in
    public static PlayerRecord[] currentPlayers =
    new PlayerRecord[15];so that would not work
    It 'works', just not the way you supposed it would. :^)
    It initializes an array of 15 elements with references to type Round. You need to assign those references to instances. The only way to create instances is via the 'new' keyword.
    im surprised java isnt up there in the top reasons
    for suicide
    It's too early in the week for me to start drinking.....
    actually now that i think about it, i could make it
    work by having a definite amount of elements in the
    array, but the array of names cannot be read since
    they are connected to the Round method
    Correct me if I am wrong, but you do already have a definite number of elements in your array. 15.
    so basically the creation of the array of
    currentPlayers has to be before the Round method, yet
    the naming of the players has to happen in the Round
    method, is there any way this can be done?
    Round is not a method. It is your class's constructor (I think). Right before calling the setter for 'name', call 'new' and assign the created Round instance to that array element (in your case '0').
    Then call 'name'.
    Message was edited by:
    s34nsm411- Saish

  • Scripting: Create Cluster in Array from existing cluster

    I am creating a custom programming tool to generate some custom LabVIEW TypeDefs.
    One of the structures I have to create is an array of clusters; but from an existing cluster.  That is, I have a reference to a previously defined cluster, and I need to array this.
    One possible way to do this is to duplicate the cluster next to the empty array, and then 'move it into' the array.  This seems to be an ugly solution.
    Is there a better way?  When I try and use "Create from Reference" method, the cluster is created in the array, but the sub-elements trigger error 0x421: Type Mismatch.
    Thanks!
    Jed

    Hi Viper,
    Sorry- you misunderstand.  We are talking about doing this with LV Scripting; what you did statically defines the array type in the VI.  Writing LV code that would create the array from an undefined array by running a VI.  (In the situation above, the code would actually EDIT the VI and change it's functionality)
    There are a few examples in the distro if you search for "scripting", but here's a page with some example code you can look at.
    http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/wiring_scripting_objects/

  • Open VI reference from a static reference

    Hello guys,
    To open VIs dynamically, instead of hardcoding the VI name in a string constant, I do this as shown below to keep a dependency to my VI, so if someone ever delete the VI from the project, move it, rename it, it will create a broken wire somewhere so we'll be able to fix it faster.
    However, don't you think it's a bit weird to have the reference to the VI already, but we need to open a new reference, is there a way to get rid of the property node to get the VI path? Is the static VI reference should be closed after the other reference is opened?
    Would it make sense to be able to right clic the static reference and specify the option to open a call and forget reference?
    Is there a better practice?
    Cheers,
    Solved!
    Go to Solution.

    From the LabVIEW help:
    vi path accepts a string containing the name of the VI that you want to reference or a path to the VI that you want to reference. If you wire a name string, the string must match the full delimited name of a VI in memory on that target. If you wire a path, LabVIEW searches for a VI in memory that you previously loaded from that path on the same target. If a matching VI is not found in memory, LabVIEW then tries to load the VI from that file on disk. An error occurs if LabVIEW cannot find the file or if the file conflicts with another VI in memory.
    So, basically, if you use the string, you load the VI in memory and get an error if not found.  If you use path, it will still use the VI in memory at that path, or attempt to load it.  In your case, it won't make much difference.  I typically use VI Name myself since I know it is in memory.

  • What are right parameter types of ODCIIndexInsert in case of creating indextype WITH ARRAY DML option (documentation mismatch)

    Hello.
    During developing Domain Index for Oracle 11.2.0.1.0 (problem also appears in 12с) i was faced with misunderstanding of parameter types of function
    ODCIIndexInsert in case of creating indextype  WITH ARRAY DML option
    According to Oracle documentation
    http://docs.oracle.com/cd/E11882_01/appdev.112/e10765/ext_idx_ref.htm#i76892
    In case of  WITH ARRAY DML option Oracle will invoke ODCIIndexInsert with following signature
    FUNCTION ODCIIndexInsert(
      ia ODCIIndexInfo,
      ridlist ODCIRidList,
      newvallist varray_of_column_type,
      env ODCIEnv)
    RETURN NUMBER
    In my case indexed column has datatype NUMBER so i defined varray_of_column_type as SYS.ODCINumberList
    STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, ridlist in sys.ODCIRidList,  newvallist in sys.ODCINumberList, env in SYS.ODCIEnv) RETURN NUMBER
    Indextype was created as
    CREATE INDEXTYPE test_index_type
    FOR
    test_eq(number, number)
    USING index_methods
    WITH ARRAY DML(number, sys.ODCINumberList)
    WITH LOCAL RANGE PARTITION
    WITH SYSTEM MANAGED STORAGE TABLES;
    or
    CREATE INDEXTYPE test_index_type
    FOR
    test_eq(number, number)
    USING index_methods
    WITH ARRAY DML
    WITH LOCAL RANGE PARTITION
    WITH SYSTEM MANAGED STORAGE TABLES;
    (problem occurs in all cases)
    CREATE TABLE test_table (id NUMBER (19,0));
    CREATE INDEX test_index ON test_table(id) INDEXTYPE IS test_index_type;
    When attempting to insert data in the table
    insert into test_table values (1);
    oracle raise exception
    Error starting at line 53 in command:
    insert into test_table values (1)
    Error at Command Line:53 Column:1
    Error report:
    SQL Error: ORA-29925: cannot execute SCOTT.INDEX_METHODS.ODCIINDEXINSERT
    ORA-06553: PLS-306: wrong number or types of arguments in call to 'ODCIINDEXINSERT'
    ORA-06553: PLS-306: wrong number or types of arguments in call to 'ODCIINDEXINSERT'
    29925. 00000 -  "cannot execute %s"
    *Cause:    The specified function does not exist or does not have an
               appropriate signature.
    *Action:   Implement the function with the appropriate signature.
    So my question is.
    Is it normal behavior  of oracle (according to documentation)?
    What is correct signature of ODCIIndexInsert function in case of INDEXTYPE creation with 'WITH ARRAY DML' option and fact that indexed column has NUMBER datatype?
    By the way if i define indextype without 'WITH ARRAY DML' option signature is clear, and working. But this approach doesn't satisfies our performance needs.
    Also if i define index type with option 'WITH ARRAY DML WITHOUT COLUMN DATA' and use signature
    static function ODCIIndexInsert(ia sys.odciindexinfo,   ridlist sys.odciridlist, env sys.ODCIEnv) return number
    Everything works too. But this approach doesn't satisfies our business needs.
    Is it a way to define ODCIIndexInsert  parameter types (in case of indexing number column)  so that batch inserting works according to documentation ?
    FUNCTION ODCIIndexInsert(
          ia ODCIIndexInfo,
          ridlist ODCIRidList,
          newvallist varray_of_column_type,
          env ODCIEnv)
    I am attaching full sql script to recreate environment and reproduce the problem.
    Type definition:
    CREATE OR REPLACE TYPE index_methods AS OBJECT
      step number,
      STATIC FUNCTION ODCIGetInterfaces(ifclist OUT SYS.ODCIObjectList) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexCreate (ia SYS.ODCIIndexInfo, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexAlter (ia sys.ODCIIndexInfo, parms IN OUT VARCHAR2, altopt number, env sys.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexDrop(ia SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexExchangePartition(ia SYS.ODCIIndexInfo, ia1 SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexUpdPartMetadata(ia sys.ODCIIndexInfo, palist sys.ODCIPartInfoList, env sys.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, ridlist in sys.ODCIRidList,  newvallist in sys.ODCINumberList, env in SYS.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexDelete(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, env SYS.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexUpdate(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, newval number, env SYS.ODCIEnv) RETURN NUMBER,
      STATIC FUNCTION ODCIIndexStart(sctx IN OUT index_methods, ia SYS.ODCIIndexInfo,
        op SYS.ODCIPredInfo, qi sys.ODCIQueryInfo, strt number, stop number, cmpval number, env SYS.ODCIEnv) RETURN NUMBER,
      MEMBER FUNCTION ODCIIndexFetch(self IN OUT index_methods, nrows NUMBER, rids OUT SYS.ODCIridlist, env SYS.ODCIEnv) RETURN NUMBER,
      MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER
    CREATE OR REPLACE TYPE BODY index_methods IS
    STATIC FUNCTION ODCIGetInterfaces(ifclist OUT sys.ODCIObjectList) RETURN NUMBER IS
    BEGIN
      ifclist := sys.ODCIObjectList(sys.ODCIObject('SYS','ODCIINDEX2'));
      RETURN ODCIConst.Success;
    END ODCIGetInterfaces;
    STATIC FUNCTION ODCIIndexCreate (ia sys.ODCIIndexInfo, parms VARCHAR2,  env sys.ODCIEnv) RETURN NUMBER IS
    BEGIN
      RETURN ODCIConst.Success;
    END ODCIIndexCreate;
    STATIC FUNCTION ODCIIndexDrop(ia sys.ODCIIndexInfo, env sys.ODCIEnv) RETURN NUMBER IS
    BEGIN
      RETURN ODCIConst.Success;
    END ODCIIndexDrop;
    STATIC FUNCTION ODCIIndexAlter (
      ia sys.ODCIIndexInfo,
      parms IN OUT VARCHAR2,
      altopt NUMBER,
      env sys.ODCIEnv)
    RETURN NUMBER IS
    BEGIN
      RETURN ODCIConst.Success;
    END ODCIIndexAlter;
    STATIC FUNCTION ODCIIndexUpdPartMetadata(
      ia sys.ODCIIndexInfo,
      palist sys.ODCIPartInfoList,
      env sys.ODCIEnv)
    RETURN NUMBER IS
    BEGIN
      RETURN ODCIConst.Success;
    END ODCIIndexUpdPartMetadata;
    STATIC FUNCTION ODCIIndexExchangePartition(
      ia sys.ODCIIndexInfo,
      ia1 sys.ODCIIndexInfo,
      env sys.ODCIEnv)
    RETURN NUMBER IS
    BEGIN
      RETURN ODCIConst.Success;
    END ODCIIndexExchangePartition;
    STATIC FUNCTION ODCIIndexInsert(
       ia sys.ODCIIndexInfo,
       ridlist sys.ODCIRidList,
       newvallist sys.ODCINumberList,
       env sys.ODCIEnv)
    RETURN NUMBER IS
    BEGIN
      return ODCIConst.Success;
    END;
    STATIC FUNCTION ODCIIndexDelete(
       ia SYS.ODCIIndexInfo,
       rid VARCHAR2,
       oldval number,
       env SYS.ODCIEnv)
    RETURN NUMBER IS
    BEGIN
      return ODCIConst.Success;
    END;
    STATIC FUNCTION ODCIIndexUpdate(
       ia SYS.ODCIIndexInfo,
       rid VARCHAR2,
       oldval number,
       newval number,
       env SYS.ODCIEnv)
    RETURN NUMBER AS
    BEGIN
      return ODCIConst.Success;
    END;
    STATIC FUNCTION ODCIIndexStart(
      sctx IN OUT index_methods,
      ia SYS.ODCIIndexInfo,
      op SYS.ODCIPredInfo,
      qi sys.ODCIQueryInfo,
      strt number,
      stop number,
      cmpval  number,
      env SYS.ODCIEnv)
    RETURN NUMBER AS
    BEGIN
      sctx := index_methods(1);
      return ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIIndexFetch(
      self IN OUT index_methods,
      nrows NUMBER,
      rids OUT SYS.ODCIridlist,
      env SYS.ODCIEnv)
    RETURN NUMBER AS
    BEGIN
      return ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER AS
    BEGIN
      return ODCIConst.Success;
    END;
    end;
    Problem workaround:
    --drop function test_eq_fun;
    CREATE FUNCTION test_eq_fun(a number, b number) RETURN NUMBER AS
    BEGIN
      IF a = b then
        RETURN 1;
      ELSE
        RETURN 0;
      END IF;
    END;
    --drop operator test_eq;
    CREATE OPERATOR test_eq
    BINDING (number, number) RETURN NUMBER
    USING test_eq_fun;
    --drop indextype test_index_type;
    CREATE INDEXTYPE test_index_type
    FOR
    test_eq(number, number)
    USING index_methods
    WITH ARRAY DML(number, sys.ODCINumberList)
    WITH LOCAL RANGE PARTITION
    WITH SYSTEM MANAGED STORAGE TABLES;
    CREATE INDEXTYPE test_index_type
    FOR
    test_eq(number, number)
    USING index_methods
    WITH ARRAY DML
    WITH LOCAL RANGE PARTITION
    WITH SYSTEM MANAGED STORAGE TABLES;
    --drop table test_table;
    CREATE TABLE test_table (id NUMBER (19,0));
    CREATE INDEX test_index ON test_table(id) INDEXTYPE IS test_index_type;
    insert into test_table values (1);

    I get single for 1 row and batch for 2 or more rows in the following simplified simulation.
    SCOTT@orcl12c> DESC SYS.ODCINUMBERLIST
    SYS.ODCINUMBERLIST VARRAY(32767) OF NUMBER
    SCOTT@orcl12c> CREATE OR REPLACE TYPE index_methods AS OBJECT
      2  (
      3    step number,
      4    STATIC FUNCTION ODCIGetInterfaces(ifclist OUT SYS.ODCIObjectList) RETURN NUMBER,
      5    STATIC FUNCTION ODCIIndexCreate (ia SYS.ODCIIndexInfo, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER,
      6    STATIC FUNCTION ODCIIndexAlter (ia sys.ODCIIndexInfo, parms IN OUT VARCHAR2, altopt number, env sys.ODCIEnv) RETURN NUMBER,
      7    STATIC FUNCTION ODCIIndexDrop(ia SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
      8    STATIC FUNCTION ODCIIndexExchangePartition(ia SYS.ODCIIndexInfo, ia1 SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
      9    STATIC FUNCTION ODCIIndexUpdPartMetadata(ia sys.ODCIIndexInfo, palist sys.ODCIPartInfoList, env sys.ODCIEnv) RETURN NUMBER,
    10    STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, rid in VARCHAR2,  newval in NUMBER, env in SYS.ODCIEnv) RETURN NUMBER,
    11    STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, ridlist in sys.ODCIRidList,  newvallist in your_type, env in SYS.ODCIEnv) RETURN NUMBER,
    12    STATIC FUNCTION ODCIIndexDelete(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, env SYS.ODCIEnv) RETURN NUMBER,
    13    STATIC FUNCTION ODCIIndexUpdate(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, newval number, env SYS.ODCIEnv) RETURN NUMBER,
    14    STATIC FUNCTION ODCIIndexStart(sctx IN OUT index_methods, ia SYS.ODCIIndexInfo,
    15       op SYS.ODCIPredInfo, qi sys.ODCIQueryInfo, strt number, stop number, cmpval number, env SYS.ODCIEnv) RETURN NUMBER,
    16    MEMBER FUNCTION ODCIIndexFetch(self IN OUT index_methods, nrows NUMBER, rids OUT SYS.ODCIridlist, env SYS.ODCIEnv) RETURN NUMBER,
    17    MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER
    18  );
    19  /
    Type created.
    SCOTT@orcl12c> CREATE OR REPLACE TYPE BODY index_methods IS
      2  STATIC FUNCTION ODCIGetInterfaces(ifclist OUT sys.ODCIObjectList) RETURN NUMBER IS
      3  BEGIN
      4    ifclist := sys.ODCIObjectList(sys.ODCIObject('SYS','ODCIINDEX2'));
      5    RETURN ODCIConst.Success;
      6  END ODCIGetInterfaces;
      7
      8  STATIC FUNCTION ODCIIndexCreate (ia sys.ODCIIndexInfo, parms VARCHAR2,  env sys.ODCIEnv) RETURN NUMBER IS
      9  BEGIN
    10    RETURN ODCIConst.Success;
    11  END ODCIIndexCreate;
    12
    13  STATIC FUNCTION ODCIIndexDrop(ia sys.ODCIIndexInfo, env sys.ODCIEnv) RETURN NUMBER IS
    14  BEGIN
    15    RETURN ODCIConst.Success;
    16  END ODCIIndexDrop;
    17
    18  STATIC FUNCTION ODCIIndexAlter (
    19    ia sys.ODCIIndexInfo,
    20    parms IN OUT VARCHAR2,
    21    altopt NUMBER,
    22    env sys.ODCIEnv)
    23  RETURN NUMBER IS
    24  BEGIN
    25    RETURN ODCIConst.Success;
    26  END ODCIIndexAlter;
    27
    28  STATIC FUNCTION ODCIIndexUpdPartMetadata(
    29    ia sys.ODCIIndexInfo,
    30    palist sys.ODCIPartInfoList,
    31    env sys.ODCIEnv)
    32  RETURN NUMBER IS
    33  BEGIN
    34    RETURN ODCIConst.Success;
    35  END ODCIIndexUpdPartMetadata;
    36
    37  STATIC FUNCTION ODCIIndexExchangePartition(
    38    ia sys.ODCIIndexInfo,
    39    ia1 sys.ODCIIndexInfo,
    40    env sys.ODCIEnv)
    41  RETURN NUMBER IS
    42  BEGIN
    43    RETURN ODCIConst.Success;
    44  END ODCIIndexExchangePartition;
    45
    46  STATIC FUNCTION ODCIIndexInsert(
    47      ia sys.ODCIIndexInfo,
    48      rid VARCHAR2,
    49      newval NUMBER,
    50      env sys.ODCIEnv)
    51  RETURN NUMBER IS
    52  BEGIN
    53    dbms_output.put_line ('single');
    54    return ODCIConst.Success;
    55  END;
    56
    57  STATIC FUNCTION ODCIIndexInsert(
    58      ia sys.ODCIIndexInfo,
    59      ridlist sys.ODCIRidList,
    60      newvallist your_type,
    61      env sys.ODCIEnv)
    62  RETURN NUMBER IS
    63  BEGIN
    64    dbms_output.put_line ('batch');
    65    return ODCIConst.Success;
    66  END;
    67
    68  STATIC FUNCTION ODCIIndexDelete(
    69      ia SYS.ODCIIndexInfo,
    70      rid VARCHAR2,
    71      oldval number,
    72      env SYS.ODCIEnv)
    73  RETURN NUMBER IS
    74  BEGIN
    75    return ODCIConst.Success;
    76  END;
    77
    78  STATIC FUNCTION ODCIIndexUpdate(
    79      ia SYS.ODCIIndexInfo,
    80      rid VARCHAR2,
    81      oldval number,
    82      newval number,
    83      env SYS.ODCIEnv)
    84  RETURN NUMBER AS
    85  BEGIN
    86    return ODCIConst.Success;
    87  END;
    88
    89  STATIC FUNCTION ODCIIndexStart(
    90    sctx IN OUT index_methods,
    91    ia SYS.ODCIIndexInfo,
    92    op SYS.ODCIPredInfo,
    93    qi sys.ODCIQueryInfo,
    94    strt number,
    95    stop number,
    96    cmpval  number,
    97    env SYS.ODCIEnv)
    98  RETURN NUMBER AS
    99  BEGIN
    100    sctx := index_methods(1);
    101    return ODCIConst.Success;
    102  END;
    103
    104  MEMBER FUNCTION ODCIIndexFetch(
    105    self IN OUT index_methods,
    106    nrows NUMBER,
    107    rids OUT SYS.ODCIridlist,
    108    env SYS.ODCIEnv)
    109  RETURN NUMBER AS
    110  BEGIN
    111    return ODCIConst.Success;
    112  END;
    113
    114  MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER AS
    115  BEGIN
    116    return ODCIConst.Success;
    117  END;
    118  end;
    119  /
    Type body created.
    SCOTT@orcl12c> CREATE FUNCTION test_eq_fun(a number, b number) RETURN NUMBER AS
      2  BEGIN
      3    IF a = b then
      4       RETURN 1;
      5    ELSE
      6       RETURN 0;
      7    END IF;
      8  END;
      9  /
    Function created.
    SCOTT@orcl12c> CREATE OPERATOR test_eq
      2  BINDING (number, number) RETURN NUMBER
      3  USING test_eq_fun
      4  /
    Operator created.
    SCOTT@orcl12c> CREATE INDEXTYPE test_index_type
      2  FOR
      3  test_eq(number, number)
      4  USING index_methods
      5  WITH ARRAY DML(number, your_type)
      6  WITH LOCAL RANGE PARTITION
      7  WITH SYSTEM MANAGED STORAGE TABLES
      8  /
    Indextype created.
    SCOTT@orcl12c> CREATE TABLE test_table (id NUMBER (19,0))
      2  /
    Table created.
    SCOTT@orcl12c> CREATE INDEX test_index ON test_table(id) INDEXTYPE IS test_index_type
      2  /
    Index created.
    SCOTT@orcl12c> insert into test_table values (1)
      2  /
    single
    1 row created.
    SCOTT@orcl12c> insert into test_table
      2  select 2 from dual union all
      3  select 3 from dual
      4  /
    batch
    2 rows created.
    SCOTT@orcl12c> insert into test_table select deptno from dept
      2  /
    batch
    4 rows created.
    SCOTT@orcl12c> insert into test_table select object_id from user_objects
      2  /
    batch
    34 rows created.
    SCOTT@orcl12c>

  • How do you make a static reference to a method?  I've included code.

    I'm sorry but this is a cross post. This should be here but it is also in the 100% pure Java forum. It won't happen again.
    Now...
    Why doesn't this work? How do I use the method add(int a, int b)?
    ERROR - "Can't make static reference to method int add(int, int) in testClass"
    interface testInterface{   
        static String sString = "TESTING";   
        public int add(int a, int b);
    class testClass implements testInterface{
        public int add(int a, int b){
            return a+b;      
        public static void main(String argv[]){
            int sum = add(3,4);    // here's the error
            System.out.println("test");
            System.out.println( sum );   
    }Again, I apologize for the cross post.

    hi,
    this seems to be pretty easy, isn't it?
    Oh c'mon! You try to invoke a non-static method from within a static method. Solution: Create a specific instance of class testClass:
    testClass test=new testClass();
    test.add(3,4);best regards, Michael

  • Can't make static reference to method while it is static

    Hello, can somebody please help me with my problem. I created a jsp page wich includes a .java file I wrote. In this JSP I called a method in the class I created. It worked but when I made the method static and adjusted the calling of the method it started to complain while i didnt make an instance of the class. the error is:Can't make static reference to method
    here is the code for the class and jsp:
    public class PhoneCheckHelper {
    public static String checkPhoneNumber(String phoneNumber) {
    String newPhoneNumber ="";
    for(int i=0; i<phoneNumber.length(); i++) {
    char ch = phoneNumber.charAt(i);
    if(Character.isDigit(ch)) {
    newPhoneNumber += String.valueOf(ch);
    return newPhoneNumber;
    <html>
    <head>
    <title>phonecheck_handler jsp pagina</title>
    <%@page import="java.util.*,com.twofoldmedia.text.*, java.lang.*" %>
    </head>
    <body>
    <input type="text" value="<%= PhoneCheckHelper.checkPhoneNumber(request.getParameter("phonenumberfield")) %>">
    </body>
    </html>

    Go over to the "New to Java" forum where that message is frequently explained. Do a search if you don't see it in the first page of posts.

  • How to create an new array from dynamically discovered type

        public static Object toAdjustedArray(Object source, Object addition,
                                             int colindex, int adjust) {
            int newsize = 0;
            Class componentType = null;
            if (source.getClass().isArray()) {
                Object[] arrayIn= (Object[])source;
                componentType = arrayIn[0].getClass();
                newsize = arrayIn.length + adjust;
            else {
                System.out.println("error in ArrayUtil");
            Object[] newarray = new Object[newsize];
            copyAdjustArray(source, newarray, addition, colindex, adjust);
            return newarray;
        }This methods take an array as an input an append new value(s) to it.
    I can get the component type of the array (i.e. the class of the array's member). But how can I create a new array of this component type (i.e doing something like componentType[] newarray = new componentType[newsize])?
    CU Jerome

    I fanally found a walkaround trick for my problem.
    Their is no way to create an array of a certain type (dynamically dsicovered) in CLDC. But what you can do is to use the instanceof method to determine the type of your array and in a big if statement create the right array.
    Here is the final code:
        public static Object toAdjustedArray(Object source, Object addition,
                                             int colindex, int adjust) {
            int newsize = 0;
            if (source.getClass().isArray()){
                Object[] arrayIn= (Object[])source;
                newsize = arrayIn.length + adjust;
            Object arrayElement = null;
            if (addition.getClass().isArray()){
                Object[] temp = (Object[])addition;
                arrayElement = temp[0];
            else{
                arrayElement = addition;
            Object newarray = null;
            if (arrayElement == null){
                newarray = new Object[newsize];
            if (arrayElement instanceof org.hsqldb.Index){
                newarray = new org.hsqldb.Index[newsize];
            else {
                newarray = new Object[newsize];
            copyAdjustArray(source, newarray, addition, colindex, adjust);
            return newarray;
        }

  • Creating a dynamic Array

    Thanks for reply.
    I want to create a dynamic array and for this I used ArrayList Collection and Vector Class. I am using JDK 1.4.1 . But , I have a problem in that. In ArrayList, I used the following code:
    ArrayList al = new ArrayList();
    while(rs.next())
    al.add(rs.getString("Enter_Year"));
    al.add(rs.getString("UG_Production_Mi_Te"));
    al.add(rs.getString("OC_Production_Mi_Te"));
    al.add(rs.getString("Total_Production_Mi_Te"));
    al.add(rs.getString("OBR_MM3"));
    al.add(rs.getString("OMS_Te"));
    al.add(rs.getString("Coal_Offtake_Mi_Te"));
    al.add(rs.getString("Supply_to_Steel_Plant_Th_Te"));
    al.add(rs.getString("Royalty_SalesTax_MP_Crs"));
    al.add(rs.getString("Royalty_SalesTax_CG_Crs"));
    al.add(rs.getString("Total_ManPower"));
    al.add(rs.getString("Fatality_Rate_per_Mi_Te_Output"));
    al.add(rs.getString("Total_Wellfare_Expenditure_Crs"));
    String rpt[][] = new String[al.size()][];
    rpt = al.toArray(rpt); // ArrayStoreExecption error
    String colheads[] = {"...........My Table's Column names are here....."};
    JTable table = new JTable(rpt,colheads);
    JScrollPane jsp = new JScrollPane(table);
    add(jsp);
    At the statement having comment line I received the error ArrayStoreException. The JTable accepts the 2 D array for storing the info and I think the toArray() method is not working there and can't convert the ArrayList elements into an Array. Similarily, Vector Class is also not converting the elements into an array object and showing the same error only.
    Please help me to convert it into an array object so that I can pass it into the JTable argument.

    That isn't a jdbc problem but rather a collection problem.
    You certainly can't convert a one dimensional collection into a two dimensional array automatically. And that is what you are creating with the while loop.
    Since you know the column names you also know the inner array size so you can start by creating a statically sized string array (not collection) in the loop and add that to the outer collection. That might solve the problem.

  • STATIC REFERENCE

    THE CODE IS ATTACHED. I NEED TO SOLVE THE ERROS.
    THIS IS THE ERRORS AFTER COMPILE
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:47: Can't make static reference to method void setLayout(java.awt.LayoutManager) in class java.awt.Container.
                        setLayout(new FlowLayout());
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:48: Can't make static reference to method void setBackground(java.awt.Color) in class java.awt.Component.
                        setBackground(Color.green);
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:53: Can't make static reference to method java.awt.Component add(java.awt.Component) in class java.awt.Container.
                        add(l);
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:58: Can't make static reference to method java.awt.Component add(java.awt.Component) in class java.awt.Container.
                        add(name);
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:61: Can't make a static reference to nonstatic variable tf_name in class PwdClient.
                        tf_name = new TextField(20);
                        ^
    5 errors
    //HERE IS THE CODE
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    class PwdClient extends Frame
         private TextField tf_name;
         private TextField tf_password;
         private String input_str_name;
         private String input_str_password;
         private String str_to_pass;
         //private String str;
         //private String str_name;
         //private String str_password;
         //private Button button1;
         private final static int buffsize = 512;
         public static void main(String args[])
              try
                        String server = args[0];
                        int port = Integer.parseInt(args[1]);
                        //create socket
                        Socket s = new Socket(server, port);
                        //readresult from server
                        InputStream is = s.getInputStream();
                        DataInputStream dis = new DataInputStream(is);
                        OutputStream os = s.getOutputStream();
                        DataOutputStream dos = new DataOutputStream(os);
                        InputStreamReader isr = new InputStreamReader(System.in);
                        BufferedReader br = new BufferedReader(isr);
                        //Frame frm = new Frame( "Client Server" );
                        setLayout(new FlowLayout());
                        setBackground(Color.green);
                        String str = "Enter Name and Password:";
                        Label l= new Label( str, Label.CENTER);
                        l.setBackground(Color.red);
                        add(l);
                        String str_name = "Name:";
                        Label name = new Label( str_name, Label.CENTER);
                        name.setBackground(Color.red);
                        add(name);
                        //Name textfield User input for name
                        tf_name = new TextField(20);
                        add(tf_name);
                        String str_password = "Password:";
                        Label password = new Label( str_password, Label.CENTER);
                        password.setBackground(Color.red);
                        add(password);
                        //Password Textfield (user input for password)
                        tf_password = new TextField(20);
                        tf_password.setEchoChar('*');
                        add(tf_password);
                        Button Button1 = new Button("Submit");
                        add(Button1);
                        Button1.addActionListener( new ActionListener()
                             public void actionPerformed(ActionEvent ae)
                                  input_str_name = tf_name.getText();
                                  tf_name.setText(new String(""));
                                  input_str_password = tf_password.getText();
                                  tf_password.setText(new String(""));
                                  str_to_pass = input_str_name+"/"+input_str_password;
                                  dos.writeBytes(str_to_pass);
                                  String received_from_server = brr.readLine();
                                  l.setText(received_from_server, Label.CENTER);
                        frm.setSize( 300, 200 );
                        frm.show();
                        frm.addWindowListener( new WindowAdapter()
                             public void windowClosing(WindowEvent e)
                             { System.exit(0);}
              }//closes the try
              catch(Exception e){}

    Put the code you have in static main in a constructor, or make an instance of PwdClient in main that you can call those methods on. You can't call non-static methods directly from a static method (main). You need to instantiate the class.
    public class PwdClient extends JFrame {
      public PwdClient() {
        // the code from your main method
      public static void main(String[] args) {
        new PwdClient(); // makes a new instance of PwdClient
    }

  • Static anonymous array as parameter

    I have a peculiar situation where I'd like to pass a "static anonymous array" as a parameter.
    For example, the function being called would look like this:
    public void writeField(String[][] fielddata) { ... }And the caller would look like this:
    writeField( {{"id1", "name1", "label1"}, {"id2", "name2", "label2"}});
    ...I can easily do this and it works:
    writeField( new String[][]{{"id1", "name1", "label1"}, {"id2", "name2", "label2"}});
    ...But I'd like to avoid the "new" calls if possible.
    I'm sure you're thinking, "why?" It's an unusual situation and this really is an ideal way of solving it so please spare me the OO and type safety lesson.
    Does anyone know of a way to pass a "static anonymous array" as a parameter. You can pass a static anonymous String, so why not an array? It seems like the compiler could pick up the array data type from the parameter specification of the called function.
    Thanks!

    >
    I'm calling this function inline in a jsp page.
    <% writeField( {{"id1", "name1", "label1"},
    {"id2", "name2", "label2"}} ); %>I'm trying to see if I can avoid a lot of object
    creation. It's more of a curiosity about the
    language at this point. It seems to me that if you
    can call a function like:
    Actually the use of these anonymous arrays tends to result in more object creation.
    What I'd do (not that I put much, if any, scriptlet coding in JSPs these days is something like this:
    <%! private final static String[][] myData = {{"id1", "name1", "label1"},
    {"id2", "name2", "label2"}} ); %>
    <% writeField(myData); %>This only ever creates one instance of the array, however often the JSP is called. Same technique applies to things like DateFormat objects.

  • Create object reference by name

    I wish to disable and enable a bunch of controls on the front panel. Instead of creating hard-wired property nodes, I wish to cycle through an array of string names of controls and set the corresponding control's property. Is it possible to create a reference on the fly based on a string? The reference will then be fed to a Property node. Or is there an alternative way for my problem?

    See the image below for a better example.
    This one provides a list of all the controls on the front panel.  See the names of the labels appears in the ArrayofCtrls.
    RayR
    You can create a subvi of this. Replace ThisVI by a control.  You then wire This VI from the calling VI.  Or, you can get fancy and wire a pathname to the appropriate function which replaces ThisVI in the above example.  You can then obtain front panel listings for other VI's.  The possibilities are alomost endless  
    Message Edited by JoeLabView on 01-08-2008 08:11 AM
    Attachments:
    _example.PNG ‏33 KB

  • Creating a byte Array dynamically.Urgent Help needed.

    Hi there,
    I need to create a byte Array with the values
    derived from the array and then am passing this byte array
    to a method.
    Example :
    public static void main(String[] args) throws IOException {
    char chars[] = {'a','j','a','y'};
    byte[] b = {
    (byte) chars[0],(byte) chars[1],(byte) chars[2],(byte) chars[3],
    //** Send name to a server.
    sendRequest(b);
    This is all right.
    But here I know the size of the character array chars.
    If it had more than 4 characters or less than 4,
    is there a way to create the byte array dynamically based on the values in the character array?
    Please can some one help me with creating a byte array on the fly?
    Has anyone understood my question please?
    A response is much much appreciated.

    The actual problem is this.
    The byte array already has some fixed values to it
    and i need to append the values of the character array
    to this byte array
    ie
    char chars[] = {'a','j','a','y'};
    byte b[] = {
    // Predefined values
    (byte) 0x01, (byte) 0x7E, (byte)0x03
    // I have to add the values from the array here
    (byte) chars[0], (byte) chars[1]....
    How can I add these values.? The size of the character array
    can vary

  • Problems creating a Java Array using JNI-HELP!

    Hi,
    I am trying to create a Java Array using JNI.I have posted the code below. The problem is that the oth element is added correctly to the Array but when the JVM gets to the next element...it goes for a toss. It is not able to create a new instance of the object in GetUGEntity() function...there seems to be some problem in creating a new instance of the object!
    Can somebody help me with this?
    jobject GetUGEntity(JNIEnv *env, UF_DISP_j3d_entity_t* entity_list)
         int numVerts=0, numStrips=0;
         jfieldID fid;
         jdoubleArray jTransform=NULL;
         jstring jstrName=NULL;
         jdoubleArray jNormals=NULL;
         //Init an Entity object
         cout<< "**Getting New Class Reference...";
         jclass jEntity = env->FindClass("Lcom/wipro/java3d/rmi/Entity;");
         cout << "**got Class reference..."<<endl;
         if (jEntity == NULL)
              return NULL;
         cout<<"Creating new object instance...";
         jmethodID mIDInit = env->GetMethodID(jEntity, "<init>", "()V");
         cout<<"Got java method id...";
         jobject javaObj = env->NewObject(jEntity, mIDInit);
         if (javaObj==NULL)
              return NULL;
         cout << "Created!" << endl;
         //Entity ID
         cout<< "**Setting eid...";
         fid=env->GetFieldID(jEntity,"eid","I");
         jint eid = (jint)(entity_list)->eid;
         env->SetIntField(javaObj, fid, eid);
         //env->DeleteLocalRef(eid);
         cout << "Done!" << endl;
         cout << "Done!" << endl;
         cout<< "**Returning jobject...";
         return javaObj;
    jobjectArray createJArray(JNIEnv* env, UF_DISP_j3d_entity_t** entity_list, int noOfEntities )
         UF_DISP_j3d_entity_t* tempVar=NULL;
         cout<<"*Creating Jobjectarray...";
         jobjectArray jEntityArray = (jobjectArray) env->NewObjectArray(noOfEntities,
              env->FindClass("Lcom/wipro/java3d/rmi/Entity;"),NULL);
         cout<<"Created!"<<endl;
         for(int i=0; i<noOfEntities;++i)
              tempVar = &(*entity_list);
              if (tempVar !=NULL)
                   cout<<"*Trying to get Entity...."<<endl;
                   jobject jEntity = GetUGEntity(env, tempVar);
                   if (jEntity!= NULL)
                        cout<<"Got Entity!" <<endl;
                        cout <<"*Setting Array Element....";
                        env->SetObjectArrayElement(jEntityArray, i, jEntity);
                        cout << "Done!" << endl;
                   else
                        printf("ERROR: Did not get Entity Reference");
              else
                   printf("ERROR: Got a NULL Reference!");
         return jEntityArray;

    Hi Deepak,
    Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
    I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
    Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
    Dhamo.

Maybe you are looking for

  • Report on Archieved data for Object MM_SPSTOCK

    Hi All. We require a report on Archieved data for the Object 'MM_SPSTOCK'.which has the tables mcha,mchb,mbew. I require the data for the table MCHB. I have Archieve Key (Index) & Offset Value. we are using Ecc 4.7 version. Please help me to solve th

  • Itunes on windows 7 keeps crashing (64 bit)

    I am having a huge problem with itunes 10.5.3.3. When i am using itunes... it suddenly crashes and I get a message box saying "Itunes has stopped working". another box then appears saying "A problem casued the program to stop working correctly. Windo

  • Exception handling in workflow

    I've read few forums on exception handling in workflow, and tried working accordingly. Created a block and on normal branch, ive added "user decision" step, mail step... On the other (exception) branch, ive sent a mail to HR informin tht workflow wen

  • How to move the Library in Windows- I don't care if I loose everything.

    I've spent now at least two hours talking to tech support and scouring the boards and no dice. Very simply: D:\Music\iTunes is where the library is stored D:\Music\iTunes\iTunes Music is where music is stored. I want to change the location of the lib

  • SCCM 2012 - Query Local Admin Users

    Hi Guys, I´m trying to get all users that are local admins of my network using sccm12. How it´s possible? Thank you.