How to declare a pointer to structure element which is array structures

 LStr, *LStrPtr, **LStrHandle structure is taken from LabView cintools extcode.h
   I used: sprintf(((*(*in_array)->Strings[*count])->str), local_str); to pass local_str string to
LabView array.  It worked fine, but  one programmer adviced me to change code to  be more readable.
Means - to change  (*(*in_array)->Strings[*count]) construction to a pointer. I tried many different
ways to implement this - but in all cases it caused LabView to crash. I understand that this question
is related to C programming not about LabView, but could you point me at a place where I have mistake ?
The most likely incorrect string is " LV_array = &(**((**in_array).Strings[*count])); "
Thanks in advance.
1.  typedef struct {
2.        int32   cnt;            /* number of bytes that follow */
3.        uChar   str[1];         /* cnt bytes */
4.  } LStr, *LStrPtr, **LStrHandle;
5.      
6.  typedef struct {
7.        int32 dimSize;
8.        LStrHandle Strings[1];
9.  } LVStringArray;
10.      
11. typedef LVStringArray **LVStrArrayHdl;
12.      
13  _declspec(dllexport) void avg_hello(int *count, LVStrArrayHdl in_array)
14.      {
15.      
16.       unsigned char *local_str="Entering function ma_in()";
17.       (*count) = 0;
18.       LStr* LV_array;
19.      
20.       LV_array = &(**((**in_array).Strings[*count])); //Set address to which should point LV_array
21.       subfunc(count, &in_array);                      // Call a function which resizes array (works)
22.       sprintf(LV_array->str, local_str);              //passing string to LabView (not working)
23.      
24. }
Solved!
Go to Solution.

thank you Andrey Dmitriev! spasibo!
With your example I understood where I have error in my code:
I tried to assign to pointer an address of string which wasn't yet pre-allocated!
that means simply swapping strings we get final code:
1.  typedef struct {
2.        int32   cnt;            /* number of bytes that follow */
3.        uChar   str[1];         /* cnt bytes */
4.  } LStr, *LStrPtr, **LStrHandle;
5.      
6.  typedef struct {
7.        int32 dimSize;
8.        LStrHandle Strings[1];
9.  } LVStringArray;
10.      
11. typedef LVStringArray **LVStrArrayHdl;
12.      
13  _declspec(dllexport) void avg_hello(int *count, LVStrArrayHdl in_array)
14.      {
15.      
16.       unsigned char *local_str="Entering function ma_in()";
17.       (*count) = 0;
18.       LStr* LV_array;
19.       subfunc(count, &in_array);                      // Call a function which resizes array (works), First we resize array, and only after that we can assign an address of string to a pointer
20.       LV_array = &(**((**in_array).Strings[*count]));  //Assigning address to which should point LV_array
21.      
22.       sprintf(LV_array->str, local_str);              //passing string to LabView (not working)
23.      
24. }

