Convert an array of strings into a single string
Hi
I am having trouble trying to figure out how to convert an array of strings into a single string.
I am taking serial data via serial read in a loop to improve data transfer. This means I am taking the data in chunks and these chunks are being dumped into an array. However I want to combine all elements in the array into a single string (should be easy but I can't seem to make it work).
In addition to this I would also like to then split the string by the comma separator so if any advice could be given on this it would be much appreciated.
Many Thanks
Ashley.
Well, you don't even need to create the intermediary string array, right? This does exactly the same as CCs attachment:
Back to your serial code:
Why don't you built the array at the loop boundary? Same result.
You could even built the string directly as shown here.
Message Edited by altenbach on 12-20-2005 09:39 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
autoindexing.png 5 KB
concatenate.png 5 KB
StringToU32Array.png 3 KB
Similar Messages
-
Multiple strings input to single string output
Dear all,
this program is needed for my demo simulation purposes, I'm creating several string inputs to show into a single string output updating (input strings are shown in each line). i attached the picture below, put 2 output strings w/c both doesn't meet my desired result:
1.) 1st string output - replace the old string w/ new string. what i need is to maintain also the previous strings. the new string will go to the next line.
2.) 2nd string output - although i got all the strings i needed, it only appears right after the while loop terminates, so i did not see the string inputs updating.
i'm using LV 8.5.1., any help is appreciated... posting your correct code will be more appreciated.
thanks in advance...
Ivel R. | CLAD
Solved!
Go to Solution.here's my code for anyone to see the actual difference.
thanks,
Ivel R. | CLAD
Attachments:
update strings.vi 14 KB -
How can I convert an array off byte into an Object ?
Hi folks...
I�m developing an application that comunicates a PDA and a computer via Wi-Fi. I�m using a DataStream ( Input and Output ) to receive / send information from / to the computer. Most off the data received from him is in the byte[] type...
How can I convert an array off byte ( byte[] ) into an Object using MIDP 2.0 / CLDC 1.1 ?
I found on the web 2 functions that made this... but it uses a ObjectOutputStream and ObjectInputStream classes that is not provided by the J2ME plataform...
How can I do this ?
Waiting answers
Rodrigo KerkhoffThere are no ObjectOutputStream and ObjectInputStream classes in CLDC. You must know what you are writing to and reading from the DataStream. You should write the primitives like int, String to the DataOutputstream at one end and read those in exactly the same sequence at the outher end using readInt(), readUTF() methods.
-
How to store array of data into a single row of table ,using any of Stmts
HI Friends,
Based on my requirements ,i have retrived a set of data from a XXX.jsp page using a request.getParameter() and stored into single dimenssional array . Now i am paassing that array to JAVA class to store a into some table .
In JSP page users can add text boxes dynamically based on his intrest then those attributes will store in table .it means table attributes are not conatant , it table attributes may change at any time when user adds any textboxs or any fields on JSP page ....thats my module ..
Now i wanted to store all array of data into Table in a single row .......thats is my requirements .
How can we use prepareStatement and Statement to store array of results intoo table row ...on each iteration i wanted to store array of results into table atributes ..It means entire array of results should to into table row at time .....coule any one write sytax ,how we do this...
could any one suggest me stps that i can impliment ......?....please reply ASAPWell ..you code can be works for constant number of attributes in table .oopss here my requirement is table attributes not fixed ,we cant put constant number of place holder(? ) in a statement ,because those are not fixed ,
Let me explain here :
i am doing in that way only. As i mentioned you Table attributes are not constant .It may very if users add any fields dynamically on JSP page .If users have option to add any text box on Jsp page ,then that attribute will store in table as a attribute .
Now i amable fetching the all dyamic form data and stored in a Result Array below ...in this iteration all form result data are from jsp page as suggestion form ,it should stored in table in single row on corrsponding attribtes ......next time when users fills FROM ,then those data i am fetching and storing in a Result Array as below and need to store in corrsponding table attributes in a single row ....
for(int i=0;i<result.length;i++)
System.out.println(result);
pst3=connection.prepareStatement("insert into *emprecord* values(?)");
if(!result[i].equals(""))
System.out.println(result[i]);
pst3.setString(1,result[i]);
pst3.executeUpdate();
Thnks in advance ....let me know the the way we can store dynamic form data into dyanamic table ... -
How to convert an array of numbers into a time signal?
I have an array of 512 data points. I want to convert this array into a time domain signal (the one with the brown color). How would I do this? Please let me know soon...Thanks!
If you are referring to waveform data type, use the "build waveform" function as illustrated in the attached vi. Also check LabVIEW help waveform example for more sample vi.
Attachments:
sample_vi.vi 30 KB -
Concatenating rows of a table into a single string
Hi,
My report gets an internal table LINES from READ_TEXT function module. This internal table LINES has 6 rows. My requirement is to concatenate all the 6 rows into a single field of string.
This is wht i have done.
data str type string.
loop at lines.
concatenate str lines into str separated by space.
clear lines.
endloop.
this code concatenates first three rows of the internal table LINES into STR, however the next rows are not concatenated into STR.
I have tried using
data : str(4096) type c.
but still it doesnt work.
Please advise.
Many Thanks,
Pritish.dont worry, the values will never get truncated.
have a look at this code.
REPORT ZSTRINGSTRANGE line-size 1023 .
data : lines type TLINE occurs 0 with header line.
lines-tdformat = '*'.
lines-tdline = 'This is line 1, This is line 2, This is line 3'.
append lines.
lines-tdformat = '*'.
lines-tdline = 'This is line 1, This is line 2, This is line 3'.
append lines.
lines-tdformat = '*'.
lines-tdline = 'This is line 1, This is line 2, This is line 3'.
append lines.
lines-tdformat = '*'.
lines-tdline = 'This is line 1, This is line 2, This is line 3'.
append lines.
lines-tdformat = '*'.
lines-tdline = 'This is line 1, This is line 2, This is line 3'.
append lines.
lines-tdformat = '*'.
lines-tdline = 'This is line 1, This is line 2, This is line 3'.
append lines.
data str type string.
loop at lines.
concatenate str lines into str separated by space.
clear lines.
endloop.
write: / str. -
Concatenate fields on multiple child rows into one single string
Hi -
I'm pretty much new to BI Publisher, and I looked through the forums for what I was trying to do below, but couldn't find much on this.
Here's my data source:
<BUSINESSES>
<BUSINESS>
<NAME>Microsoft</NAME>
</BUSINESS>
<BUSINESS>
<NAME>Apple</NAME>
</BUSINESS>
<BUSINESS>
<NAME>Google</NAME>
</BUSINESS>
<BUSINESS>
<NAME>Yahoo</NAME>
</BUSINESS>
</BUSINESSES>
What I was trying to do is create a single string from the XML data source in the form
Microsoft,Apple,Google,Yahoo,............
Here was my plan to do this:
1. Create a global variable - <?variable:AllNames;''?>
2. Loop - For each BUSINESS
2a. Capture NAME - <?variable@incontext:BusName;'NAME'?>
2b. Concatenate it to the global variable AllNames - <?variable:AllNames;concat($AllNames,',',$BusName)?>
3. End Loop
4. Display global variable - <?$AllNames?>
I get a blank RTF when I run this.
Can someone please advice me on this? I thought it would be pretty simple to do, but here i am at the end of the day, and ...
Thank you.There are multiple ways to do it..
one option of using variable, which i would not certainly do is this :)
<?xdoxslt:set_variable($_XDOCTX,'TESTTEST’,’’)?>
<?for-each:/BUSINESSES/BUSINESS?>
<?position()?>: <?NAME?> <?xdoxslt:set_variable($_XDOCTX,'TESTTEST’, concat(xdoxslt:get_variable($_XDOCTX,'TESTTEST’),’,’ ,NAME) )?>
<?end for-each?>
<?xdoxslt:get_variable($_XDOCTX,'TESTTEST’)?> -
Reducing 6 character string into 2 character string
--- So here's part 2 of my problem / This is the follow-up to my previous question ---
--- part 1 of this question is "merging characters into one cell, keeping the order" ---
How can I reduce a 6 character string into the right 2 character string ?
guidelines :
- the 6 character string is made up of up to 3 different characters, being A B C
- all 6 character strings list As first, Bs second and Cs third
- if the 6 character string contains 4 or more of the same characters, it should be reduced into a 2 character string of 2 times that same character
e.g. AAAABC --> AA
- if the 6 character string is AABBCC, then it should be reduced to the 'exception-string' NO
e.g. AABBCC --> NO
- if the 6 character string contains exactly 3 of the same characters, it should be reduced into a 2 character string of the 2 characters that occur most
e.g. ABBBCC --> BC
How do I fit this into just one formula ?
Thanks !"I was actually thinking about something like :
if ?????? = AABBCC, then NO,
else : if ?????? contains A, B and C,..."
I thought about that awhile and investigated a few dead ends before thinking 'Wait a minute...there are only 28 possible 6 character strings.'
With that low number, the simplest solution is to list them in one column, list the two character result beside each one, then use that as a Lookup Table:
Same table as before.
Column L uses my version of Yvan's formula to produce the string from the entries in columns A,B and C
Column Q uses the string in L as the search key for VLOOKUP to find and return the two character string shown.
Q2: =VLOOKUP(L,Table 2 :: A:B,2,FALSE)
"FALSE" sets the formula to look for an exact-match. Probably unnecessary here, as all possible matches are in Table 2. Here is the top part of that table:
For convenience, here's the full data list for Table 2. Copy and Paste into a new table for your own use.
6 char
2 char
AAAAAA
AA
AAAAAB
AA
AAAAAC
AA
AAAABB
AA
AAAABC
AA
AAAACC
AA
AAABBB
AB
AAABBC
AB
AAABCC
AC
AAACCC
AC
AABBBB
BB
AABBBC
AB
AABBCC
NO
AABCCC
AC
AACCCC
CC
ABBBBB
BB
ABBBBC
BB
ABBBCC
BC
ABBCCC
BC
ABCCCC
CC
ACCCCC
CC
BBBBBB
BB
BBBBBC
BB
BBBBCC
BB
BBBCCC
BC
BBCCCC
CC
BCCCCC
CC
CCCCCC
CC
Regards,
Barry -
How to convert an array of Integers into String
So how can an array of integers be converted into a string?
As I do not have a javac with me now, I hope you guys could help.
Can it be done this way:
int [] value = new int[] {2,3,4,5,6,7}
String strValue = "";
for (i=0; i<value.length-1; i++)
strValue += value;Instead of working with Strings, I would suggest you use a StringBuffer. It will improve memory utilization.
Like this:
int [] values = new int[] {2,3,4,5,6,7};
StringBuffer sbTmp = new StringBuffer();
final int size = values.length;
for (i = 0; i < size; i++) {
String intStr = Integer.toString(values);
sbTmp.append(intStr);
String strValues = sbTmp.toString(); -
Would like some help converting an array of strings into multiple parsed string arrays
Hello everyone.
this is a very novice question and I sincerely apologize for that, but i need some direction!
i have an array of strings:
(('J01',), ('0', '0', '0', '1'))
(('J02',), ('0', '1', '0', '1'))
(('J03',), ('0', '0', '0', '0'))
ect...
i would like to know what are some of the best ways to gain access to this information (aka, parse it). The field lengths are not static and all those ones and zeros could very possibly be two digits at times (0 = off state, 1-100 = on state), so simply pulling characters out of a given position of the string will not always work.
what i would like to achieve is to make either separate arrays for each desirable element, eg:
array one:
J01
J02
J03
array two:
0
0
0
array three:
0
1
0
and so on.
or maybe even a matrix (if that’s feasible).
other than that I am totally up for suggestions!!
thank you very much,
Grant.Assuming fixed structure (not necessarily length of the different numbers or names).
-
How to convert an array of bits into an array of bytes?
If I have an array of 1s and 0s, how can I pack them
into an array of bytes (8 bits)?
Thanks.NI recommends to get rid of 4.x mode (Quote from the help file: "National Instruments recommends reworking any application that uses the Convert 4.x Data mode as a long term solution."). For this reason, I have attached an alternative example to give you some ideas.
(The previous example (using 4.x type cast) is actually slightly flawed, because for some reason it only produces even sized output arrays (why???) so you would need to trim the resulting array as a function of the input array size.)
LabVIEW Champion . Do more with less code and in less time .
Attachments:
OnesAndZeroesU8v2.vi 43 KB -
Converting an array of chars to a single integer.
Hello, I have a little question that I would really appreciate if anyone could answer.
I have a year "1978" spread out in an array of chars like this:
c�r[3] // contains '8'
c�r[2] // contains '7'
c�r[1] // contains '9'
c�r[0] // contains '1'
and I would like to transform in into an integer, int �r = 1978 ,again. How can I do that?I'm not sure if that would actually work but I would just put it into a loop, I am using a long value for the total just in case it isn't only 4 digits but more than 9.
static char c[] ={'0','1','2','3','4','5','6','7','8','9'};
static long totalC = 0;
public static void main(String [] args)throws IOException{
for(int i=0;i<c.length;i++){
totalC += Integer.parseInt(String.valueOf(c[c.length-(i+1)]))* Math.pow(10,c.length-(i+1));
System.out.println(totalC);
System.out.println(totalC);
} -
How to process multiple rows of data into a single string
Hello,
I am trying to process multiple rows of text from an Oracle database into one field to display on a report as continuous text. Below is sample data. The text field is 55 characters wide so anything longer is broken into multiple rows. I need to recombine it for display.
line text
1 IN THE N.E. QUADRANT OF THE INTERSECTION OF THE FAIRFAX
2 COUNTY PARKWAY AND THE DULLES AIRPORT ACCESS AND THE T
3 OLL ROAD AND SOUTH OF SUNSET HILLS ROAD
I tried creating a formula field but it did not work, below is the code in Visual Basic syntax. I also tried using the Maximum() and UBound() functions without luck. I don't quite understand how to make the UBound() work; it threw a lot of errors.
Dim i As Number
Dim strLocDesc As String
For i = 1 To count({LDS_AR_RL_COMM.ART_LINE_NUM})
strLocDesc = strLocDesc & {LDS_AR_RL_COMM.ART_COMM_RMK}(i)
Next i
formula = strLocDesc
Any ideas on how to solve this?Hello Allison,
You can try this:
Create a formula called @StoreText, place it in the details and have the following code in it:
WhilePrintingRecords;
Global StringVar Text1;
Global StringVar TextRest;
if {field.line} = 1 then
Text1:= {field.text} else
if {field.line} >= 2 then
TextRest := TextRest+" "+{field.text};
In the Group Footer you can have a formula called @GetStoreText with the following code in it:
WhilePrintingRecords;
Global StringVar Text1;
Global StringVar TextRest;
Text1+varTextRest;
See how that works out for you.
Regards,
Zack -
Concatinating a field from several records into a single string
Using Crystal Reports 11
I have a table of EMS/Fire runs, with a related table of fire trucks that respond on each run. My report is grouped by EMS/Fire run, and then the details section shows each truck, something like this....
Run #1 | 123 E Main St | Structure Fire
E123
E124
E125
L123
L342
R153
Run #2 | 455 S High St | Fire Alarm
E322
E233
L122
What I would like to do is hide the details section, and instead in the footer section of each group, have a "text field" that combines all of the trucks into 1 line, something like this...
Run #1 | 123... | Stru... | E123, E124, E125, L123...
Run #2 | 455... | Fir... | E322, E233, L122
Basically the logic would be:
For Each RecordInThisGroup
If Maximum(TruckNumberField) = TruckNumber Field Then
TruckNumberField
Else
TruckNumberField & ", "
Next RecordInThisGroup
Is there a way to loop through all the records in the group?
Thanks for any insight!
JasonHi Jason,
This can't be done in the Detail section but we can do it in the Group Footer. Seeing as you already are grouping on the EMS/Filre run this is good. We can use a running total to do this.
1) Create a formula and drop it into the Group Header. This will reinitialize the running total for each group:
WhilePrintingRecords;
StringVar Run := "";
You can suppress this formula so you don't see it when you run the report
2) Now create another formula that will go into the Detail section. This is the formula that will build the string:
WhilePrintingRecords;
StringVar Run;
Run := Run & & ", " & {table.TRUCK};
You can hide the detail section or format this formula to be suppressed so you don't see it.
3) The last formula goes into the GroupFooter section and will display the string:
WhilePrintingRecords;
StringVar Run;
Good luck,
Brian -
Converting a binary string into a JPEG image in Crystal Reports 2008
Hi Gang
Iu2019m having problems converting a binary string into an image in Crystal Reports 2008
I have JPEG images stored in ECC. ECC stores the data in binary format.
Iu2019m using the ECC function module SKWF_PHIO_CONTENT_ACCESS_GET to retrieve the data. This function module has an export table, FILE_CONTENT_BINARY, which returns several lines of data. Each line contains a maximum of 1,024 characters.
When I drop the T_ FILE_CONTENT_BINARY.LINE field into my Crystal Report detail section, I wind up with a report that displays all the lines in FILE_CONTENT_BINARY table. (in my case, 19 lines are displayed.)
I created a formula to collect all the data into a single string.
whileprintingrecords;
stringvar data:= data & {SKWF_PHIO_CONTENT_ACCESS_GET.T_FILE_CONTENT_BINARY.LINE}
I added the formula to the detail section and itu2019s doing a great job collecting the data.
I then inserted a picture object in the report footer, opened the format editor, navigated to the u201Cpictureu201D tab, and inserted a formula for the u201Cgraphics locationu201D.
whileprintingrecords;
stringvar data:=data;
data
My clever idea turned out to be a disappointment . . . . my picture object is blank.
Does anyone have a solution for converting a binary string into a JPEG image?Save the JPEG in a format CR supports. Refer to the help file for the file types.
Maybe you are looking for
-
MSI Z68A-GD80(G3) and Corsair's New RAM
Yeah, ok, it all looks great, but how do they work together outside of a test laboratory in a real world home built pc? That question was answered very quickly, without any special fiddling about required beyond normal setting changes. When the Corsa
-
New Password is not being recognized by iTunes
Although, I had the correct password, my iTunes account insisted it was not correct. Made me change it and continue facing the same problem. Although, my iTunes account password has been changed about three times, it does not allow me to log into iTu
-
How to show classic package view in Acrobat 9?
In Acrobat 8, I had my package PDF with the left panel showing the PDF files, the middle panel showing the Pages panel, and the right panel showing the content of the page itself. With a three panel view, I could quickly navigate between PDFs, select
-
Cannot install Adobe Acrobat or Reader on Leopard OS!
Has anyone ever had this problem? I used monolingual software to remove non-english language files & non-Intel architectures for installed applications. I have had problems with Acrobat 9 ever since. It requires me to enter my system administrator pa
-
Sub reports not included in CharacterSeparatedValues export
Our application allows users to export a report that includes several sub reports to any of the export formats that the .NET API exposes. The export works in every format except CharacterSeparatedValues. In this format the sub reports are not inclu