Initializing an array question

if i wanted to initialize elements of an array and get input from the user of how many there will be. where can i find some info on this?
basically instead of initializing 0,1,2,3, and so on i wanted to do it in a for loop, but i have tried it a couple of different ways with no luck.
maybe you guys can give me some insight on how i need to set this thing up or what i need to think about or where some of the reading is?
any info would help
thanks in advance guys

well here is the code for it i thought i was intializing it correctly??
public static void main(String[] args) {
        int y;
        int x;
        int maxValue = 0;
        int numRepitions;
        int [] counters = new int[maxValue];
        Scanner keyin = new Scanner(System.in);
        Random generator = new Random();
            System.out.println("please enter how many random numbers you would like to generate");
            maxValue = keyin.nextInt();
            System.out.println("please eneter how many values your would like to draw for");
            numRepitions = keyin.nextInt();
            for(y = numRepitions - 1; y >= 0; y--)
               counters[y] = numRepitions;
               counters[numRepitions]--;
       

Similar Messages

  • Initializing object array

    Hi,
    I am having problem initializing object array - here is my scenario -
    I have created class a -
    public class A {
    Public String a1;
    Public String a2;
    Public String a3;
    }the I have created class b
    public class B {
    Public A [] aa;
    }and I want to initialiaze my class bi in anoither clas c
    public class C{
    A ar = new A;
    ar.aa[0].a1 = "test"
    }this gives me null ..please anybody help me
    Neha
    }

    Thanks for the reply ..I know this is not good code ..but I have to write the classes in this way in SAP to create the Webservice ...the SAP side understand this type of structure only ..I still got the same error ..here are my original classes -
    public class GRDataItem {
         public String AUFNR ;
         public String EXIDP ;
         public String EXIDC;
         public String MATNR ;
         public String WERKS ;
         public String CHARG ;
         public String VEMNG ;
         public String VEMEH ;
         public String CWMVEMEH ;
         public String CWMVEMNG ;
         public String STATUS;
    public class GRDataTab {
         public GRDataItem [] grItem;
    Public class webservice {
                int sn = 20 ;
                  GRDataTab tab = new GRDataTab();
                tab.grItem = new GRDataItem[sn];
                tab.grItem[1].AUFNR = "12";
    }Thanks for all your help
    Neha

  • Initial startup with question marked folder with a disk already inside

    Initial startup with question marked folder with a disk already inside

    Reinstalling Lion/Mountain Lion Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • Initializing string array registers

    Hello. I have posted my project. It is not even close to finished but I am having trouble initializing the array's labeled "Up values" and "Down values", to "0" for all elements, at beginning of Vi run. So, when I am at the Front Panel and running the Vi, I would like all of the fields to begin with a "0", the moment the Vi is started. I have tried a couple different things I could think of and watched the Core 1 Video about arrays again however, it doesn't give the example for a string and nothing I have tried so far, is working. Thank you.

    crossrulz wrote:
    There are a few options to you:
    1. Use an initialization state to write to your indicators their default values via a local variable
    2. Put the default values into the indicators and then right-click on them and choose Data Operations->Make Current Value Default.  This will store the default value in the indicators themselves.
    I would recommend going with #1.
    2. Put the default values into the indicators and then right-click on them and choose Data Operations->Make Current Value Default.  This will store the default value in the indicators themselves. I put a "0" in each field, I slected "make current value default, but after the Vi ran, and then I started the Vi again, it keeps the numbers in the registers that are left over from the previous test. I also tried your suggestion #1. however, it still isn't writing a "0" in all the fields. The reason for this is that I don't want the operator's to read old data accidentally, when the Vi is running. I thought if I wipe all the registers out, it will prevent that from happening.

  • Methodology Question: Initializing Static Arrays

    After almost gnawing my arm off in frustration, I finally stumbled onto how to go about initializing and populating a static array that's outside of my Class's constructor (by placing it inside of a static block). My problem is, I just don't understand why I needed to do it that way. My code started out as such:
    public class Parameter {
         private static appEnvironmentBean[] appEnvironment = new appEnvironmentBean[8];
         appEnvironment[0].setMachineIP("192.168.1.100")
    }and this kept throwing an error " ']' expected at line ###"
    so I changed it to this:
    public class Parameter {
         private static appEnvironmentBean[] appEnvironment = new appEnvironmentBean[8];
         static {
         appEnvironment[0].setMachineIP("192.168.1.100")
    }and it worked. Now my problem is, I'm assigning a literal, and I declared the Bean array as static, so the way I see it, there was no reason to throw assignments to the array inside of a static block. I'll take it as a "That's just the way it is" thing, but if someone out there could explain the reasoning behind having to put my assignments inside of a static block, it would really be appreciated.
    Thanks!

    Because if you didn't put it inside a static block you'd be attempting to execute code outside of a method which is illegal except for initialization.
    I think you could do it this way:
    private static appEnvironmentBean[] appEnvironment = {
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100"),
      new appEnvironmentBean().setMachineIP("192.168.1.100") };it depends on whether setMachineIP returns an appEnvironmentBean.

  • Arrays Question

    Hello all, i have a couple of questions about multi-dimensional arrays.
    The length of this 2-dimensional array is 3.
    int table[] [] = {
    {1, 2, 3},
    {4, 5},
    {6, 7, 8, 9},
    But what is the length of both own dimensions? How many rows({}) belong to each dimension?
    So, what are ? and ? int table [] [] = new int [?] [?] or is it not possible to have a value for ? and ? if you initialized the 2d array?
    "Length= number of arrays stored in the multidimension." is this definition good?
    int t, i;
    int table [] [] = new int [3] [4];
    for(t=0; t<3; ++t){
    for(i=0; i<4; ++i){
    table[t] = (t*4) + i + 1;
    system.out.print(table [t] [i] + � �; } system.out.println();
    The size of this not initialized 2-dimensional array is 3,4(like in a real table, 3 vertical indexes, and 4 horizontal indexes). But, does this 2-dimensional array have a length(number of arrays), if yes, what is the length of this?

    import java.util.Arrays;
    import java.util.Random;
    public class ArrayOfArrays {
        private int[][] data;
        public ArrayOfArrays(int rows, int cols) {
            data = new int[rows][cols];
        //numbers in the range lo <= x < hi
        public void fillWithRandomNumbers(int lo, int hi) {
            Random r = new Random();
            for(int[] row: data) {
                for(int i =0; i<row.length; ++i) {
                    row[i] = lo + r.nextInt(hi-lo);
        public void display() {
            for(int[] row: data) {
                System.out.println(Arrays.toString(row));
        public static void main(String[] args) {
            ArrayOfArrays app = new ArrayOfArrays(5,10);
            app.fillWithRandomNumbers(10,20);
            app.display();
    }

  • Stalling a form from loading until the initial javascript arrays are loaded

    I am looking for a way to get a form to be hidden based on the onload event. I would like to call a javascript function to initially populate some select boxes based on javascript arrays, but I would like this to happen before the page loads or at least stall displaying the select boxes until they are populated.
    The way it is setup now, when the page loads, the select boxes try to load first and then the rest of the form loads. I would like to know if there is a way to load the select boxes from the javascript arrays, then have the select boxes and other form elements show up at the same time. I have tried putting a <div> around the entire form and within the javascript populate function I first use "document.formname.div_id.style.visibility=hidden" then at the end of the select box population within the function, I use "document.formname.div_id.style.visiblity=visible". I tried this and the select boxes appear blank; it is as if the populate function doesn't work at all.
    I realize this is a very long question, but I will award you Duke Dollars if you help me out!!!

    right now, I have it set up where I click on a link which is a jsp page which forwards me to the jsp page that has all the html in it. That page is where I initially try to populate the select boxes with the javscript arrays...I also have a number of javascript functions which change the contents of the select boxes based on another select box in the form. Will i have access to those "java" arrays, [instead of using the javascript arrays], that you are suggesting in the javascript code? I do need to use whatever arrays I create in javascript functions.

  • Trying to send multiple types in a byte array -- questions?

    Hi,
    I have a question which I would really appreciate any help on.
    I am trying to send a byte array, that contains multiple types using a UDP app. and then receive it on the other end.
    So far I have been able to do this using the following code. Please note that I create a new String, Float or Double object to be able to correctly send and receive. Here is the code:
    //this is on the client side...
    String mymessage ="Here is your stuff from your client" ;
    int nbr = 22; Double nbr2 = new Double(1232.11223);
    Float nbr3 = new Float(8098098.809808);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(mymessage);
    oos.writeInt(nbr);
    oos.writeObject(nbr2);
    oos.writeObject(nbr3);
    oos.close();
    byte[] buffer = baos.toByteArray();
    socket.send(packet);
    //this is on the server side...
    byte [] buffer = new byte [5000];
    String mymessage = null; int nbr = 0; Double nbr2 = null;
    Float nbr3 = null;
    mymessage = (String)ois.readObject();
    nbr = ois.readInt();
    nbr2 = (Double) ois.readObject();
    nbr3 = (Float) ois.readObject();
    My main question here is that I have to create a new Float and Double object to be able to send and receive this byte array correctly. However, I would like to be able to have to only create 1object, stuff it with the String, int, Float and Double, send it and then correctly receive it on the other end.
    So I tried creating another class, and then creating an obj of this class and stuffing it with the 4 types:
    public class O_struct{
    //the indiv. objects to be sent...
    public String mymessage; public int nbr; public Double nbr2;
    public Float nbr3;
    //construct...
    public O_struct(String mymessage_c, int nbr_c, double nbr2_c, float nbr3_c){
    my_message = my_message_c;
    nbr = nbr_c;
    nbr2 = new Double(nbr2_c);
    nbr3 = new Float(nbr3_c);
    Then in main, using this new class:
    in main():
    O_struct some_obj_client = new O_struct("Here is your stuff from your client", 22, 1232.1234, 890980980.798);
    oos.writeObject(some_obj_client);
    oos.close();
    send code....according to UDP
    However on the receiving side, I am not sure how to be able to correctly retrieve the 4 types. Before I was explicitely creating those objects for sending, then I was casting them again on the receiving side to retrieve then and it does work.
    But if I create a O_struct object and cast it as I did before with the indiv objects on the receiving end, I can't get the correct retrievals.
    My code, on the server side:
    O_struct some_obj_server = new O_struct(null, null, null. null);
    some_obj_server = (O_struct)ois.readObject();
    My main goal is to be able to send 4 types in a byte array, but the way I have written this code, I have to create a Float and Double obj to be able to send and receive correctly. I would rather not have to directly create these objects, but instead be able to stuff all 4 types into a byte array and then send it and correctly be able to retrieve all the info on the receiver's side.
    I might be making this more complicated than needed, but this was the only way I could figure out how to do this and any help will be greatly appreciated.
    If there an easier way to do I certainly will appreciate that advise as well.
    Thanks.

    public class O_struct implements Serializable {
    // writing
    ObjectOutputStream oos = ...;
    O_struct struct = ...;
    oos.writeObject(struct);
    // reading
    ObjectInputStream ois = ...;
    O_struct struct = (O_struct)ois.readObject();
    I will be sending 1000s of these byte arrays, and I'm sure having to create a new Double or Float on both ends will hinder this.
    I am worried that having to create new objs every time it is sending a byte array will affect my application.
    That's the wrong way to approach this. You're talking about adding complexity to your code and fuglifying it because you think it might improve performance. But you don't know if it will, or by how much, or even if it needs to be improved.
    Personally, I'd guess that the I/O will have a much bigger affect on performance than object creation (which, contrary to popular belief, is generally quite fast now: http://www-128.ibm.com/developerworks/java/library/j-jtp01274.html)
    If you think object creation is going to be a problem, then before you go and cock up your real code to work around it, create some tests that measure how fast it is one way vs. the other. Then only use the cock-up if the normal, easier to write and maintain way is too slow AND the cock-up is significantly faster.

  • Database array questions

    Disclaimer: I am new to DB's.
    I'm looking at creating a MySQL database to hold tests done on DUTs (each with a specific serial). In theory, each DUT undergoes 3 tests. Each test produces a 401x9 2D array of DBLs. I am not concerned with the write speed to the DB, but I do want to optimize the read of the DB (potentially may need to retrieve 1000+ of these 2D arrays as fast as possible). I have the DB Toolkit; using LV 8.5. Questions:
    1. I have seen two different ways to save a 2D array in a DB mentioned: first, writing one row at a time with the DB Insert vi, resulting in a 2D array in a table (which is slow writing) or second, changing the 2D array to a variant and using the DB Insert vi, resulting in a single cell in a table. I know I can use other methods (parameterized vi, sql commands, user defined functions on the DB server, please do comment if you have found drastic performance increase with these methods), but of the two ways of storing a 2D array, can I read a 2D array from a table faster than reading a 2D array from a single cell? Whenever I need this data, I will read it all (i.e. I will never have to search for certain data within these individual 2D arrays)
    2. I may have installed the 8.2.1 DB toolkit, because the Database Variant to Data vi/function does not drop onto the Block Diagram when I drag it from the palette, and the Help has ???. I assume this is because it just points to the normal Variant to Data, which in 8.5 is in a subpalette as compared to 8.2.1. Any quick way to fix this?
    3. Any other general suggestions for a DB newbie? I've been trying to derive best practices from KB aritcles, this forum, and the web, but there is so much information and so many varying opinions I find it hard to narrow down best practices.
    Michael

    Hi Miguel,
    It looks like you are embarking on a very interesting project. Although you probably have seen many of the following documents, I've linked a few to get you started.
    Discussion forum using LabVIEW to read from tables
    Developer Zone article about developing a test system
    Knowledgebase article about imitations of speed with database toolset
    As far as your first question, I would suggest trying out both methods with simple code and testing with a small amount of values to determine  which one will be the fastest.
    Good luck with your project!
    Amanda Howard
    Americas Services and Support Recruiting Manager
    National Instruments

  • Array questions

    Hi, everyone.
    I'm writing a lab program which counts the number of occurances of English letters in a line of English text.
    The program has the following requirements
    Assume that we input only lowercase English text
    The program should be able to count the number of occurances of English letters in a text and print out both the number of occurances and the letters. Don't print out letters that don't exist in the text.
    I write my code as following:
    import java.util.*;
    public class Translator
    public static void main(String[]args)
         Scanner sc = new Scanner(System.in);
         System.out.println("Please enter text:");
         String text = sc.nextLine();
         char[] input = text.toCharArray();
        public static void countLetters(char [] input)
            System.out.println("Letter           Number of occurances");
            int[] alphabet = new int[26];
            for (int i=0; i<input.length; i++)
                if (input=='a')
    alphabet[0] += 1;
    else if(input[i]=='b')
    alphabet[1] += 1;
    else if (input[i]=='c')
    alphabet[2] += 1;
    else if (input[i]=='d')
    alphabet[3] += 1;
    else if (input[i]=='e')
    alphabet[4] += 1;
    else if (input[i]=='f')
    alphabet[5] += 1;
    else if (input[i]=='g')
    alphabet[6] += 1;
    else if (input[i]=='h')
    alphabet[7] += 1;
    else if (input[i]=='i')
    alphabet[8] += 1;
    else if (input[i]=='j')
    alphabet[9] += 1;
    else if (input[i]=='k')
    alphabet[10] += 1;
    else if (input[i]=='l')
    alphabet[11] += 1;
    else if (input[i]=='m')
    alphabet[12] += 1;
    else if (input[i]=='n')
    alphabet[13] += 1;
    else if (input[i]=='o')
    alphabet[14] += 1;
    else if (input[i]=='p')
    alphabet[15] += 1;
    else if (input[i]=='q')
    alphabet[16] += 1;
    else if (input[i]=='r')
    alphabet[17] += 1;
    else if (input[i]=='s')
    alphabet[18] += 1;
    else if (input[i]=='t')
    alphabet[19] += 1;
    else if (input[i]=='u')
    alphabet[20] += 1;
    else if (input[i]=='v')
    alphabet[21] += 1;
    else if (input[i]=='w')
    alphabet[22] += 1;
    else if (input[i]=='x')
    alphabet[23] += 1;
    else if (input[i]=='y')
    alphabet[24] += 1;
    else alphabet[25] +=1;
    System.out.println("a");
    for(int i=0; i<input.length; i++)
    if (alphabet[i] > 0)
    System.out.println(input[i] +" "+alphabet[i]);
    Though having gotten no syntext error complain from the compiler, no matter what I input, the program returns nothing. At first I assumed that it's the first for loop's problem, so that I typed in some System.out.println() methods at the end of some elseif statements. But I still got nothing after this trial. So that I guess it's the char[] input = text.toCharArray();'s problem.
    Have the input[i] elements really stored any character (I tried to convert the input string into char array) after I typed char[] input = text.toCharArray();'s problem. ?
    My another question is: since the input[i] stores character, when I am trying to print out the letters that exist in the text through the last System.out.println() method in my code, I can use input[i] to represent the letter which I want to print. Is it right?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I figure out now that the problem is caused by the last for loop. I modify it as following:
    for(i=0; i<26; i++)
                if (alphabet[i] > 0)
                System.out.println('a'+i +"          "+alphabet);
    }After the modification, now I can get the right answer. The only problem I have now is trying to convert the interger number produced by 'a'+i back into character. I tried to replace 'a'+i with toChar('a'+i), but it doesn't work. Can you give me some explanation? Thank you very much!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Photo Array Question

    I have a bit of a silly question about the photo array Apple uses in many of their publications, including the idea behind "CoverFlow". Check this link to see what I mean: http://arstechnica.com/reviews/os/mac-os-x-10-5.ars/2. (Bottom photo)
    Is there a way to achieve this? What software accomplishes this? I am a webmaster using iWeb.
    I have something similar on the page I have created, but the difference is my photos are straight as they descend, whereas Apple's are straight, yet not square, they seem to be turned, like in this top image of Ubuntu: http://www.taimila.com/?q=node/3. The photos are not rotated, but turned.
    Any software ideas?
    Any ideas at all?

    Resizing is a different issue altogether from format.
    It's safe to scale the image in ID regardless of the format. If you look in the info panel with the image selected you'll see two resolution numbers listed, actual and effective. Actual is just the resolution at the dimensions the image was saved and is essentially irrelevant. Effective resolution is what you have at the dimensions you are currently using, and that's the number that counts. If that number is in the range that is acceptable for the type of output you are using, there is no need to resize the image in Photoshop at all.
    If you MUST resize the image, then yes, convert to something besides jpeg if that's what it is to start. And keep in mind that up-sampling won't improve image quality in general, and downsampling more than 20% or so can cause you to lose fine details (but so will scaling down).
    Peter

  • Initializing an array of clusters in a CIN?

    I'm trying to write a CIN to connect to a mySQL database, retreive some information, and return it to labVIEW for display. The connection works perfectly using ODBC, but I'm having major trouble getting the information back to LabVIEW. I'm new to CINs and I'm still slightly confused as to how the different structures work. I want to return the data in an array of clusters (using struct names, a 'Set' of 'Records'). LV generated the structs, and I simply renamed some of the fields/names. The code I have so far works up to the point specified in the source below, when I try to initialize the array for data entry. I think what's throwing me off is the conplexity of my structures. Since it's an array of clusters, and not an array of say strings or integers, I'm getting confused. If anyone could help me out by telling me what's wrong with my code, and/or filling in the section of the while loop I'm rather clueless on.
    typedef struct {
    LStrHandle Number;
    LStrHandle SerialNumber;
    } Record;
    typedef struct {
    int32 dimSize;
    Record ptr[1];
    } Set;
    typedef Set **SetHdl;
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet);
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet)
    // LV error code
    MgErr err = noErr;
    // ODBC environment variables
    HENV env = NULL;
    HDBC dbc = NULL;
    HSTMT stmt = NULL;
    // Connection options data variables
    UCHAR* dsn = malloc(SQL_MAX_DSN_LENGTH * sizeof(UCHAR));
    UCHAR* user = malloc(32 * sizeof(UCHAR));
    UCHAR* pass = malloc(32 * sizeof(UCHAR));
    UCHAR* num = malloc(16 * sizeof(UCHAR));
    // Query variables
    INT qlen;
    INT nlen;
    UCHAR colNumber[5];
    SDWORD colNumberSize;
    UCHAR* query;
    INT numRows;
    // ODBC return code storage
    RETCODE retcode;
    /** Prepare data from LV for C++ manipulation **/
    strcpy(dsn, LStrBuf((LStrPtr)(*(ConnectionOptions->DSN))));
    dsn[(*(ConnectionOptions->DSN))->cnt] = '\0';
    strcpy(user, LStrBuf((LStrPtr)(*(ConnectionOptions->Username))));
    user[(*(ConnectionOptions->Username))->cnt] = '\0';
    strcpy(pass, LStrBuf((LStrPtr)(*(ConnectionOptions->Password))));
    pass[(*(ConnectionOptions->Password))->cnt] = '\0';
    strcpy(num, LStrBuf((LStrPtr)(*Number)));
    // Program crashes here too, but that's the least of my concerns right now. Keep reading down.
    //num[(**Number)->cnt] = '\0';
    qlen = (int)strlen(
    "SELECT m.Number FROM master AS m WHERE (m.Number LIKE '');"
    nlen = (int)strlen(num);
    query = malloc((qlen + nlen + 1) * sizeof(UCHAR));
    sprintf(query,
    "SELECT m.Number FROM master AS m WHERE (m.Number LIKE '%s'\0);",
    num);
    // Prepare and make connection to database
    SQLAllocEnv (&env);
    SQLAllocConnect(env, &dbc);
    retcode = SQLConnect(dbc, dsn, SQL_NTS, user, SQL_NTS, pass, SQL_NTS);
    // Test success of connection
    if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    retcode = SQLAllocStmt(dbc, stmt);
    retcode = SQLPrepare(stmt, query, sizeof(query));
    retcode = SQLExecute(stmt);
    SQLBindCol(stmt, 1, SQL_C_CHAR, colNumber, sizeof(colNumber), &colNumberSize);
    SQLRowCount(stmt, &numRows);
    //Program crashes on the following line. I get an error in LV saying something about an error in memory.cpp
    DSSetHandleSize((*RecordSet), sizeof(int32) + (numRows * sizeof(Record)));
    (**RecordSet)->dimSize = numRows;
    retcode = SQLFetch(stmt);
    numRows = 0;
    while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    /* Need code here to retreive/create Records and put them in the array */
    retcode = SQLFetch(stmt);
    numRows++;
    SQLDisconnect(dbc);
    else
    // Free ODBC environment variables
    SQLFreeConnect(dbc);
    SQLFreeEnv(env);
    // Return LV error code
    return err;

    This looks incorrect:
    MgErr CINRun(COpt *ConnectionOptions, LStrHandle *Number, SetHdl *RecordSet)
    Did you let LabVIEW generate the C file??
    When you pass an array of clusters to a CIN, what is passed is a handle to the array. You are declaring a pointer to a handle. I just did a test passing an array of clusters to a CIN. The C file looks like this (comments are mine):
    typedef struct {
    int32 Num1;
    int32 Num2;
    } TD2; // the cluster
    typeDef struct {
    int32 dimSize;
    TD2 Cluster[1];
    } TD1; // the array
    typeDef TD1 **TD1Hdl; // handle to the array
    CIN MgErr CINRun(TD1Hdl Array);
    Notice that it passes you a HANDLE, not a pointer to a handle.
    On this line:
    DSSetHandleSize((*RecordSet), sizeof(int32) + (numRows * sizeof(Record)));
    If RecordSet is a HANDLE, then (*RecordSet) is a POINTER - you are passing a POINTER to a routine that expects a HANDLE.
    The line:
    (**RecordSet)->dimSize = numRows;
    Is also incorrect - if RecordSet is a HANDLE, then (*RecordSet) is a POINTER, and (**RecordSet) is an ARRAY, but you're asking it to be a pointer. (*RecordSet)->dimSize would be the size to fetch.
    Read the rules again on what is passed to CINs.
    I strongly suggest developing the interface first - the VI that calls the CIN. Put the CIN in place and let LabVIEW generate the initial C file.
    Then modify the code to do something simple with the input arguments, like fetch the array size, and put this number into an output argument. Something VERY basic, just to test the ins and outs. Debug this until all ins and outs are working.
    THEN AND ONLY THEN add code to do whatever work needs doing.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • FLV Array question - final flv file looping

    So the first part of my question was kindly and quickly
    answered by Rothrock. But I've got a new question that has arisen.
    When I set these up as an array it's ignoring the settings in the
    parameter field for autorewind which is set to false and it's
    looping the last movie file in the array. Is there anyway to avoid
    this by adding a snippet of new code to this code below:
    import mx.controls.MediaDisplay;
    flvURL = new Array();
    flvURL[1] = "preroll_live.flv";
    flvURL[2] = "atlas.flv";
    flvURL[3] = "jones_outro.flv";
    counter = 1;
    my_FLVplybk.contentPath = flvURL[1];
    var listenerObject:Object = new Object();
    listenerObject.complete = function(eventObject:Object):Void {
    counter++;
    if (counter == flvURL) {
    counter = 1;
    my_FLVplybk.contentPath = flvURL[counter];
    my_FLVplybk.addEventListener("complete", listenerObject);
    Preferably I'd like to either:
    Have the movie reset to an array file of my choice but not
    auto play or just Stop the movie on the final frame.
    Any help here will be greatly appreciated.
    Many thanks!
    -Kjup

    Anyone have any ideas on this...let me know if you need more
    details.
    Thanks,
    Kjup

  • Sort an array question

    Hello I have a sort question.
    I have a array like this
    "105016""Testnaam 16""16""16"" 16 16 1""105017""Testnaam 17""17""17"" 17 17 2""105018""Testnaam 18""18""18"" 18 18 3""105019""Testnaam 19""19""19"" 19 19 4""105020""Testnaam 20""20""20"" 20 20 5"This 105016 is the record number with data after it "Testnaam 16""16""16"" 16 16 1"
    Than there is new data "Testnaam 17""17""17"" 17 17 2" with record number 105017
    This is the way it should be because it is good sorted like you can see
    first. 105016
    than next record 105017
    than next record 105018
    than next record 105019
    than next record 105020
    It is in the right order but it can happen that record 105017 is before 105016 because something happend.
    All data is stored in an array like I said.
    Is it possible to go with a loop through the array and sort it the way I want it but with the data of the record after it???

    Hello I made this sorter.
    But does someone have some tips if there is a better way to do it.
    public class sorttest
    public static void main(String[] args)
        String[] data = {"2","boe","schrik","6","hoioi","b","5","test","hoi","9","doei","iets"};
        int[] inar = new int[data.length/3];
        String[] collected= new String [data.length];
        for (int i=0;i<data.length;i+=3)
          inar[i/3]=Integer.valueOf(data).intValue();
    int max = inar[0];
    for (int i=0;i<inar.length;i++)
    if(inar[i]>max)
    max=inar[i];
    int col=0;
    for (int i=0;i<(max+1);i++)
    for (int j=0;j<inar.length;j++)
    if(inar[j]==i)
    String test =""+inar[j];
    int cnt= Integer.valueOf(test).intValue();
    String iets = ""+cnt;
    for(int k=0;k<data.length;k++)
    if (iets.equals(data[k]))
         collected[col] = data[k]+" "+data[k+1]+" "+data[k+2];
         System.out.println("DATA OUT "+collected[col]+" COL "+col);
         col++;

  • Initializing an array

    I have an array that needs to be initialized 1096 times, I
    don't want to use a cfloop because I am looking for a better
    performance. So I use a query that brings all the records that have
    been initialized, the problem is if some of them hasn't been
    initialized and I use some conditionals as CFIF the application
    will throw an error because the specified position into the array
    doesn't exist yet.
    Here's my code.
    <cfquery name="lista_espacios"
    datasource="#Application.BD#">
    SELECT ISNULL(id_espacio,0) as id_espacio, ruta, url, alt
    FROM ESPACIOS
    ORDER BY id_espacio
    </cfquery>
    <cfloop query="lista_espacios">
    <cfset lista[lista_espacios.id_espacio][1] =
    lista_espacios.id_espacio>
    <cfset lista[lista_espacios.id_espacio][2] =
    lista_espacios.ruta>
    <cfset lista[lista_espacios.id_espacio][3] =
    lista_espacios.url>
    <cfset lista[lista_espacios.id_espacio][4] =
    lista_espacios.alt>
    </cfloop>
    <cfset cont=1>
    <cfif #lista[cont][1]# EQ #cont# ><a
    href="#lista[cont][3]#" onclick="abrirURL(#lista[cont][1]#);"
    target="_blank"><img style="border:0px" width="13"
    height="13" src="#lista[cont][2]#" title="#lista[cont][4]#"
    alt="#lista[cont][4]#" />
    </a>
    <cfelse>
    <img width="13" height="13" src="img/bad.jpg" />
    </cfif>
    <cfset cont = #cont#+1>

    quote:
    Originally posted by:
    Newsgroup User
    If I understand your requirements you have a database that
    has some
    records, but not necessarily all 1096 records at this time.
    You want to
    pull out these records, but have a full set of 1096 records
    even if some
    of them do not yet exist in the dataset.
    There are database tricks that can be used to create a record
    set like
    this. Hopefully somebody will chime in with the details. This
    would
    greatly simplify your processing after that.
    There is not enough information to know what approach would
    be most appropriate.
    What is the database type? Also, do the existing records have
    sequential values for idespacio, starting with 1?

Maybe you are looking for

  • How do I convert an InDesign file into a PDF file, it won't let me do it when I 'Save As'. Help??

    I need help with converting an InDesign file into a PDF file. I've tried looking into the program and seeing if i can do it, but it is not giving me the option. I need to be able to do this for work purposes. Please help.

  • Music files missing after sync with iTunes

    All of my devices are updated to the last version. I created playlists to manage syncing music from iTunes to iPhone. Sometimes my music files would be missing on my iPhone 6 running iOS 8.1 after sync with iTunes 12.0.1.26. When music missing, they

  • Zoom in Permanently?

    I have a lovely 27" display and Safari defaults to a very small font size and as my eyes need thicker reading glasses,  "Command +" two or three times and it's the way I want it. The problem is that I have to do this for every page.  Some have sugges

  • IPod video question...

    Hi people. I am looking forward in buying a 30GB MP3 player after a week and my tight choices came down on a Zune and an iPod video. I did a lot of research on both, including going to Apple's Tech Specs of the iPod video. It said there, that you mus

  • How to install CCMS agent in MSCS cluster system?

    Hi, We just migrated our WAS 7.0 system from a single to a MSCS cluster system and we need re-install CCMS agent on it. New cluster system have two nodes. Each node we have local SAP instances. We have central instance for message server running on a