Concatinating strings in a loop

The string TYPE only contains the last value from the loop instead of all of them
Attachments:
Search Catalog.vi ‏88 KB

Hi exo,
i think you spoke about the for loop. Don´t set the tunnels from a case structure to "default if unwired".
See the attached vi, it should now work for you.
Mike
Attachments:
Search%20Catalog_LV80.vi ‏86 KB

Similar Messages

  • How can i read XML string in a loop???

    i changed xml file reader to xml string reader by
    looking around this and other forums.
    here is the code.
    public class XMLTester2 {
        public static void main(String[] args) {
            String s = "<firsttag><secondtag>123</secondtag></firsttag>";
            java.io.Reader reader = new java.io.StringReader(s);
            org.xml.sax.InputSource source = new org.xml.sax.InputSource(reader);
            org.w3c.dom.Document doc = null;
            javax.xml.parsers.DocumentBuilderFactory fact = javax.xml.parsers.DocumentBuilderFactory.newInstance();
            try {
                javax.xml.parsers.DocumentBuilder builder = fact.newDocumentBuilder();
                doc = builder.parse(source);
            } catch (javax.xml.parsers.ParserConfigurationException pce) {
            } catch (org.xml.sax.SAXException se) {
            } catch (java.io.IOException ioe) {
            } finally {
                try {
                    reader.close();
                } catch (java.io.IOException ignored) {
    }i put this stuff into a loop, but i always ends up
    having new in the loop.
                String inputLine = "Start";
                // define what's needed for XML messages
                Reader reader = new StringReader(inputLine);
                InputSource source = new InputSource(reader);
                Document doc = null;
                DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = null;
                Node xmlNode = null;
                try {
                    builder = fact.newDocumentBuilder();
                } catch (ParserConfigurationException pce) {
                // -->
                while ( (inputLine = in.readLine()) != null) {
                    System.out.println("readLine() : {" + inputLine + "}");
                    reader = new StringReader(inputLine);
                    source.setCharacterStream(reader);
                    try {
                        doc = builder.parse(source);
                    } catch (SAXException se) {
                        System.out.println("SAXException : " + se);
                        System.out.println("SAXException source : " + source.toString() );
                        se.printStackTrace();
                    } catch (IOException ioe) {
                        System.out.println("IOException : " + ioe);
                    } finally {
                        try {
                            reader.close();
                        } catch (IOException ignored) {
                    reader = null;i know putting new in the loop is VERY bad.
    i gotto get ride of this new from the loop.
    can anyone help me?

    i know putting new in the loop is VERY bad.
    i gotto get ride of this new from the loop.Don't design your application based on one-liners you heard somewhere. Do some timings to see if it matters. My guess would be that parsing an XML file would take a fair bit longer than creating a StringReader object. And you do need a new StringReader each time, they aren't reusable, so the alternatives are not obvious. And don't accept my guess about the timings, check it for yourself.

  • How do I update multiple characters at specified positions in a string while avoiding looping?

    DECLARE @mytestvar NVARCHAR(MAX) = '2,3,4,5,6'
    UPDATE tblMessageState
    SET UserFilingCategoryStatus = STUFF(UserFilingCategoryStatus,CONVERT(INT,a.Value),1,'0')
    FROM dbo.udtfSplit(@mytestvar, ',') a
    WHERE MessageID = 1
    This is the farthest I have gotten. This only updated the character in position 2 ...I also want it to update the character in position 3 and 4 etc... or whatever positions I input. Is there some CROSS APPLY trickery I could use ? I really want to avoid looping.
    Paul Mauriello

    ALTER FUNCTION dbo.fnparseAndreplaceString
    @vSplitStr varchar(1000),
    @vChangePosStr varchar(100)
    RETURNS varchar(100)
    AS
    BEGIN
    Declare @vMyString varchar(100) = @vSplitStr
    Declare @vChangeStr varchar(100) = @vChangePosStr
    Declare @vResult varchar(100) = ''
    Declare @vTable Table (ID int, val nvarchar(100))
    ;With wcte as (
    Select Row_Number()over(Order by name) ID from sys.columns
    ) --Insert into @vTable
    Select @vResult = (Select '' + Case when b.value is Not Null then '1' else Right(SubString(@vMyString,1,ID),1) end
    from wcte a
    Left Outer Join dbo.fnSplit(@vChangePosStr,',') b on b.value = a.ID
    where ID <= Len(@vMyString)
    For XML Path(''))
    --),1,1,'')
    RETURN @vResult
    END
    GO
    Create the function as above and then you can use it in your UPDATE query;
    Declare @vMyString varchar(100) = '4567899243'
    Declare @vChangeStr varchar(100) = '2,4,8' -- I will replace these positions with 1.
    Declare @vTableTest Table (ID int, val varchar(10))
    Insert into @vTableTest
    Select 1, '123456789' Union All
    Select 2, '456783457'
    Select *, dbo.fnparseAndreplaceString (val,@vChangeStr) from @vTableTest
    Update @vTableTest
    Set val = dbo.fnparseAndreplaceString (val,@vChangeStr)
    Select * from @vTableTest
    Technically you will need two functions in your code. One is above and the other one is dbo.fnSplit. I hope you have the split function that splits the string on the basis of a given character.
    Please visit my Blog for some easy and often used t-sql scripts
    My BizCard

  • Adding Characters to a string in a loop

    Hi
    I have a task where if the text perameter is more than 10 characters in cuts it down to 10, which i can do. If it is 10 it just gives it back, which i can do. But if it is less than 10 you need to add extra spaces onto the end of it. I cant seem to think how to do it. What i have at the moment seems to put it in an infinite loop. Any tips or hints would be much apreciated.
    public class Main
         public static String trimTo10(String s)
    int i, len = s.length();
    String results = "";
    if (len >10)
    for (i =0; i <= 9; i++) {
    char w=s.charAt(i);
    results = results + w ;
    if (len ==10){
    results = s ;
    if (len <10)
    for (i =0; len<=9; i++) {
    results =  s + " ";
    return results;     }
    }

    Hi
    You need to decide on exactly what you want to do. Write an algorithm of the process. (it doesn't have to be formal)
    Something like:
    <length is less than 10>
    get length of string
    number of spaces = 10 - length of string
    That should be enough to get you started...
    regards,
    lutha

  • 1D Array Of String To For-Loop

    Hi fellow engineers,
    I'm new to LabVIEW.
    I got a question,
    If I got a 1D array of string and I want to loop my program to the same number of times (Iteration) in conjunction with the numbers of sub-folders generated by the "list folder" function. How can I do it?
    Any help is greatly appreciated.
    Solved!
    Go to Solution.
    Attachments:
    Capture.PNG ‏7 KB

    Wire the string array to the border of the for loop. LabVIEW will automatically iterate through each element of the array; you should not wire anything to the N terminal of the for loop. This is the default behavior for arrays entering a loop; if you do not want auto-indexing, right-click on the tunnel (where the array enters the loop) to change the behavior.

  • Cannot wire string to Timed Loop Name terminal in LV8 (base)

    I just installed LabVIEW 8, and I've discovered that the VI breaks if you wire a string to the name input on a timed loop.  Also the error cluster input doesn't seem to like an error cluster connected to it.  I'm using the base development system if that's significant, but I was able to do it in 7.1.  Please let me know if I'm doing something wrong.

    Just hit ctrl-B and the error clears up.
    I suspect that there was another hidden wire between two of the other input terminals of the loop. You don't need to invoke any conspiracy theories (Other version also installed, base only, etc.)
    It also fixes itself if you select to use the built-in timing source.
    Message Edited by altenbach on 11-10-2005 01:28 PM
    LabVIEW Champion . Do more with less code and in less time .

  • Concatinating Strings into Variable Names

    Hi
    I'm not sure if this is even possible but here goes.
    Is there anyway of concatinating (sp? Join together!) two strings and then use the new string as a variable name.
    The reason I ask is that, depending upon what character I read into my program I will want to modify an array of data associated with that character.
    For example if the character read in was @ I would want to modify the array data@. So my question is, is it possible to read in a character such as @, join it with the string "data" and then use the resulting string as a variable name?
    Apologies if this has a simple solution but I'm struggling to come up with it by myself.
    Many thanks.

    Hey
    Thanks for the advice. The problem is that I'm storing the arrays in a hash map already. This is because each character has more than one piece of data associated with it , and as far as I can tell each key entry in a hash table has one and only one piece of data associated with it. But if there is a way of storing multiple pieces of information with a particular key, then that could be a possible solution....
    Any suggestions?

  • For loops and dynamic sql string syntax

    Hi
    is there a why to loop through a dynamic sql string
    normally you would have
    FOR cur IN (select * from emp) LOOP
    but I have a dynamic sql string called l_sql
    I have tried the following
    FOR cur IN l_sql LOOP
    but I get
    PLS-00456: item 'L_SQL' is not a cursorCompilation failed
    Any ideas?

    You will need to use ref cursors and the OPEN v_rc FOR '<your sql string'> and then loop through it as you would with any other OPEN, LOOP, EXIT WHEN, END LOOP syntax

  • Output strings from loop into one string

    im trying my best to explain my problem so ber in mind:)
    hey having a bit of trouble with outputing strings from loop
    example
    i typed ab into the textbox
    the output should be 12
    but since it is in a loop it would only output the last string and in this case is 2
    im trying to get both strings from the loop and output strings from loop into one string.
    here is some of my code to understand my problem
    // characters a to f
         char[] charword = {'a','b','c','d','e','f'};
         String charchange ;
      // get text from password textbox
                          stringpassword = passwordTextbox.getText();
                          try {
                          // loop to show password length
                          for ( int i = 0; i < stringpassword.length(); i++ ){
                          // loop to go through alfabet     
                          for (int it = 0; it < charword.length; it++){
                             // if char equals stringwords
                               if (stringpassword.charAt(i) == charword[it]){
                                    System.out.print("it worked");
                                    // change characters start with a
                                    if (charword[it] == 'a'){
                                         charchange = "1";
                                    // change to 2
                                    if (charword[it] == 'b'){
                                         charchange = "2";
                                        }

    Not sure how you are displaying the result but you could display each value as soon as you find it.
    if (charword[it] == 'a'){
        System.out.print("1");
    }If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
    if (charword[it] == 'a'){
        charchange += "1";
    }

  • Loops messed up. Help needed quickly

    Hi there,
    I'm in the middle of kind of an important project that has to be finished by next week and of course those are the times when software seems to fail So I need help quickly.
    Situation: the location of my apple loops seems to be messed up. I placed the "Apple Loops for Soundtrack Pro" on an external disk (since it is the largest folder) and kept the rest on my internal drive. Now, when I search my loop browser, results seem to be incomplete. I know I had a lot more drum loops before I reorganized my loops than I have now.
    So I became suspicious and as some kind of test I looked in the Library > Audio > Apple Loops > Jam Pack Symphony Orchestra folder, searched for a particular loop name (in this case "Adversary Strings"), typed it in the search menu of the loop browser in Logic and couldn't find it.
    So I took al my loop folders in the "Apple Loops" map and dragged them back into Logic. It showed "Adding Loops" and after 10 seconds (which seemed rather short to me) this was done. I searched again "Adversary Strings" in the loop browers, still couldn't find it. So I dragged ONLY the "Adversary Strings" loop in the Logic Pro loop browser and then Logic gave me a message: "Logic already has this loop, do you want to replace it?"
    But Logic doesn't have that loop! I can't find it, there's no filter on in my loop browser (I search "all loops") and I don't find some loops (it's not only the case with the "Adversary Strings") and when I want to add them I get the message that they're already in Logic...
    So I deleted all my loop indexes, re-added the loops and still no results.
    Any ideas out there to re-index these things correctly???
    Thanks!

    Hi,
    thanks for the help, but as I said in my topic, I already followed the steps suggested in "Rebuilding the Loop index" (deleting my index and dragging the apple loops folder back in the browser) and of course I already searched the forum. My question was a little more specific, so I thought it deserved a new thread.
    Eventually I solved it in a very strange manner, just by trial and error actually. When I added the whole loop folder, Logic couldn't find the loops (despite deleting the index and hoping for Logic to re-index the loops). But when I selected one loop out of a particular folder (for instance Jam Pack1) and added it, Logic added the loop, but this seemed to take a while. After that one loop was loaded, suddenly all the others that were in the same folder (Jam Pack1) were also visible again.
    I did this for every different loop folder (5 jam packs, garage band, soundtrack pro and I life) and so got back all my loops...
    Weird, but it worked
    Thanks anyhow...
    S.

  • Buffer too small for string - Crystal Report for Vs2010

    Hello,
        I have recently upgrade my VS2010 project to Crystal Report for Visual Studion 2010.
        I have some reports that contains more than 512 characters in the Report Comments section.
        When I try to do a RptDoc.SaveAs(vPath, false) the following error is raised:
    Buffer too small for string or missing null byte.
          at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.SaveAs in :line 0
          at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.SaveAs in :line 0
          at CrystalDecisions.CrystalReports.Engine.ReportDocument.SaveAs in :line 0
        This line SaveAs was working has expected with Crystal Report 2008. Any idea on why it is not working anymore.
    Thank you.
    Charles

    Hello Don,
        I have start a little project to retest the behavior.
       I have create a new report in Crystal Report 2008 just by clicking New, Finish and Save.
       In a new Windows Application in Vs2010 ,I have added the following Crystal Report Reference.
        CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0
       CrystalDecisions.Shared, Version=13.0.2000.0
    I have then try the following code and found out the limit of ReportComment is 511 but in the Crystal Report 2008 designer and runtime the limit did not apply.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim objRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
          Dim i As Integer = 0
          Try
             objRpt.Load("c:\temp\empty.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
             Do
                i += 1
                objRpt.SummaryInfo.ReportComments = New String("X", i)
             Loop
             objRpt.SaveAs("c:\temp\dfh_save.rpt", False)
          Catch ex As Exception
             MsgBox("i: " & i)
             MsgBox(ex.Message)
          End Try
    End Sub
         I am able to put has many characters if I insert the report in the Vs2010 Solution.
         If you prefer I can send you my little project.
    Thank you.
    Charles
    <code> should be
    Edited by: Don Williams on Feb 4, 2011 12:47 PM

  • Splitting and type casting huge string into arrays

    Hello,
    I'm developing an application which is supposed to read measurement files. Files contain I16 and SGL data which is type casted into string. I16 data is data from analog input and SGL is from CAN-bus data in channel form. CAN and analog data is recorded using same scan rate.
    For example, if we have 6 analog channels and 2 CAN channels string will be (A represents analog and C represents CAN):
    A1 A2 A3 A4 A5 A6 C1 C2 A1 A2 A3 A4 A5 A6 C1 C2 A1 A2 .... and so on
    Anyway, I have problems reading this data fast enough into arrays. Most obvious solution to me was to use shift registers and split string in for loop. I created a for loop with two inner for loops. Number of scans to read from string is wired to N terminal of the outermost loop. Shift register is initialized with string read from file.
    First of the inner loops reads analog input data. Number of analog channels is wired to its N terminal. It's using split string to read 2 bytes at a time and then type casts data to I16. Rest of the string is wired to shift register. When every I16 channel from scan is read, rest of the string is passed to shift register of the second for loop.
    Second loop is for reading CAN channels. It's similar to first loop except data is read 4 bytes at a time and type casted to SGL. When every CAN channel from scan is read, rest of the string is passed to shift register of the outermost loop. Outputs of type cast functions are tunneled out of loops to produce 2D arrays.
    This way reading about 500 KB of data can take for example tens of seconds depending on PC and number of channels. That's way too long as we want to read several megabytes at a time.
    I created also an example with one inner loop and all data is type casted to I16. That is extremely fast when compared to two inner loops!
    Then I also made a test with two inner loops where I replaced shift register and split string with string subset. That's also faster than two inner loops + shift register, but still not fast enough. Any improvement ideas are highly appreciated. Shift register example attached (LV 7.1)
    Thanks in advance,
    Jakke Palonen
    Attachments:
    String to I16 and SGL arrays.vi ‏39 KB

    OK, there is clearly room for improvement. I did some timing and my two above suggestions are already about 100x faster than yours. A few teeaks led to a version that is now over 500x faster than the original code.
    A few timings on my rather slow computer (1GHz PIII Laptop) are shown on the front panel. For example with 10000 scans (~160kB data as 6+2) my new fastest version (Reshape II) takes 14 ms versus the original 7200ms! It can do 100000 scans (1.6MB data) in under 200 ms and 1000000 scans (15MB data) in under 2 seconds.
    I am sure the code could be further improved. I recommend the Reshape II algoritm. It is fastest and can deal with variable channel counts. Modify as needed.
    Attached is a LabVIEW 7.1 version of the benchmarking code, containing all algorithms. I have verified that all algorithms produce the same result (with the limitation that the cluster version only works for 6*I16+2*SGL data, of course). Remember that the reshape function is extremely efficient, because it does not move the data in memory. I have some ideas for further improvements, but this should get you going.
    Message Edited by altenbach on 08-05-2005 03:06 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    StringI16SGLCastingTimer.png ‏48 KB
    StringtoI16andSGLArraysMODTimer.vi ‏120 KB

  • 2D array output in a loop

    Hello,
    I need output data (several array string) from FOR-loop to 2D array. I use Replace array subset inside the loop (after array initialize). Output works (I see each step right string in its right place), But each next loop clear all previous strings to 0 0 0 . Finally stay only the last string in result array (see fig). Output to file works perfectly.
    Similarly, no result outside of loop. 
    WHY?
    I'm beginner...
    Solved!
    Go to Solution.

    Hi zazra,
    But outside Out_array 2 and Out_array are empty (grey zero fields). 
    THINK DATAFLOW!
    Those two array indicators stay empty UNTIL the FOR loop finishes!
    How to use out_array 4 - data outside the loop?
    Either finish the FOR loop - or use a local variable (as easiest, but not the only solution)…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How do you make Robot type out a variable String?

    I don't know why I'm having an issue with this. I want the Robot class to type out a string one character at a time as if I were sitting at the keyboard and doing it myself. There will be many, variable strings to type. Here is what I tried to do and it fails miserably:
    private String myString = "example";
    // Loop for each character in the string
    for(int i=0; i<numChars; i++)
         // Get the current character
         myChar = myString.charAt(i);
         // Convert the character to a keycode
         myKC = (int)myChar;
         // Press the key, release the key
         myRobot.keyPress(myKC);
         myRobot.delay(10);
         myRobot.keyRelease(myKC);
    }When I run it, I get some unexpected output in the Notepad window I have open. Instead of it spelling out "example", it gives me something entirely different:
    e - instead of 'e', it gives me a '5'
    x - instead of 'x', it gives me nothing at all
    a - instead of 'a', it gives me a '1'
    m - instead of 'm', it gives me a '-'
    p - instead of 'p', 'F1' is triggered and the Notepad help window pops open
    l - instead of 'l', it gives me nothing at all
    e - instead of 'e', it gives me another '5'
    What am I doing wrong here? This was supposed to be easy...
    Edited by: ConQuesimo on Jan 19, 2010 12:06 AM

    ConQuesimo wrote:
         // Convert the character to a keycode
         myKC = (int)myChar;
    I don't see a keycode conversion here, keycodes for a to z are the same as ASCII, what I do see is an int conversion of what ever character set you have running on your computer. If I take your approach to conversion, then I get different codes on different keyboards/systems also. What I finally ended up doing is making a map for my keys and everything started working fine.
    For me, the problem expressed itself when I went from my Windows with MS-Keyboad to my Ubuntu with an earlier style MS-Keyboad. Character values and single character strings come out fine, but when I would try converting char to KeyCode as you have done, the results were not always what was desired. I've not looked into it to see what was actually causing the problem, ti was faster and easier just to make the map.

  • Which is better storing string values in Map or String buffer

    Hi,
    I have a store a 10 string values in a cookie. Do i use a String buffer and append all values or put it in a hash map.
    If i put in a string buffer i have to use a string tokenizer to loop and extract the values., but if i am using a map then
    retrieval will be easier, but in terms of memory management, which is better. as i have to create this cookie for every unique IP hitting my site.
    Thanks,
    Viiveek

    viiveek wrote:
    I have a store a 10 string values in a cookie. Do i use a String buffer and append all values or put it in a hash map.
    If i put in a string buffer i have to use a string tokenizer to loop and extract the values., but if i am using a map then
    retrieval will be easier, but in terms of memory management, which is better. as i have to create this cookie for every unique IP hitting my site. In terms of memory management, StringBuffer could potentially be better as there is no need to keep key objects in memory.
    That doesn't make it a good idea. The bytes of memory you'd lose by using a Map would be made up by the fact that Map was expressly made for storing key/value pairs. Memory management should be about the 200th factor you should consider.

Maybe you are looking for

  • 5th Gen iPod, seen by Windoze, not by iTunes

    I've been too busy lately to hang out keep up with the iTunes 7 issues, but I still have to stop the iPod service, attach my iPod, start iTunes/start the service every time I want to sync. Is there any hope that this is a temporary condition or is th

  • Error Reading from a File

    Right now i am coding a game and i need to read from a text file to load the map. The only problem is that i cant do this in internet exploerer because i get an error saying that access is denied. I've been researchign the problem nonstop and the onl

  • Trying to set the contents of a Text View in Objective-C

    Hi there, I have a properly linked up Text View (within a Scroll View) in Interface Builder, and I wish to change the value of that Text View at runtime. I am trying this code here, but it (and other similarities of it) is not working; [textField set

  • Skype for Sony Playstation 3 ( PS3 ) and for Sony ...

    There is a huge amount of Sony Playstation users who would like to have Skype available for their consoles. The client is already available for PSP and PS Vita. There are ton of thread with this request, but none of them has received a clear answer a

  • Transfer Purchased onto iTunes not working

    Today, I borrowed my friends iPod to download the purchased songs onto my iTunes. When it said it was finished, it only transferred 34 out of 300 and some odd number purchased. Could you help me please? I authorized the account and clicked on transfe