Similar Messages

  • How to change the properties of individulal elements in an array?

    Hi all,
    I have an array (size is 25) of string and I want to disable and grayout half of them. But how do I do it? How do I change the properties of individual elements in an array? I have tried to use some of the examples given in the discussion forums, but it didint work for the task mentioned above. Anybody would be able to help me with a suitable example that can be specifically used for disable or enable the individual array  elements?
    Dev

    Telemaque wrote:
    The user will see the first half of the string elements filled-in and the lower half grayed-out (to be filled in later).  Make a test VI, play around.
    ... except that all elements "greyed out" with this method contain the default string for the array element (blank by default, but changeable). There is no way to have meaningful, unique text in the greyed out elements.
    I would suggest to use a listbox as control/indicator. Here elements can easily be disabled programmatically.
    LabVIEW Champion . Do more with less code and in less time .

  • How Do I Print the Number of Elements in An Array

    How do I print: "There are ____ number of elements in the array?"

    If you have a String holding a sentence, and if you split on non-empty sequences of whitespace (if the string has newlines in it, you'd probably need to pass the argument that makes \s match newlines, and for that you would probably need to use java.util.regex.Pattern -- see the docs and try some tests), when you'd get an array of Strings that were the non-whitespace parts of the original String. That makes for a reasonably good definition of the words in the sentence, although you could arguably get into some gray areas (does "isn't" count as one or two words? Does a sequence of numbers or punctuation qualify as a word?). In that case, counting the number of elements in the resulting array of String. using .length, would be a reasonable way to get the number of words in that sentence, yes.
    But rather than asking for confirmation on forums, why don't run some tests?
    import java.io.*;
    public class TestWordCount {
      public static void main(String[] argv) {
        try {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          String line;
          while((line = in.readLine()) != null) {
            int count = // your code here, to count the words
            System.out.println("I see " + count + " words.");
        } catch (IOException e) {
          e.printStackTrace();
    }Put your word-counting code in there, then run it from the command line. Type in a sentence. See how many words it thinks it found. Does it match with your expectation, or the examples given (hopefully) with your homework assignment?

  • How to set Keyfocus to a single Element in an Array-Control

    How do i set the keyfocus programmatically to a single numeric-control in an array-control.

    This is detailed handled here.
    Guenter

  • The "Use Selection of Structure Elements" Option in RSRT Query Properties

    Hi, does anyone know the side effect of enabling this option for all BEx Queries? The help states the following: "The Use Selection of Structure Elements option can be selected for any query; however, it is only useful in some cases. In queries, selections are frequently based on one or more characteristics in the columns, or more precisely, in the structure elements. One or more of these structure elements are often filtered in the BEx Analyzer or in BEx Web applications. If you do not select the Use Selection of Structure Elements option, these dynamic (structure element) selections are not transferred to the database. Normally, the data for the entire structure or for both structures is then read from the database." It sounds to me that there is no harm in checking this flag all the time, but what is confusing is the default state of this option; i.e. unchecked.
    I would appreciate if someone can clarify the downside of checking this flag.
    Thanks,
    Mohamed Judi

    Hello Michael,
    Checking this simple property helps improve performance in situations where there are many Restricted Key Figures and other calculations in the Query Definition
    If analysis of the query performance indicates very high EVENTID 3200 times, and/or the FEMS number is very high try enabling this property and check performance.
    Checking this ensures the structure elements are sent to the database for processing.
    Check the below link: Page 14
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/006b1374-8f91-2d10-fe9c-f9fa12e2f595?QuickLink=index&overridelayout=true&48747879633011
    Thanks,
    Vinay

  • Condition on a Local Structure element-BI7

    Hi All,
    BI7, I have to create a structure with 2 key figures and then build a condition on one of the keyfigures.
    I have done this but in query designer it gives me a error "condition is created on a structure element which is never visible"
    Pls suggest.

    Condition seems to be appropriate. definition is proper. its only that its not built directly on a keyfigure, but on a keyfigure which is under a local structure..
    Pls suggest

  • How can I reach a structure-element instead of structure(value of other variable)

    Hi gurus,
    Sorry If my question is not really clear.
    Now I give result to a structure element.(green)
    But I'd like to replace this with the red.
    TYPES: BEGIN OF structure,
                  x1          TYPE i,
                  x2          TYPE i,
                  x3          TYPE i,
                  x4          TYPE i ,
    END OF structure.
    DATA: s  TYPE structure,
         name TYPE char2.
    name = 'X1'.
    s-x1 = 0.
    s-(name) = 0.
    How can I do this? With filed symbol?
    Thanks,
    Mark

    Hi Mark
    Please check this syntax 'ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.'
    regards,
    Archer

  • How to declare value binding to array list element in a pojo?

    I have a POJO called P, that contains an ArrayList member called w.
    class P {
    private ArrayList w = new ArrayList(5);
    w is initied in the class constructor.
    The POJO is in the SessionBean and I would like to reference individual
    elements in the ArrayList via a value binding like so;
    #{SessionBean1.instanceOfP.w[5]}
    I'm not sure how to declare the getter/setter for member W in POJO P
    so that setter and getter injection work.

    You may not be able to directly set the indexed value.
    Try some thing like this.
    Add a property that returns the indexed value.
    Ex. if you ArrayList objets are of type "String"
    int index = 5;
    public String getMyValue(){
    return w.get[index]
    Now your value binding would look something like
    #{SessionBean1.myValue}
    BTW, if you want to access different index, create another method
    public void setIndex(int index){
    this.index = index;
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • How to declare custom structure in form interface in smartforms?

    Hi,
    How to declare custom structure in form interface in smartforms?
    Thanks.

    Create a structure in SE11 and use that in Form Interface - > Tables tab in smartforms.
    Pranav

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • How to enhance the length of standard UI element which maps to DDIC structure?

    Dear Webdynpro Expert,
    I got a requirement to enhance the length of UI element which maps to DDIC structure attribute. I have tried by using
    View Enhancement by hiding the standard UI element,
    Adding the required field in the standard structure through append structure,
    mapping the appended structure field to the UI element.
    But it shows error as data compatibility.
    Can you please share some light on it.
    Thanks.

    Hi Mohsin,
    When and where are you getting this data compatibility error???
    Try to create a new context attribute and add your new DE.
    BR,
    RAM.

  • How to use Reference type of Data Element

    Hi guys, is there anyone could give me a trace how to use reference type of data element.
    More details i'm going to reach is:
    I create 2 tables:
    eq.
    1. table ZFIRST has field X with data element ZFX (Data element i declared).
    2. table ZSECOND has field Y.
    Here at field Y (second table) I'm going to declare a new data element say it ZFY, but in ZFY I'm going to use the data element as i declared before (ZFX). Is it possible if I do it using reference type data element (SE11)?
    I already did this way, but I got error :
    Field Y: Reference ZFX to class w/o interface cannot be used in DB table ZSECOND
    What does it mean?. Did I miss something about using reference data element type?.
    This error occurs when I activate ZSECOND table. However in creating ZFY (reference) to data element ZFX, there is no error occur.
    The point is I need to RE-declared existing data element and ot put existing data element(ZFX) to my current table (ZSECOND).
    Any helpful will be highly appreciated.
    Thanks.
    Edited by: dinivian dondi on Nov 4, 2010 8:30 AM

    Field Y: Reference ZFX to class w/o interface cannot be used in DB table ZSECOND
    What does it mean?. Did I miss something about using reference data element type?.
    Apparently system doesn't allow you to type a transparent table field with deep type. This refers to references and tables types as components. The RDBMS (Relational DB Management System) cannot interpret this componenets correclty and mapp them to TABLEs in DB.
    So I am affraid you won't be able to type table component with reference to other data element.
    The point is I need to RE-declared existing data element and ot put existing data element(ZFX) to my current table (ZSECOND).
    Sorry but I don't get it, could you please explain this more clearly. Maybe then we can think of some workaround for you.
    Regards
    Marcin

  • How we can attach search help directly to the table field / structure field

    Hi All,
       Can you please let me know the step by step procedure of How we can attach search help directly to the table field / structure field.
    Regards,
    jaya

    Hi Jaya,
    1. Create a search help using SE11.
    2. Include this search help in the field of table in SE11. There is a tab in the table defination where you can specify the search help.
    Even you can specify search help at data element level, screen field level.
    Reward points if useul.
    Regards,
    Atish

  • How do I get sdo_point into C host variables from OTT structures?

    How do I get sdo_point info into C host variables from structures generated by OTT?
    Databse Version 10.1.0
    I am using OTT to generate C structures for the Oracle Spatial datatype sdo_geometry. The file is generated as
    #ifndef GEOMETRY_ORACLE
    # define GEOMETRY_ORACLE
    #ifndef OCI_ORACLE
    # include <oci.h>
    #endif
    typedef OCIRef sdo_geometry_ref;
    typedef OCIRef sdo_point_type_ref;
    typedef OCIArray sdo_elem_info_array;
    typedef OCIArray sdo_ordinate_array;
    struct sdo_point_type
    OCINumber x;
    OCINumber y;
    OCINumber z;
    typedef struct sdo_point_type sdo_point_type;
    struct sdo_point_type_ind
    OCIInd _atomic;
    OCIInd x;
    OCIInd y;
    OCIInd z;
    typedef struct sdo_point_type_ind sdo_point_type_ind;
    struct sdo_geometry
    OCINumber sdo_gtype;
    OCINumber sdo_srid;
    struct sdo_point_type sdo_point;
    sdo_elem_info_array * sdo_elem_info;
    sdo_ordinate_array * sdo_ordinates;
    typedef struct sdo_geometry sdo_geometry;
    struct sdo_geometry_ind
    OCIInd _atomic;
    OCIInd sdo_gtype;
    OCIInd sdo_srid;
    struct sdo_point_type_ind sdo_point;
    OCIInd sdo_elem_info;
    OCIInd sdo_ordinates;
    typedef struct sdo_geometry_ind sdo_geometry_ind;
    #endif
    I can successfully access the sdo_gtype and sdo_ordinates using the following ProC code
    exec sql begin declare section;
    int sptype;
    double coord[100000];
    sdo_geometry *spgeom;
    sdo_ordinate_array *spcoords;
    exec sql end declare section;
    /* allocate memory for the geometry host variable */
    exec sql allocate :spgeom;
    select bounds into :spgeom from boundary;
    /* retrieve the geometry type from the geometry host variable into a host variable */
    exec sql object get sdo_gtype from :spgeom into :sptype;
    /* allocate memory for the sdo_ordinate_array host variable */
    exec sql allocate :spcoords;
    /* move the coordinates from the geometry host variable into the sdo_ordinate_array host variable */
    exec sql object get sdo_ordinates from :spgeom into :spcoords;
    /* determine the number of coordinates */
    exec sql collection describe :spcoords get size into :numord;
    /* move the coordinates from the sdo_ordinate_array host variable into a host array */
    exec sql for :numord collection get :spcoords into :coord;
    I cannot, however, figure out how to get point data out of the host variable spgeom. If I prepare code analagous to the other types in the geometry structure, I get an error. I can see that sdo_point is different because it is a struct within the geometry definiton of typedef OCIRef but my knowledge of C is sufficeintly weak that I cannot figure out how to get sdo_point into C host variables. Some sample code for getting the sdo_point data would be greatly appeciated.
    Thanks, Chris

    To get point data from geometry column use following
    select a.location.sdo_point.x, a.geometrycolumn.sdo_point.y
    from tablename a;
    Do not forget to alias the table.

  • How to declare a dynamic array in java

    I have to use a dynmic array of boolean and the size of this array will defiend throuh the run of the program to explian
    boolean[][] a;
    a=new boolean[number_of_ raw][number_of_ culm];
    after the program run the number_of_ raw and number_of_ culm will defind..so if any body know how to declare this kind of arraies in java please help me.

    My previous post gives me an idea on how to use ArrayList of ArrayList as dynamic 2 dimensional array.
    More info bellow
    ArrayList rows = new ArrayList()
    ArrayList columns_of_row0 = new ArrayList()
    rows.insertAt(0) = columns_of_row0;
    ArrayList columns_of_row1 = new ArrayList()
    rows.insertAt(1) = columns_of_row1;and so on..
    You can't use the code exactly or similar way, it would depend on how this array grows in your application.
    But this and my previous post should give an idea on how to insert and retrieve elements from ArrayList when
    treated as 2 dimensional array.
    Hope this helps.

Maybe you are looking for

  • ITunes 7.0.1.8 experiences - Here's what got fixed for me...

    After news of the iTunes 7.0.1.8 update broke out today, I downloaded it and have used it for a little while. I'd thought I'd share my experiences so far, but please take note that I did not do any CD burning/importing tests, nor do I own an iPod to

  • Messaging server not calling the SpamAssassin

    HI all, The current instalation: For SJES Messaging : # ./imsimta version Sun Java(tm) System Messaging Server 6.2 (built Dec 2 2004) libimta.so 6.2 (built 00:34:23, Dec 2 2004) SunOS rcaredev 5.9 Generic_117171-08 sun4u sparc SUNW,Sun-Fire-V240 For

  • Using LAP1242AG as RAP for Outdoor Mesh

    Hi, I am looking at building a outdoor mesh to provide free open wireless, the plan is to use two AIR-LAP1242AG mounted inside our building with external antenna's attached to the outside as RAP's, LAP1524SB's will be chained from the RAP's going in

  • AS does not open after update

    Cannot get adobe story to open after update (indeed there was difficulty before as well; it got worse after update). This applies to both offline and online. Even after a restart. All I get is a big, blank, black page, with no projects on it, not eve

  • Read data from ODS table using value mapping

    hi all; can anyone help on how to read data from ODS table using value mapping