Write to an array
Hello
How do you write on the fly to an array. This is a way to put contents hard coded in..But how can I do it just writing a sentence to the array?
import javax.swing.*;
public class stringStuff{
public static void main( string args[] )
string1 = "Hello all";
char charArray[] = new char[ 5 ];
String output = "s1: " + s1;
Hello
How do you write on the fly to an array. This is a way
to put contents hard coded in..But how can I do it
just writing a sentence to the array?
import javax.swing.*;
public class stringStuff{
public static void main( string args[] ) {
string1 = "Hello all";
char charArray[] = new char[ string1.length() ];
for (int i= 0; i < string1.length(); i++) {
charArray= string1.charAt(i);
System.out.println(charArray[i]);
Think this works, or somthing like it.
See ya
Michael
Similar Messages
-
Write Text Data Array to text file
Greetings all. I hope someone can help me as I am really under the gun. The attached vi shows the basics of what I am trying to do. I have already written a vi that takes the Cal Data Array and prints it out in a nicely formatted report. My problem is that the powers that be also want the data saved to a generic text file that can be copied and printed out anywhere they like. As such, I need to save the data to a generic text file in column format such that it will all fit on one page in landscape mode. There are a total of 12 columns of data. I have been trying to create something that would format each column to a specific length instead of them all being the same. No luck so far. Basically, I need columns 1,2,3,8 and 12 to be length of 5. The rest a length of 9. I have tried to place the formatting part in a for loop with the formatting in a case, but it does not appear to work. I really need this quick so if anyone has any ideas, please help. As always, I really appreciate the assistance.
Thanks,
Frank
Attachments:
Write Cal Data to Text File.vi 21 KBpincpanter's is a good solution. Beat me to it while I was away building an example. Similiar approach using two for loops and case statement. Here is my suggestion anyway....
cheers
David
Message Edited by David Crawford on 11-23-2005 09:37 AM
Attachments:
Write Text Data Array to text file.vi 31 KB -
How to write a 2D array to a database using database connetivity toolkit?
Hey Gang.
I am having trouble writing records efficiently to my database. I have a 2D array of elements that I am writing to my database. Currently, I am writting one row at a time using a FOR loop and "DB Tools Insert Data.vi". Unfortunately, this process is very time consuming. When I try writing in the entire 2D array (as opposed to 1 row at a time) I get the error:
"Number of query values and destination fields are not the same..."
Is there any way to write a 2D array to a database in one shot?? (and take up the same number of records as if I wrote each row individually)
Any ideas would be much appreciated.
Using LV 2010.
CheersMaybe Ive explained the issue incorrectly. Please see the attached snapshot. The top portion of the code is what I currently have. It works, but it writes one database record at a time and the loop runs ~1000 times. (How I am generating the data to write is not particularly important but how I am writing to the database is currently my issue)
The second loop is what I would like to get working as the database write function will only run 4 times (as determined by the number of elements in the variable "Multiple Tables".
Thanks to all for the input so far.
Attachments:
Database Write Test.zip 64 KB -
DSC - Write Trace - Bit Array or Logical
Hi,
we are trying to write digital signals to a citadel database. The polymorphic function "Write Trace.vi" has the types logical and bit array.
First of all I have created a new database and tried to write 10 digital signals of type boolean to the database. Unfortunately I get an error: "SPW_WriteBool.vi:2". I only can write the data into the citadel database if I convert the boolean to 0 and 1 values and write them via the numeric type. But this causes an overhead of factor 32.
Is there a sample vi of using the "Write Trace.vi" function of type Logical or Bit Array. I've noticed that the trace which I have created is a analog one of type double. In another database of our company I've found a discrete trace of type double. Is this the problem?
Kind Regards
JoachimMany thanks for your help. MAX would be a nice and easy way to view the data, by the way, I try to view them with the Mixed Signal Graph. I am very new to LabVIEW and I am fighting now in correct reading of my data. I have 32 digital channels - each value of them is packed in an U32. When making a loop of my example 2 times for each channel should contain 2 values. But how can I program that the first boolean of the U32 is part of digital channel 1 - second boolean is part of digital channel 2 and so on? I've read that I can only transpose 2D arrays. Enclosed I've programmed the visualization of 2 digital channels containing 32 datapoints. But the result should be 32 channels with 2 datapoints.
Kind Regards,
Joachim
Attachments:
read from citadel - bit array.png 8 KB -
Write 2D data array to spreadsheet with good alignment
Using "write to spreadsheet file" function to write 2D array, I always have the problem that headers cannot align well wiith the data. See attached snapshot please (There are 7 column headers.)
WT
LV2013sp1
Solved!
Go to Solution.Plain text display cannot handle tabs very well.
You can take the spreadsheet file and open it in e.g. excel and it will all look great. Spreadsheet files have no formatting information, just row and column delimiters.
If you want to create nicely formatted report files in LabVIEW, use the report generation tools and pick an output file format that is suitable for what you want to display (e.g. html).
If you want to display your data in a plain text indicator, you would need to do two things:
use a fixed-width font (e.g. courier)
Format all fields with a fixed widh of padding characters.
For a tabular front panel indicator, you should use a table. You can write the header strings into the table header.
LabVIEW Champion . Do more with less code and in less time . -
Read/Write 2d numeric array or string array into bin file
Can anyone pls help me to resolve this problem
Attachments:
bin file.vi 9 KBYou are still using the wrong format.
Whatever you are doing has nothing to do with a binary file.
You are still using way too much duplicate code.
All you probably need is read/write from spreadsheet file, no need to reinvent the wheel.
Your code will fail if the numbers contain decimal digits (since your array is DBL, it could! If your array only contains integers, you are using the wrong numeric representation).
You string code will fail if the array elements contains tabs, for example.
You still don't need a sequence structure.
LabVIEW Champion . Do more with less code and in less time . -
BufferedOutputStream do not write all byte array in linked OutputStream
Hello,
I am writing a proxy.When a proxy works like transparent
"clientOut.write(response, 0, responseLength);"
clientOut is
"BufferedOutputStream clientOut = new BufferedOutputStream(pSocket.getOutputStream());"
All is works right,but when I change response array
"responseProxy = modi_content(response,word,color);"
"modi_content" is a function, who change original response.
After that, I want to write modified response in client stream
"clientOut.write(responseProxy, 0, responseProxy.length);".
The result is that, not all bytes from responseProxy are wrote in OutputStream and
the web page have no all source code and desplays incorrect in browser.
Do you have any ideas, where I make mistake and who is that mistake.
Thank you.when type
"System.out.println(new String(responseProxy));"
all data is good,but after
"clientOut.write(responseProxy, 0, responseProxy.length);"
browser dislay not all page.
Function "modi_content" just insert a javascript in response. -
Can't write to one array - error -50
I have an XServe RAID with a 7 disk 3TB RAID 5 volume on one side and a 4 disk 1.2TB RAID 5 volume on the other side. I am suddenly no longer able to write to the 3TB volume. The smaller volume works fine. The same error (-50) occurs from a client trying to access their files via AFP as well as directly in the finder on the server. Any ideas as to what might cause this and how to go about fixing it?
Disk util etc. don't show any errors.
Thanks,
Miles
XServe G4 dual 1.33, 2GB RAM, Apple Fibre card and cables (optical, I think).Hey Miles,
I've found errors to pop up when a drive or a controller starts to go sour... naturally, controllers failing is almost underheard of (but it does happen) so always best to make sure its a drive acting funny first. Of course if the drive isnt yellow or red, apple wont really help you.. here's a way to see if a drive is the case and if so, how to speed up the process to make it trigger yellow or red:
Go to Raid Admin
Go to the drive conditioning option ( i believe this is raid admin 1.5 only)
start conditioning on the array in question and let it go...
You should see all the drives go blue.
First way to check is to see if any errors start popping up in raid admin (and apple would help you from there)
Second way to check is to see if one of the drive's blue LEDs is acting funny (stays solid all the time, blinks out of sequence with the other drives, etc)
If those happen, chances are that drive's gonna go soon and either a colored light or an error is more than enough for applecare to replace it if you have warentee/applecare. -
Write an 1d-array of cluster with 3 elements
Hi,
I have to make a "Power spectral densities" analyse from my waveform data. The results from this VI is an array of cluuster with 3 elemments. Now I want to write this array of cluster with 3 elements to a file. And later it must be able to use this file with EXCEL!!
thanksHi
I found some outer Forum entries about this topic.
Look at this links:
http://forums.ni.com/ni/board/message?board.id=170&message.id=49553&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=51526&requireLogin=False
I hope this helps
Manuel -
How can I write a 1d array of cluster with 3 elements to a file?
Hi,
I have to make a "Power spectral densities" analyse from my waveform data. The results from this VI is an array of cluuster with 3 elemments. Now I want to write this array of cluster with 3 elements to a file. And later it must be able to use this file with EXCEL!!
thanksHello schloronzo,
make a for loop feeded with your array. Inside the for loop unbundle
the cluster, "format into string" the 3 values, adding the result to
the ones before and collect them in a shift register. Then save the
resulting string to a txt-file. If you make a good format string then
Excel is able to read your txt-file (use tab a separator and CR/LF
after each 3 values aka "csv format").
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Hello All...........,
I have done some code for applet and servlet communication in which i writes "String " as an object and gets reply from servlet as a string as follows:
// send data to the servlet
String input="hello there.....";
URLConnection con = getServletConnection();
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(input);
oos.flush();
oos.close();
// receive result from servlet
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String result =(String) inputFromServlet.readObject();
outputField.setText(result);
//outputField.setText("good morning");
inputFromServlet.close();
instr.close();This code is same at servlet end.
But now i want to pass an int array.How to pass int[] as an object.
It is giving me error if i pass int array as int array[]={1,2,3}; oos.writeObject(array); Why is it so?
Can anybody tell me how to write and read int array[].
Thanks.
Shraddha.hello kaj,
I am trying to write as follows
while writting:
int array[]={1,2,3,4,5};
URLConnection con = getServletConnection();
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(array);
oos.flush();
oos.close();
while reading:
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
int result[] =(int []) inputFromServlet.readObject();
Thanks,
Really imp for me. -
How do you write to a 3D array?
I know this is probably a very simple questions, but for some reason I can not think of how to write to a 3D array. The application that I am going to use this for is that I have multiple graphs with x and y data points, and I want to be able to write all the graphs with their data points to a 3D array instead of having a large amount of 2D arrays. My main goal is to be able to use this 3D array with a graph so that I can click through all the graphs after I have done my measurements. I appreciate anyone that can give me help on this matter.
3D array handling is not much different from 2D, you just have another coordinate to specify - "page" (row, column, page). Create a 3D array constant and wire it to e.g. the replace function and it will automatically scale up to show you the index and length options involved...
PS. If you have XY arrays why not just have a 1D array of XY sets (as one would use for multiplot XY graphs)?You could even write the whole array to a graph (save you the extraction operations) and then choose to see whatever combination you would like by setting the color of the plots you want to hide to transparent.
MTO -
Write arrays into a text file in different columns at different times
Hi,
I have a problem write data into a text file. I want to write 4 1D arrays into a text file. The problem is that I need to write it at different time and in different column (in other word, not only append the arrays).
Do you have an idea to solve my problem?
Thank youA file is long a linear string of data (text). In order ro insert columns, you need to rewrite the entire file, because colums are interlaced over the entire lenght of the file.
So:
read file into 2D array
insert columns using array operations
write resulting 2D array to file again.
(Only if your colums are guaranteed to be fixed width AND you know the final number of colums, you could write the missing columns as spaces and then overwrite later. Still, it will be painful and inefficient, because column data are not adjacent in the file.)
LabVIEW Champion . Do more with less code and in less time . -
How do I write whole array in single write ?
Hi Jgurus,
I have fetched the record from Oracle and I wants to write those in a file . But problem is for every record in a record set file.writebytes write to a OS file. I don't want this single record write since it will write one by one. I have crores of records to fetch. Critical issue is performance. Can I picked up the rows in bunch and write to file ? I have stored (on smaller record size) all rows in array and now want to write the whole array to file in one OS write operation. Is there any way to do this ? Do any one suggest the better approach ?
For real scenario file size will become around 300MB. I did it but it writes one by one record using next() from record set.
Please advice.
--RajivK.Can you give any example for a small String or int array. I have stucked at this point. I have wrote the array using for loop but for each iteration in a loop it writes. I have 5 lakh values stored in array. Can anybody show how do write whole array to os file in one write operation instead of getting one by one value and printing it. I am new to java please give details or sample so that I can understand.
Thanks in advance.
--RK. -
Multiple writes of a DBL 2D array to binary file
Hello.
Does anyone have an example of writing a 2D array to a binary file multiple times?
Specifically, I need to write a 2D array of DBL to a binary file mulitple times and then (later) be able to read it back (reconvert to DBL). All of the examples that I've found only do one write and then close the file. I need to leave the file reference open and write data to it over the period of a few days. The data comes out of a queue that is fed from a DAQ loop. (In an acquistion loop I feed a queue and in a slower loop I dequeue the data and write it to disk)
I believe it has something to do with the pos mode and offset mode but I can't figure it.
I haven't been able to successfully read the data back yet from the .bin file so I'm not sure if I'm even writing it correctly.
The closest example that I've found is the High Speed Data Logger and High Speed Data Reader but I haven't had any luck with those.
Thanks in advance.
Steve
LabVIEW 7.1
Solved!
Go to Solution.To change the representation of a number, use the Numeric > Conversion sub-palette.
The example below shows that the wires contain the representation info independently of the destination indicators : you can connect different types of numerics to the same wire and LabVIEW will automatically adapt to the type (the coercion dots indicate that a convertion has been done). Everything you should want to know about converting numbers is explained in the LabVIEW Help : "Conversion VIs and Functions"
Message Edited by chilly charly on 07-30-2005 10:57 AM
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Attachments:
Convert to single.png 27 KB
Maybe you are looking for
-
HT4623 How do I install 10.6.3 onto my iphone 4?
Trying to download all of my old apps onto my phone but its saying that I need to install 10.6.3? I already tried going to settings and using the software Update but it says that I don't have any updates that need to be installed. Help!
-
Firefox v17.0, windows7. this is not related to the web page, all URLs present this issue. firefox is the default browser
-
Unable to share from iphoto using Messages....
I have upgraded to Mavericks and have noticed that I can't share a photo directly from iphoto using Messages. Anyone else have this problem? I got an error message once that said something like "couldn't communicate with helper application". Usually
-
Installing a VPN Server in Mac OS X
Has anyone tried to install a VPN server successfully in mac os x? I was able to get webmin installed successfully, and I know on my linux distros webmin automatically detects if a VPN server is installed (such as poptop) or at least if the option is
-
Why should useful life be given in case of PRC depr type?
Hi Experts, I have no answer for that quation that if i have a depreciation type which is straight line but under calculation tab the type is PRC, then in asset master data why do i have to give a useful life for this asset. I cannot add a new asset