How to read file before executing everything else in VI
I am using the "Read from measurements file" .vi to read read in a .lvm file containing the data I want to use in my VI. I have two different files I need to read into the VI. After I click "run" the prompt comes up and I select my desired file, then the other prompt shows up, along with everything else running in the VI which is in a while loop, but I do not want anything to run in the while loop until the 2nd input is selected.
Is there anyway for the program to wait until those two files have been read in?
These are the "read from measurement file" vi's that I want to input the data with before having everything execute in the VI.
Solved!
Go to Solution.
Attachments:
Batch Training (2).vi 87 KB
jcarmody wrote:
It's a slight misstatement to call using the Error Out an "easy fix". That's the proper way to control execution order in LabVIEW, while using a Sequence Structure is a "fix".
Actually, the correct way would be to get rid of the local variable and turn the array control into an indicator or eliminate it completely. Is the array control even shown on the front panel?
While the error out is the second choice, it could possibly still lead to a race condition. Since the start of the while loop and the writing to the two local variables can occur in parallel righ after the last file dialog has completed, the error out alone is not 100% safe (well, it probably is, but why take the risk ).
cmersits,
Please show us your code so we can provide some guidance. I have the feeling that you are doing this way more complicated than needed.
LabVIEW Champion . Do more with less code and in less time .
Similar Messages
-
[Urgent] How to read files from different directories?
I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
ProjectDirectory
|--MainDirectory
|--MainProgram.java
|--SupplementDirectory
|--SupplementProgram.java
|--Pictures
|--Image.gif
What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
ThanksRun through the I/O tutorial here. It should get you up to speed on this sort of thing...
-
How to read file from remote machine
Hello,
Hi, i would like to know how to read text file from remote machine using java source code, any code ?
Thanks very much;
Best regards
KimOn the server, perform the following steps:
Parse the request and determine the file to serve
Open a FileInputStream to the appropriate file
Obtain a reference to the Servlet OutputStream
Pipe the bytes from the file to the output stream
Flush and close the streamYou might want to call HttpServletResponse.setContentType("application/octet") to indicate to the browser that a file download will be occurring. Do so before getting the reference to the Servlet's OutputStream.
- Saish -
How to read files in whole directory
hi everybosy i have got a directory called grepdatabase in the following path
/users/zer/gd.
it has 3000 files in it.i have to read each file and do soem process and write it into another file.
but with the following code it says, directorydoesnot exists.but i have the directory,with all the files in it.
File database = new File("c:/Domain/nbi.bbsrc.ac.uk/Users/zer/gd");
if (database.exists() && database.isDirectory()) {
String datafiles[] = database.list();
for (int i = 0; i < datafiles.length; i++) {
System.out.println("processing file: " + database.getAbsolutePath() +
"/" + datafiles[0]);
} else {
System.out.println("Database exists: "+database.exists()+"\nDatabase is Directory: "+database.isDirectory());
}can anyone help me how to read multiple files...ur code can be little modified as follows to make it work flawlessly
File database = new File("c:/Domain/nbi.bbsrc.ac.uk/Users/zer/gd");
if (database.exists() && database.isDirectory()) {
//String datafiles[] = database.list();
//Instead use file list here
File[] datafiles = database.listFiles();
for (int i = 0; i < datafiles.length; i++) {
// System.out.println("processing file: " + database.getAbsolutePath() +
// "/" + datafiles[0]);
System.out.println("processing file: " + datafiles.getName());
} else {
System.out.println("Database exists: "+database.exists()+"\nDatabase is Directory: "+database.isDirectory());
BR -
HOW to read file using ftp???
Hi to all,
I have problem with reading file using ftp connection, i want to read only 1024 bytes for one time, and i have
next code wich read this:
byte buffer[] = new byte[1024];
while( (readCount = input.read(buffer)) > 0) {
bos.write(buffer, 0, readCount);
but I dont know how to put all read data in one byte[] if i dont know length of file.
I can't do some like: byte file[] = new file[1000000];
Thanks for all sugestions!* Download a file from a FTP server. A FTP URL is generated with the following syntax:
* <code>ftp://user:password@host:port/filePath;type=i</code>.
* @param ftpServer FTP server address (incl. optional port ':portNumber').
* @param user Optional user name to login.
* @param pwd Optional password for <i>user</i>.
* @param fileName Name of file to download (with optional preceeding relative path, e.g. one/two/three.txt).
* @param destination Destination file to save.
* @throws MalformedURLException, IOException on error.
public void download(String ftpServer, String user, String pwd, String fileName, File destination) throws MalformedURLException, IOException {
if (ftpServer != null && fileName != null && destination != null) {
StringBuffer sb = new StringBuffer("ftp://");
if (user != null && pwd != null) { //need authentication?
sb.append(user);
sb.append(':');
sb.append(pwd);
sb.append('@');
}//else: anonymous access
sb.append(ftpServer);
sb.append('/');
sb.append(fileName);
sb.append(";type=i"); //a=ASCII mode, i=image (binary) mode, d= file directory listing
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URL url = new URL(sb.toString());
URLConnection urlc = url.openConnection();
bis = new BufferedInputStream(urlc.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
int i;
while ((i = bis.read()) != -1) { //read next byte until end of stream
bos.write(i);
}//next byte
} finally {
if (bis != null) try { bis.close(); } catch (IOException ioe) { /* ignore*/ }
if (bos != null) try { bos.close(); } catch (IOException ioe) { /* ignore*/ }
}//else: input unavailable
}//download()If you don't want to strore the data into a file, use ByteArrayOutputStream instead of a FileOutputStream. -
How to read file on demand (or) avoid polling in bpel 11g?
Hello -
Scenario - Receive two files(A & B) which should end up in two tables (Header, Lines)
BPEL process -
1) Receive acitivity - To Read file (A) via File adapter
2) Tranformed
3) Invoked the Db adapter to insert into "Header" table
4) Added another Receive activity - To Read file (B) via File adapter
5) Transformed
6) Invoked the Db adapter to insert into "Line" table
Issue - Step 4 gets fired as a SEPARATE instance (but no data in lines table) . At the end - I see the BPEL process which is waiting for File B. Even after I dropped File B - I dont see any records going into tables.
Is there a better way to design this process? Do I need to separate BPEL process to insert into Header & Line table? If so - how can I make this sequential process?
Appreciate detailed steps, if possible
Thanks
BabuIf its really a SyncRead Step 4 willl not run as a seperate process.
Step1: Initiates the process once the header file arrived
Step4: Will be invoked like a normal partnerlink.
Just make sure, you put the lines file before the header file in the directory.
If it doesnot resolve the problem, send your project to me helloprasanna at rediffmail.com . I'll have a look.
--Prasanna -
How to read file from server if I have a logical file path?
Hi guys,
I'm having a pretty "on the run" question,
My program is currently reading a file from server using "open dataset" with file path like this (just example)
/usr/interface/abc/bcd/testfile.dat
Now I got a requirement to make it more consistent to read files, instead of reading that physical file name, I should read the files from a specific folder using logical path.
So I go to T code "FILE" and created a logical path called ZABC_FILE_PATH, unix compatible, with physical path is (for example),
/usr/interface/<sysid>/<client>/<filename>
My question is, can I still use open dataset statement to read this? if yes, how do I do that? If no, there should be alternative way, please let me know what you think. Thanks,Thanks all, I figured it out.
ONe thing is that typo double quote
The other thing is the importing part, I need the full file path.
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
CLIENT = SY-MANDT
logical_path = 'ZABC_MY_LOGICAL_FILE_PATH'
* OPERATING_SYSTEM = SY-OPSYS
* PARAMETER_1 = ' '
* PARAMETER_2 = ' '
* PARAMETER_3 = ' '
* USE_BUFFER = ' '
file_name = v_1
* USE_PRESENTATION_SERVER = ' '
* ELEMINATE_BLANKS = 'X'
IMPORTING
FILE_NAME_WITH_PATH = v_what_I_need
* EXCEPTIONS
* PATH_NOT_FOUND = 1
* MISSING_PARAMETER = 2
* OPERATING_SYSTEM_NOT_FOUND = 3
* FILE_SYSTEM_NOT_FOUND = 4
* OTHERS = 5
I really appreciate your contributions, thanks again! -
How to read file header/open filein binary mode
i am using FileConnenction API to read from a file. how can i open a file in binary mode so that i can read file header. In other words i want to open a file in binary mode.
You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
~ -
How to read files....plzzz
Hi! All,
I have a problem in reading files using jfilechooser class.
when i select open menuitem from the file menu and reading it through
the file reader class it is giving nullpointer exception.
Also i tried by hardcoding filename in filereader class instead of using getSelectedfile().This time it is not giving null pointer exception but it is showing any stuff.
Here's the code i am using...
int returnVal = fc.showOpenDialog(openpanel);
if(returnVal == JFileChooser.APPROVE_OPTION){
file = fc.getSelectedFile();
//This is where a real application would open the file.
if(fc == null)
file = new File("D:\\karthik\\java\\");
file = new File("D:\\karthik\\java\\kar.txt");
fc.setCurrentDirectory(file);
BufferedReader infile = new BufferedReader(new FileReader(file));
files.append(infile.readline()); //files is the textarea..how come you do a fc.setCurrentDirectory(file);?
where exactly do you get the NullPointerException? what does your stacktrace say?
thomas -
How to read File Header in JAVA
I wanna upload a(doc/pdf) file from client site, where I hv to check whether the the file is originally a doc/pdf file or not, I mean not just the extension, but the actual header information of the file. Please some body help me to do this, I dont know how to read the file header. Thnx in advnc.
You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
~ -
How to read file in flex ?.
can anyone of you help me to know how to read a file in local
disk with flex.You cannot! Flex is flash player based player meant to work
with browsers and browsers are not allowed to access the local
disks.
You can either read/write file on the server. or consider
using AIR.
ATTA -
WebDynpro: How to read file content?
Hi,
My business scenario requires:
1, The file name is passed in through inbound plug parameter
2, I need to read the file content and then attach it to my CRM transaction
Please share with me how to read the file content.
The following approaches do not fit my scenario:
1, UI element: FileUpload
The reason is obvious: there is only file name parameter instead of any UI interface
2, Function Module: GUI_UPLOAD
The reason is that dump will happen in WebDynpro environment
Thanks & Best Regards,
DavidHI,
Refer these links -
Get content document in WD abap
Excel File to Internal Table -
New to J2ME, dont know how to read files on phone mem
i check all the .io packages, still cant find any class that would help me to read files on phone memory.
and i see that javax.microedition.media.Manager.createPlayer(String locator), require a string input argu. how can i make this string locator point to a media file on phone memory of TF-card.
i heard Kjava has some packages from j2se, is there any class would help me? plz someone give me a link of Kjava reference, i cant find it anywhere, thx a lot!oh~~~no!
i am afraid i cant enjoy myself with file conn.
i tried several times, only to get a "Security Exception", and i contacted with moto dev center, they say that unless i have a cert, i cant use file conn API and many other APIs that is defined as restricted!!!
and for the cert, if i have a biz relation with moto, they could give a "Develop Certification", or i must pay a third party to get a cert...
what a world~~~~~~~~~~~is unfair!!! -
How to read files outside the jar ?
Hi all,
One of my classes inside jar needs to read XML file that resides in the same location where the jar sits. I use MyClass.getClass().getResource("MyXMLFile.xml") but it keeps returning null.
If I place the XML file inside the JAR, I can find it using above methods, but since I want the user to easily edit the XML file without opening the jar file and detach the XML file, I choose not to include the XML file inside the jar.
Any help would be greatly appreciated.
SetyaThanks for the dukes.
My JDBC post on this forum discusses the issues of
using Class-Path in your jar file. It works, but it
may vary from system to system.
Thanks also from my side: I have read recently your discussion about reading files in the jar's directory, since I had the same problem. So I was really glad to see your solution. However, I had one more problem, namely that I'm running my application sometimes from the jar, sometimes from the classes directly (debugging). In order to have always the correct path (although a different one) I have added some more lines to deal with that case. I hope that will be useful for you as well!
Dieter Profos
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.net.URL;
* @author pkwooster
* @author Dieter Profos
* @version 1.01 04/03/26
public class ReadOutside extends Frame {
private TextArea textArea;
public static void main(String[] args) {
// Create application frame.
ReadOutside tc = new ReadOutside();
tc.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
// Show frame
tc.setSize(600,250);
tc.setVisible(true);
public ReadOutside() {
textArea = new TextArea(20,80);
add(textArea);
readOutside(this);
public void readOutside(Object o) {
System.out.println(getCodeBasePath(o));
/** Gets the absolute path of the directory where the JAR or CLASS file is
* located. If the application is run from a jar file, the directory of the
* jar file is returned; if it is run from a class file, the method will
* return the directory path of the class file.
* @param o The main class of the application.
* @return The absolute directory path, or null if neither the class nor a
* jar file could be found.
public String getCodeBasePath(Object o) {
Class c = o.getClass();
URL url;
// get the class name
String className = c.getName();
textArea.append("class name = " + className + "\n");
// replace package periods by file separators
className = className.replace('.','/');
ClassLoader cl = c.getClassLoader();
if (cl == null)
cl = ClassLoader.getSystemClassLoader();
url = cl.getResource(className + ".class");
String xPath = url.toExternalForm();
textArea.append("url = " + url + "\n");
textArea.append("extPath = " + xPath + "\n");
// make sure that the path starts with jar:file:
if (xPath.startsWith("jar:file:")) {
// remove jar:file: + the subsequent file separator
xPath = xPath.substring("jar:file:".length()+1);
int n = xPath.indexOf("!");
if (n < 0)
n = xPath.length();
String jarPath = xPath.substring(0, n);
textArea.append("jar file path = " + jarPath + "\n");
n = jarPath.lastIndexOf("/");
String jarDir = jarPath.substring(0, n+1);
textArea.append("jar dir = " + jarDir + "\n");
return jarDir;
else { // if program is run from its class file (development phase!)
if (xPath.startsWith("file:")) {
// remove file: + the subsequent file separator
xPath = xPath.substring("file:".length()+1);
textArea.append("class file path = " + xPath + "\n");
int n = xPath.lastIndexOf("/");
String classDir = xPath.substring(0, n+1);
textArea.append("class dir = " + classDir + "\n");
return classDir;
return null; -
Do anybody know how to read file...
Hello,
I have a problem with reading config file. Do anybody know how to read config file from the same dir as class.
Now the situation is like:
filePath I hardcoded like:
fileName = "C:\\apache-tomcat-5.5.17\\webapps\\ROOT\\WEB-INF\\classes\\config.sales";
Is it possibility to read config file wich is used by java classes (in prj) from the same dir as classes are?
Thanks in advance.If the file is in the class path you should be able to access it using the Class.getResourceAsStream method. It is the same concept as loading a properties file:
http://www.javaworld.com/javaqa/2003-08/01-qa-0808-property_p.html
Maybe you are looking for
-
Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Snow lepard it work just perfectly... help please.
-
From which table I can get Vendor characteristic values ?
Hi Everybody, From Which table I can get <b>Vendor Characteristic values from Vendor classification ?</b> Thanks & Regards, Nagaraju Maddi
-
RFC call do not return any value
Hi All, I have an RFC written in one R/3 system(call center R/3) and i am calling this RFC in the ERP system. If i try to run the RFC locally in the call center system ,it runs correctly and returns me proper values. But when i try to call it from o
-
How to unlock my itunes. I cannot open my itune 11.0.4. MacBookPro
please i need help...
-
Search a paragraph style next to other paragraph style...
I need search a paragraph style ("AAA") next to other paragraph style ("BBB"), and modifiy in this case ("BBB" to "BBB+") with a "spaceBefore" of 3 mm... My code don't work... Please, help me...!!!