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/

Similar Messages

  • Programmatically create array from common cluster items inside array of clusters

    I have seen many questions and responses on dealing with arrays of clusters, but none that discuss quite what I am looking for. I am trying to programmatically create an array from common cluster items inside array of clusters. I have a working solution but looking for a cleaner approach.  I have an array of clusters representing channels of data.  Each cluster contains a mixture of control data types, i.e.. names, types, range, values, units, etc. The entire cluster is a typedef made up of other typedefs such as the type, range and units and native controls like numeric and boolean. One array is a “block” or module. One cluster is a channel of data. I wrote a small vi to extract all the data with the same units and “pipe” them into another array so that I can process all the data from all the channels of the same units together.  It consists of a loop to iterate through the array, in which there is an unbundle by name and a case structure with a case for each unit.  Within a specific case, there is a build array for that unit and all the other non-relevant shift registers pass through.  As you can see from the attached snapshots, the effort to add an additional unit grows as each non-relevant case must be wired through.  It is important to note that there is no default case.  My question:  Is there a cleaner, more efficient and elegant way to do this?
    Thanks in advance!
    Solved!
    Go to Solution.
    Attachments:
    NI_Chan units to array_1.png ‏35 KB
    NI_Chan units to array_2.png ‏50 KB

    nathand wrote:
    Your comments made me curious, so I put together a quick test. Maybe there's an error in the code (below as a snippet, and attached as a VI) or maybe it's been fixed in LabVIEW 2013, but I'm consistently getting faster times from the IPE (2-3 ms versus 5-6ms for unbundle/index). See if you get the same results. For fun I flipped the order of the test and got the same results (this is why the snippet and the VI execute the tests in opposite order).
    This seems like a poster child for using the IPES!  We can look at the index array + replace subset and recognize that it is in place, but the compiler is not so clever (yet!).  The bundle/unbundle is a well-known "magic pattern" so it should be roughly equivalent to the IPES, with a tiny penalty due to overhead.
    Replace only the array operation with an IPES and leave the bundle/unbundle alone and I wager the times will be roughly the same as using the nested IPES.  Maybe even a slight lean toward the magic pattern now if I recall correctly.
    If you instantly recognize all combinations which the compiler will optimize and not optimize, or you want to exhaustively benchmark all of your code then pick and choose between the two to avoid the slight overhead.  Otherwise I think the IPES looks better, at best works MUCH better, and at worst works ever-so-slightly worse.  And as a not-so-gentle reminder to all:  if you really care about performance at this level of detail: TURN OFF DEBUGGING!

  • Will I be able to create fillable pdf forms from existing word and excel documents?

    Will I be able to create fillable pdf forms from existing word and excel documents?

    Hi
    Yes you can. You may visit this link to check the workflow: https://www.youtube.com/watch?v=O0PPzFq3X00
    Regards,
    Ajlan Huda.

  • Create/split transport request from existing request

    Hi
    I want to know how to create/split  transport request from existing transport request in ECC 6.0
    Regards
    Kumar

    hai kumar,
    split the request means ?
    u can assign objects of one request to another  and merge two requests
    but u cant split one requet in to , u can assign task from one request to another
    u have lot fo options just search in menu and u get them
    regards
    m.a

  • Create a new schema from existing schema

    Hi, I'm wondering whether there is a way of create a schema from
    existing one? Could it done through SQL statement or have to go
    through some sort of tools? Please drop me a few words if you
    know the answer. Thanks.

    Hi,
    U can do that in a few steps.
    First create the User.
    Then Go to the Source User and grant him create any table privs.
    Then write a Sql Stmt to generate the necessary scripts and run it.
    The other way would be to grantr the newuser select on all the tables and then run that script from his account.
    Regards,
    Ganesh R

  • How to create new genius playlists from existing music in library?

    I tried the genius button for creating lists from existing music in my library. The problem is that it continues to show the first list created no matter what song I highlight then hit the genius button. Genius works fine for creating lists I can purchase online, but not new ones from my own music.

    This is the iTunes for Mac forum.
    As you are running Windows you will probably get a better response from posting in the iTunes for Windows forum:
    http://discussions.apple.com/category.jspa?categoryID=150

  • 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;
        }

  • [solved] creating video dvd iso from existing folders

    I used dvdbackup with the -M option to copy a complete video dvd to my harddisk.
    How can I create a video dvd iso image from the existing folders?
    I used k3b till now (new video dvd, only create iso file)..
    Last edited by SiD (2008-07-26 18:18:13)

    SiD wrote:
    ah, ok.
    p.s.
    do you mean the "ERR:  SCR moves backwards, remultiplex input." error?
    That one can be solved by encoding to vob as opposed to mpg. I do still get the time stamp warning, but I read that they can be ignored. The problem I'm having now is this one:
    http://bbs.archlinux.org/viewtopic.php?id=52251

  • Creating a web service from existing EJB.  HELP!!!

    I have an existing EJB deployed to WL which I want to call as a web service. I do not want to deploy everything in an EAR - I want to use the existing EJB.
    Basically I just created a new web module and put my web-services.xml (and web.xml) in WEB-INF and deployed it.
    The web-services.xml looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-services>
    <web-service useSOAP12="false" exposeWSDL="true" targetNamespace="http://www.fxf.com/test/services" name="ProtoService" style="rpc" uri="/ProtoService" ignoreAuthHeader="false">
    <components>
    <stateless-ejb name="ejbcomp0">
              <jndi-name path="ejb/ProtoService"/>
    </stateless-ejb>
    </components>
    <operations>
    <operation name="protoOneMethodOne" method="protoOneMethodOne" component="ejbcomp0">
    </operation>
    </operations>
    </web-service>
    </web-services>
    When I deploy my web project WL throws an exception. Here is part of the stack trace:
    <Feb 23, 2005 8:56:14 AM MST> <Error> <HTTP> <BEA-101216> <Servlet: "WebServiceServlet" failed to preload on startup in Web application: "efs".
    javax.servlet.ServletException: ERROR: The EJB component named: ejbcomp0 specified a JNDI name: ejb/TransitRequest, but this JNDI name does not refer to a stateless session EJB.
         at weblogic.webservice.server.servlet.WebServiceServlet.initLocal()V(WebServiceServlet.java:132)
         at weblogic.webservice.server.servlet.WebServiceServlet.init()V(WebServiceServlet.java:86)
         at javax.servlet.GenericServlet.init(Ljavax.servlet.ServletConfig;)V(GenericServlet.java:258)
         at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run()Ljava.lang.Object;(ServletStubImpl.java:1018)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(SecurityManager.java:118)
         at weblogic.servlet.internal.ServletStubImpl.createServlet()Ljavax.servlet.Servlet;(ServletStubImpl.java:894)
         at weblogic.servlet.internal.ServletStubImpl.createInstances()V(ServletStubImpl.java:873)
         at weblogic.servlet.internal.ServletStubImpl.prepareServlet(Lweblogic.servlet.internal.RequestCallback;)V(ServletStubImpl.java:812)
         at weblogic.servlet.internal.WebAppServletContext.preloadServlet(Ljava.lang.String;)V(WebAppServletContext.java:3281)
         at weblogic.servlet.internal.WebAppServletContext.preloadServlets()V(WebAppServletContext.java:3226)
         at weblogic.servlet.internal.WebAppServletContext.preloadResources()V(WebAppServletContext.java:3207)
         at weblogic.servlet.internal.WebAppServletContext.setStarted(Z)V(WebAppServletContext.java:5737)
         at weblogic.servlet.internal.WebAppModule.start()V(WebAppModule.java:874)
    I'm sure that my EJB is a stateless session bean. Looking at the deployed EJB in the console confirms it.
    I cannot figure out what WL is upset about.
    Does anyone have any advice or know of any resoures on using an existing EJB via a webservice in WL? I did not find any sort of guide, I just pieced this approach together. It seems like it should work, but I'm stuck on this problem.
    I really appreciate any help or advice.
    Thanks,
    Matt

    Using <autotype> and <source2wsdd> to generate what I need. Now WL seems happy.

  • How can I create a single array from three arrays? Please Help!

    I have three arrays:
    Dates[2002-10-29 2002-10-30 2002-10-31 ...]
    OCodes[AC AD AE ...]
    LCodes[A01 A02 A03 ...]
    I would like to combine the above three arrays and write out to an array
    The new array would look like:
    NewArray[ 2002-10-29 AC A01, 2002-10-29 AC A02, 2002-10-29 AC A03,
    2002-10-29 AD A01, 2002-10-29 AD A02, 2002-10-29 AD A03,
    2002-10-29 AE A01, 2002-10-29 AE A02, 2002-10-29 AE A03 ......,
    2002-10-31 AC A01, 2002-10-31 AC A02, 2002-10-31 AC A03....,
    2002-10-31 AE A01, 2002-10-31 AE A02, 2002-10-31 AE A03...]
    Thanks in advance!

    String [ ] newArray = new String [Dates.length];
    for (int counter = 0; counter < Dates.length; ++ counter)
    StringBuffer buf = new String Buffer();
    buf.append(Dates[counter] + " ");
    buf.append(OCodes[counter] + " ");
    buf.append(LCodes[counter]);
    newArray[counter] = buf.toString(0;
    }

  • Share new pdf created from existing online pdfs

    Is a solution in the works to be able to create new pdf books from existing individual pdfs online? Let's say I have individual pdfs for each of my recipes, but want to create a book online to share of just my desserts. Without sending each pdf share using an individual email, can this be done?
    Absolutely love the interface and where Adobe seems to be going with this.
    Thanks,
    James

    Hi,
    Thanks for your post. In order to combine multiple PDF's into one, you need the desktop version of Adobe Acrobat. We don't currently have plans in the works to add this feature to Acrobat.com, but I will share your feedback with the team. You could also visit our Ideas site and promote this idea - we actively use the Ideas site to prioritize the roll out of new features.
    Best,
    Michelle

  • How to create BP from existing vendors optionally?

    Hi,
    how can I create RE business partners from existing vendors for some optional vendors only?
    Does the vendor synchronization (Cross-Application Components - Master Data Synchronization - Customer/Vendor Integration) mean that a BP is created for each vendor in the specific account group?
    I've tried to define the configuration settings but haven't found the solution for this yet. Please advise.
    - BP grouping assigned to number range
    - one FI account group is assigned to BP grouping
    - BP role (BP role category, BP view) defined
    - in Vendor role link, is the assignment of Role category "optional"?
    Thanks!

    Hi,
    thanks for your comment.  I need to check this option too. 
    However, in this case this does not seem like the best option regarding the workload of users. If they have already xxx vendors in FICO, it does not seem like a very efficient way to create those first also as BP, and then link these records.
    It would be much easier to only create the BP based on vendor data with FLBPC1, and save the double work.
    Based on SAP documentation, I've understood that FLBPC1 Create BP from vendor is meant for this purpose, so I would like to use this option.
    Please advise. Has anyone used FLBPC1 Create BP from vendor successfully?
    Thanks!

  • Question-Creatin array from a large # of scalars

    Hello
    I am developing LV code, where a large number of calculations are being done
    in various ways as scalars. I would like to assemble these (say about 200
    such) into a 1D array. I want to avoid using Build Array with 200 element
    inputs. Also, these are not being generated within a For-Next loop to be
    able to use the auto-indexing function or shift-registers.
    Is there a relatively simpler way to create a 1D array from a large number
    of scalars?
    Reason I want to do this, is to make it easy to pass this array to other
    vi's via a connector output or store to like a spreadsheet or send to a
    printer.
    TIA
    Khan Kabir
    Xerox Corp.

    Hi Khan,
    you can use Vi-Server to automatically build an array of values contained in controls or indicators of your front panel.
    I attach a vi in LV6 that:
    - Creates an array of references of all the front panel controls and indicators
    - Extracts the values of a determined number of controls/indicators
    - Converts each value in a DBL format (of course it can be changed)
    - Builds an array of values extracted
    N.B. the order of the references array refers to the order of the controls/indicators on your panel. It's important that you set correctly the panel order to make this vi build an array of the wanted controls/indicators; to access panel order: Edit - Set Tabbing Order. If for instance you want to make an array of 5 controls but in your panel you have a boolean at
    order #3 you will get an error ( you can't convert a boolean to DBL...)
    Let me know if you need more help.
    good luck,
    Alberto
    Attachments:
    building_controls_array.vi ‏35 KB

  • Copy small array from cyclical queue

    Hi,
    I would like to know how to create a small array from a bigger one when the bigger one is cyclical. The problem is that i'm copying the values with Arrays.copyOfRange(array,from,to) until I end up to the final of the queue where it falls in a ArrayIndexOutOfBoundsException
    Example:
    cyclical_queue: [ 34 23 2 3 4 5]
    if small_array has to be [4 5 34] i cannot use copyOfRange since it would end up in Arrays.copyOfRange(cyclical_queue,4,1) -> ArrayIndexOutOfBoundsException
    P.S. I am trying to do it without loops since performance is important in my program
    Thanks in advance for any help,
    Rodo

    Rodo1983 wrote:
    I would like to know how to create a small array from a bigger one when the bigger one is cyclical. The problem is that i'm copying the values with Arrays.copyOfRange(array,from,to) until I end up to the final of the queue where it falls in a ArrayIndexOutOfBoundsExceptionYou can't use Arrays.copyOfRange for this if the array you're copying wraps around the end of the queue.
    P.S. I am trying to do it without loops since performance is important in my programDon't bother. Looping isn't inefficient, and besides, I'm almost positive Array.copyOfRange() uses loops. Just start copying at the beginning index, wrapping to zero if you get to the end, and stop when you get to the ending index.

  • How can I create a RAWpic-file with header(cluster of 8elements) and 2D Array?

    I have created a cluster with 8 "I32"elements (Header). I also got picture information into a 2D array (i converted information from a ROI into a 2Darray("Image pixels(I16)")
    Now I want to create a RAW picture file (first the header information followed by the picture information.)
    I think I have to convert the Header-cluster into an array with "cluster to array". But even this is not possible(Info:"you cannot combine 2 different clusters"). Then I have to combine the 2 arrays with "insert into array"??? But the header array would be a 1Darray if the "cluster to array conversation" works and the picture information is 2D.
    Can anyone help me please?

    I think this is actually pretty straightforward, barring any byte-order issues. Attached is an image that demonstrates what I think jotthape wants to do.
    The key is to let multiple Write File nodes do the work for you. There's no need to combine all the data into a single structure for the write, and avoiding that makes things easier in this case, because you don't have to worry about some of the data being I32 and the rest being I16.
    Give this a shot,
    John
    P.S. It does seem likely that you will run into byte-order problems if you want to read your custom RAW file in using some other piece of Windows software. You can check the forum and the NI site for info on byte order, then ask a new question if you're still having a problem.
    Attachments:
    writeRaw.png ‏8 KB

Maybe you are looking for