How to obtain Hashtable element (array) base type?

Hi,
     I have read the thread
          http://forum.java.sun.com/thread.jspa?forumID=52&threadID=531561
     on determining the base type of an object array.
     I tried applying the technique to my Hashtable where the element are arrays, this is how I am setting up my Hashtable to pass on to my native method
Hashtable ht = new Hashtable();
Float Kd[] = new Float[1];
Kd[0] = 0.1f;
Float from[] = new Float[3];
from[0] = -4.0f;
from[1] = 2.0f;
from[2] = 1.0f;
Integer indices[] = new Integer[4];
indices[0] = 217;
indices[1] = 17;
indices[2] = 769;
indices[3] = 23;
     myNativeMethod("dbname",ht);
     In my native method, I have the following which is able to determine the array size so I think it is kind of working/correct but when I tried to determine the base type of the array, I keep getting Bus error.
     Here is my native code (as part of my SWIG code)
     Should I be handling arrays obtained from Hashtable differently, can someone point out to me what the correct approach is?
Regards
8<------8<------8<------8<------8<------8<------8<------8<------
if ($input != 0) {
std::cout << "SWIG ...parameterlist..." << std::endl;
// Generated typemap code
const jclass hashtable = jenv->FindClass("java/util/Hashtable");
if (hashtable != 0) {
const jclass enumeration = jenv->FindClass("java/util/Enumeration");
const jmethodID keys =
     jenv->GetMethodID(hashtable, "keys",
               "()Ljava/util/Enumeration;");
const jmethodID get =
     jenv->GetMethodID(hashtable, "get",
               "(Ljava/lang/Object;)Ljava/lang/Object;");
if (enumeration != 0) {
     const jmethodID hasMoreElements =
     jenv->GetMethodID(enumeration,
               "hasMoreElements", "()Z");
     const jmethodID nextElement =
     jenv->GetMethodID(enumeration,
               "nextElement", "()Ljava/lang/Object;");
     for (jobject keyset = jenv->CallObjectMethod($input, keys);
     jenv->CallBooleanMethod(keyset, hasMoreElements) == JNI_TRUE;) {
     jstring key = (jstring)jenv->CallObjectMethod(keyset, nextElement);
     jarray value = (jarray)jenv->CallObjectMethod($input, get, key);
     jclass valueClass = jenv->GetObjectClass(value);
     jclass valueClassClass = jenv->GetObjectClass(valueClass);
     const jmethodID getName =
     jenv->GetMethodID(valueClass,
               "getName", "()Ljava/lang/String;");
     jstring valueClassClassName =
     (jstring)jenv->CallObjectMethod(value, getName);
     const char *vccptr = jenv->GetStringUTFChars(valueClassClassName,
                              0);
     std::cout << "vccptr is " << vccptr << std::endl;
     jenv->ReleaseStringUTFChars(valueClassClassName, vccptr);
     const char *keyptr = jenv->GetStringUTFChars(key, 0);
     std::cout << "key is " << keyptr << std::endl;
     int numElements = jenv->GetArrayLength(value);
     std::cout << "value array size is " << numElements << std::endl;
     // const char *valptr = jenv->GetStringUTFChars(value, 0);
     // $1 = CSLAddNameValue($1, keyptr, valptr);
     jenv->ReleaseStringUTFChars(key, keyptr);
     // jenv->ReleaseStringUTFChars(value, valptr);
8<------8<------8<------8<------8<------8<------8<------8<------
Regards
Message was edited by:
nicholas_yue

You've asked the same thing before. Assuming that you've defined the function prototype correctly when you built the DLL from the VI, you should be able to call it and get the results from it. You do not need to change the return type when you build the DLL. Read the information at http://zone.ni.com/devzone/conceptd.nsf/webmain/7D6A20FE02EDBF318625690700704CF3. Even though it was written for LabVIEW 6, the section on Accessing LabVIEW 6x Arrays from Microsoft Visual C++ is still valid.

Similar Messages

  • Change a property of a specifc array element (array of type defs)

    If I have an array of elements, and I want to change aproperty of one specific element, at position X, is there a way to do this?
    Basically, I have an array of string indicators indicating certain tests attached to certain ports, and I want to change the text to bold on certain indicators, and i want to color certain indicators green or red.  Any chance in an array or clusters only? 
    Thanks Guys.

    While you can't change the properties for a single array element, there are solutions.
    For the background color, you can turn the array element into a cluster of your string (which would be transparent) and a color box which will be the background. You can then change the value of the color box and the color will change.
    For the bold text, I think your only option will be to get rid of the string control and make the array element a picture control instead. Using the picture VIs, you can draw a colored rectangle and then place text inside it (and each element can have different text properties). That way, you won't even need the color box.
    Try to take over the world!

  • In java code, how to obtain the input a user types in JTextArea

    In my java code, I have two JTextArea. When a user
    starts the GUI, there are two testareas showing up
    (by typing: java xxx). The user types in words and
    sentences in the first testarea, and how can I code
    the java program so that something can come out
    on the second testarea, with that something depends
    on what the words are.

    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class GUI extends JFrame{
        JTextArea jta1, jta2;
        public static void main(String args[]){
            GUI g = new GUI();
            g.addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent we){
                      System.exit(1);         
            g.setSize(400,300);
            g.setVisible(true);   
        public GUI(){
            JPanel p = new JPanel();
            p.setLayout(new FlowLayout());
            jta1 = new JTextArea(10,10);
            jta1.setLineWrap(true);
            jta1.addKeyListener(new KeyAdapter() {
                public void keyTyped(KeyEvent e) {
                    char c = e.getKeyChar();
                    jta2.append(String.valueOf(c));
            jta2 = new JTextArea(10,10);
            jta2.setLineWrap(true);
            p.add(jta1);
            p.add(jta2);
            getContentPane().add(p);
    } You can implement whatever logic you want inside the keyTyped method.

  • Log warning "Link from unexpected type of object" ("Possible path leak, unable to purge elements of base")

    Hey,
    I'm getting the following warning after closing my LabVIEW application (see also LabVIEW code snippet attached).
    Can you help me figure out if this may be relevant?
    I don't experience anything unexpected, also no leaking of memory.
    Thanks,
    Peter
    #Date: Mo, 11. Nov 2013 15:14:42
    #OSName: Windows 7 Enterprise Service Pack 1
    #OSVers: 6.1
    #OSBuild: 7601
    #AppName: LabVIEW
    #Version: 12.0 32-bit
    #AppKind: FDS
    #AppModDate: 06/26/2012 19:23 GMT
    #LabVIEW Base Address: 0x00400000
    Processing 1230000708 link to [LinkIdentity "ProcessTaskWrapper.lvclass:" [ Mein Computer]
    <DEBUG_OUTPUT>
    11.11.2013 15:15:35.726
    DWarn 0xC1CF3BB8: Link from unexpected type of object {HeapClass=BDHP,UID=5401,DPId=23,o=0x0de33558} in VI [VI "ProcessPool.lvclass:configure.vi" (0x11646770)]
    e:\builds\penguin\labview\branches\2012\dev\source\linker\HeapLinker.cpp(2852) : DWarn 0xC1CF3BB8: Link from unexpected type of object {HeapClass=BDHP,UID=5401,DPId=23,o=0x0de33558} in VI [VI "ProcessPool.lvclass:configure.vi" (0x11646770)]
    minidump id: 236443a2-84d3-403e-a24a-fb72dd7ff65d
    $Id: //labview/branches/2012/dev/source/linker/HeapLinker.cpp#12 $
    </DEBUG_OUTPUT>
    0x0069DDF3 - LabVIEW <unknown> + 0
    0x10016460 - mgcore_SH_12_0 <unknown> + 0
    0x013E32A5 - LabVIEW <unknown> + 0
    0x00EBECFC - LabVIEW <unknown> + 0
    0x01060FD1 - LabVIEW <unknown> + 0
    0x0106112D - LabVIEW <unknown> + 0
    0x0106A5C9 - LabVIEW <unknown> + 0
    0x0106B6D1 - LabVIEW <unknown> + 0
    0x005C28D3 - LabVIEW <unknown> + 0
    0x005C03FC - LabVIEW <unknown> + 0
    0x005C1BCB - LabVIEW <unknown> + 0
    0x005C20AE - LabVIEW <unknown> + 0
    0x006495BC - LabVIEW <unknown> + 0
    0x009ECF0E - LabVIEW <unknown> + 0
    0x01CC57D4 - LabVIEW <unknown> + 0
    0x01CC5964 - LabVIEW <unknown> + 0
    0x006513E3 - LabVIEW <unknown> + 0
    0x00657C9D - LabVIEW <unknown> + 0
    0x00B87A67 - LabVIEW <unknown> + 0
    0x00B8C606 - LabVIEW <unknown> + 0
    0x00B8DA6D - LabVIEW <unknown> + 0
    0x014A90C2 - LabVIEW <unknown> + 0
    0x014ABA3C - LabVIEW <unknown> + 0
    0x014ADA42 - LabVIEW <unknown> + 0
    0x01B4BE87 - LabVIEW <unknown> + 0
    0x01BF99C5 - LabVIEW <unknown> + 0
    0x01B5DBFC - LabVIEW <unknown> + 0
    0x761D62FA - USER32 <unknown> + 0
    0x761D6D3A - USER32 <unknown> + 0
    0x761D77C4 - USER32 <unknown> + 0
    0x761D788A - USER32 <unknown> + 0
    0x01BF9C4D - LabVIEW <unknown> + 0
    0x01BFA0C7 - LabVIEW <unknown> + 0
    0x042F14D6 - QtManager452_2012 <unknown> + 0
    0x670E7261 - NIQtCore_2012 <unknown> + 0
    0x00000000 - <unknown> <unknown> + 0
    Possible path leak, unable to purge elements of base #0
    Attachments:
    2013-11-11_153125.jpg ‏48 KB

    Hello Peter,
    as you can imagine, it is difficult for us to interpret an error message without a certain amount of information.
    Even more, when you cannot reproduce it yourself every time.
    And, on a side note, we as Application Engineers do not know how exactly the compiler works.
    This could be something for the developers, but: to escalate an issue to the developers, there are some requirements.
    - we have to know exactly when and how the error occurs, i.e. the exact steps which have to be done, so you can force the error to show up
    - exact OS, LabVIEW version, all NI Software which is installed
    - what is the application
    - what has been done as troubleshooting actions, can the issue be avoided somehow
    - we would need your VI or project, or at least a minimal version of them, which can produce the error message
    - one of us should be able to reproduce the procedure and get the same error
    I am sorry, but at this point, it seems like I cannot do much for you in this topic.
    Have a nice day,
    Best regards
    PS: one more question:
    is this even a message from LabVIEW? For me, it seems like a Windows crash report - which we can not fully support.
    Christopher W.
    Intern Application Engineering | NI Certified LabVIEW Associate Developer (CLAD) | NI Germany

  • How to disable individual elements in array

    How do I disable individual elements in an array at runtime.

    I assume you are referring to the control property "disabled".
    If so there is no way to disable a single element of an array. By definition an array is a collection of data, it is not a collection of controls. A fine line but an important one. So you can configure the single control that makes up the array and defines its type. For example, if you have an array of Booleans, you can change the color of the Boolean. However this will change the color of all the Booleans in the array. It is 1 control, with a lot of values.
    Part of the reason for this is memory. Imagine an array of 1 million elements. If you could set the properties of each element, then to store that array would be incredibly large. It would be 1 million U8s for example, but then all the properties for each 1 million elements would also need to be saved. Therefore your 1 million element array of bytes could easily represent 100 million bytes in memory.
    Let me know if this explanation makes no sense, I usually explain it better, but I think I need more coffee.
    The way around this is clusters. You can change each element in a cluster, so if your array is of a manageable size, change your array control into a cluster of n elements. You can then use the cluster to array function to convert the data to the array of data you need. Unfortunately this method means that before runtime you must know the maximum number of elements you will need. You can always hide the extras, but you can not create more during execution.

  • How to translate text elements in forms from type : pdf

    does anybody know how to translate text elements
    in  pdf  from english to other languages.
    i tried the tran. se63 and filled in the desired language,
    but there was no effect on the output ,
    thanks,
    ami

    call this funcation. crate_text.
    CALL FUNCTION 'CREATE_TEXT'
             EXPORTING
               FID               =
               FLANGUAGE         =
               FNAME             =
               FOBJECT           =
             SAVE_DIRECT       = 'X'
             FFORMAT           = '*'
             TABLES
               FLINES            =
           EXCEPTIONS
             NO_INIT           = 1
             NO_SAVE           = 2
             OTHERS            = 3
           IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
           ENDIF.

  • How to use array or type in "IN" criteria

    Hi all,
    anybody knows how to use group of same datatype data ( array or type ) in SQL statement
    For example
    ls_dept[1] = 'abc';
    ls_dept[2] = 'xyz';
    ls_dept[10] = 'ppr';
    i want to use this group of data in "IN" criteria like
    Select * from department where dept in ('abc','xyz'.....''ppr');
    if anybody know how to use please reply me as soon as possible.
    Thanks,

    I hope you are not suggesting concatenating literals from a web front-end application ;) Is it not what he was saying.. he is getting user input info from an application.. if the user sends multiple values.. he has to build a string with concatenating literals..
    correct me if I am wrong.

  • How to delete an  element in an array...(simple way)

    hi,
    Newbie here... please help how to delete an element in an array list?
    there are alot of codes but they're complicated for a newbie like me..
    (simple codes would be better ..:) thank you...

    makk_88 wrote:
    since u want the simple method.....
    just overrite the position of the element that need to be deleted with the next element in the array..
    by doing this, element need to be deleted will not be accessibe..
    i think u got..what i'm saying.
    thnx..Mak,
    Say we wish to delete the second element of an array a[1]. Do you really believe that a[1] = a[2] somehow magically deletes a[1]? I really don't think so Tim.
    Two eggs, minus 1, equals two eggs? Interesting theory, but I think you're probably wrong.
    *@OP:* My advise is just use an ArrayList.
    Cheers. Keith.

  • I want to add image in column is it possible then how to add image in data base what data type we need to do

    I want to add image in column is it possible then how to add image in data base  what data type we need to give we required any casting  please show me one example
    jitendra

    Hi again,
    Several points that can help more:
    1. If you are working with Dot.Net, then I highly recommend read the first link that you got! This is nice and simple coding. Another option is this link which is even better in my opinion:
    http://www.dotnetgallery.com/kb/resource21-How-to-store-and-retrieve-images-from-SQL-server-database-using-aspnet.aspx
    2. As i mention above both link use the column's type image. There are several other option of working with Files. In most of my applications architecture I find that it is better to use a column which let us use any type of file and not an image column.
    In choosing the right column's type for your needs basically your fist question should be if if you want to store your data inside relational database environment or outside relational environment. It is a good idea to look for blogs on this issue. Next
    if you chose to store your data inside then you need to chose the right column type according to your server version. I highly recommend to look for blogs on the differences between those column's types: IMAGE, 
    Check those links:
    To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem
    http://research.microsoft.com/apps/pubs/default.aspx?id=64525
    FILESTREAM feature of SQL Server 2008
    http://msdn.microsoft.com/library/hh461480
    FileTables feature of SQL Server 2012
    http://technet.microsoft.com/en-us/library/ff929144.aspx
    Compare Options for Storing Blobs (SQL Server)
    http://technet.microsoft.com/en-us/library/hh403405.aspx
    Binary Large Object (Blob) Data (SQL Server)
    http://technet.microsoft.com/en-us/library/bb895234.aspx
    Managing BLOBs using SQL Server FileStream via EF and WCF streaming
    * Very nice tutorial!
    http://petermeinl.wordpress.com/2012/02/20/managing-blobs-using-sql-server-filestream-via-ef-and-wcf-streaming/
    [Personal Site] [Blog] [Facebook]

  • How do I open a PSA file type in Photoshop Elements 12

    How do I open a PSA file type in Photoshop Elements 12

    A file with a .PSA extension is most probably a catalog file from an older version of Elements (up to PSE5). To be able to use it with a newer version (including PSE12), you'll have to convert the catalog to the new format. In the organizer, open the 'File' menu, select the catalog manager (shift Ctrl C) and click the convert button, browse to the .psa file. Your catalog will be converted to the new format.

  • How can I restore move function and type tool which abruptly became balky with Elements 8 with OS10.10.2?

    How can I restore move function and type tool which abruptly became balky with Elements 8 with OS10.10.2?

    Follow-up: I'm worried about performing any actions without input, because I don't want to back myself into a corner.
    Will resetting Firefox fix the problem (instead of creating a new places database)? https://support.mozilla.org/en-US/kb/reset-firefox-easily-fix-most-problems
    According to this article, a reset will keep browsing history, which should allow me to access my lost tabs IF it will also fix my database problem.

  • How to show the elements of an array?

    How to show the elements of an array, when the array size changes every loop?
    It's possible to use node property?
    thanks
    Vicens
    Win XP/ LV7.1
    Attachments:
    show elements.PNG ‏184 KB

    Basically it is (at least in LV8.0). There is a property "Number of Rows" which sets the number of visible rows. If your 1D array is placed horizontally, use "Number of Columns".
    Using LV8.0
    Don't be afraid to rate a good answer...

  • Urgent : How to use pricing scale base type "G" in CRM?

    Hi Gurus
    We are facing a problem regarging scale base type G which is scale based on a formula in SAP ECC side. I one of our Z condition type wea re using scale base type G and using a formula 901 to calculate pricing in SAP R/3.
    But scale base type "G" is not supported in CRM as the entry is not there in /SAPCND/T681VS and we could not find any ways to include it in CRM. We even tried by entering the entried in the table by debug method but then the records, specialy the supplement record, are not replicating correctly in CRM from ECC.
    So for time being we changed the scale base type to C from G in ECC side.
    Can you please guide me if there is any way to use scale base type G in CRM? Or what can be the way around to use scale based on formula in CRM ?
    Is it possible to change the scale base type while the records are getting replicated to CRM?? But how will it work then.
    This is very urgent.
    An useful answer will be highly appreciated.

    Hello Singamshetty and Micheal,
    We are facing exact same issue. Problem is that formula 901 does not get called in ECC with scale base type = 'c' in condition type ZSH1.  Because of this, order and billing document in ECC have wrong condition value and then order document in CRM also gets wrong value once the billing document is saved.
    This is highly critical issue as it's a big $ loss. Any expert, please suggest how to correct it?
    Thanks
    Sandeep

  • How can I multiply all values of a 4-element array with all of its inverse values resulting to an array having all 16 products?

    I'm quite new to LabVIEW (v.8.0) and I'm trying to figure out the easiest way to have a 4-element array multiplied by its inverse values resulting in a 16-element array
    Array 1 values = 1, 2, 3, 4
    Array 1 inverse values = 1, 0.5, 0.33, 0.25
    Resulting array = (1, 0.5, 0.33, 0.25, 2, 1, 0.66, 0.5, 3, 1.5, 1, 0.75, 4, 2, 1.32, 1)
    Any advice would be appreciated. Thanks!
    Solved!
    Go to Solution.

    Attachments:
    mo.doc ‏27 KB

  • How to obtain system form's type and count?

    Hi all
    i wish to open a system form by calling the GetForm method of the Forms collection.
    My question is how do i know the form's type and count in order to get it?
    appreciate the help
    Yoav

    To open Activity form, you need to have the menuUID.
    in order to get it , Click on View of the toolbar, and then System Information
    (or CtrlShiftD)
    Now I guess you know you have more information about items in forms and menu on the bottom left corner of Business One.
    Then in the toolbar, click on Modules, Business Partnet, and put the mouse on the menu Activty.
    You will see in the bottom left corner the value:Menu Uid = 2563
    HTH
    Sebastien

Maybe you are looking for