| Author |
Topic  |
|
|
hotelbravo
Austria
Posts |
Posted - 11/29/2007 : 2:25:25 PM
|
Hey everybody,
I don’t know if there already exists a topic of a problem that I will now describe…
I use the Code Builder of Origin 8.0. With the Code Builder I want to programm a special code to open many chosen files (in ascii-code). Of course, it works!
But now there is a huge problem: The imported datas are not equal to the datas which are written in the file(s)!!!
In the following you see some examples:
My original file with datas: quote: Amplitude Frequency Delay Pulse Width Voltage Power Current 0.000000000 250.000000000 0.000000500 0.000000250 0.540000021 0.044000000 0.092000000 -2.040816307 250.000000000 0.000000500 0.000000250 3.230000019 0.042900000 0.050000001 -4.081632614 250.000000000 0.000000500 0.000000250 5.150000095 0.042599998 0.056000002
When using my code like this:
quote:
[main] getfile -m *.*; // prompt for multiple files for (ii = 1; ii <= count; ii ++) { newbook; getfile -g ii; // get the iith file into %A open -a %A; ....... };
I only get other datas in the worksheet like this:
quote:
Amplitude Frequency Delay Pulse Width Voltage Power Current 0,00000000 2,5E11 0.000000500 0.000000250 1,14E9 0.039799999 0.054000001 -2,75862E9 2,5E11 0.000000500 0.000000250 2,72E9 0.038300000 0.050000001 -5,51724E9 2,5E11 0.000000500 0.000000250 5,43E9 0.038400002 0.056000002
Well, as you can realise, in the second row the datas are partly very different... From the original file there is in the first column no number with E9, but already in the imported file .
So could somebody help me (with codes), so that I can solve this problem and depict the right datas in a worksheet?
Thanks for all! |
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/29/2007 : 5:08:09 PM
|
Open your ASCII Options and change the decimal separtor used in the file ('.' instead of the ',' that you use). Separator list is maked in red below. Don't forget to press Update and save the worksheet template.

Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/29/2007 5:09:11 PM |
 |
|
|
hotelbravo
Austria
Posts |
Posted - 11/30/2007 : 10:16:32 AM
|
Thanks for your support!
But what I want is a script programmed in LabTalk. Some of my code is already posted.
The script with importing files already works. But I have no clue how to programm in order to get the right datas for each column!!!
|
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/30/2007 : 12:13:54 PM
|
quote: The script with importing files already works. But I have no clue how to programm in order to get the right datas for each column!!!
The standard way to use the open command is to save your ASCII options to a worksheet template (say, "MyTemplate") as I described above and then create the workbook from that template using newbook template:="MyTemplate". If you must bypass that procedure you can probably use the system.numeric.separators property. You can try this...
getfile -m *.*; // prompt for multiple files oldsep = system.numeric.separators; // save current separator system.numeric.separators = 4; // you might need to try another value (0, 1, 2 or 3) for (ii = 1; ii <= count; ii ++) { newbook; getfile -g ii; // get the iith file into %A open -w %A; // use -w option when importing a single file ....... }; system.numeric.separators = oldsep; // restore separators
Mike Buess Origin WebRing Member |
 |
|
|
hotelbravo
Austria
Posts |
Posted - 11/30/2007 : 12:34:37 PM
|
Hey,
it really works now!
Thank you very much! |
 |
|
|
ahlers01
Germany
Posts |
Posted - 08/29/2008 : 06:01:44 AM
|
Hello, I'm sorry to chime in late, but I encounter the same problem.
But the solution which Mike Buess offered is not working in my case! Whatever decimal separator I set with the "system.numeric.separators = n" (n=0,1,2,3,4) command, it does not affect what a following "open -w <filename>" command imports into, say, a worksheet. (Only the separator used within the worksheet display changes, of course).
The only thing which DOES help is to change the windows preferences on the OS level (which is just what I want to avoid...)
So what can I do?
Additional info: I issued the commands manually from the script window. It made no difference whether I changed the separator with a "system.numeric.separators = .." command from the script window or with the 'Tools-->Options-->Numeric Format' menu dialog. Origin version "OriginPro 8 SR1, v8.0773" was used on a Windows XP localised for Germany.
-Franz |
 |
|
|
greg
USA
1380 Posts |
Posted - 08/29/2008 : 10:57:08 AM
|
You should not use the 'open' command which does not have control over numeric separator. You should be using the 'impasc' command (new in Origin 8) which does.
Origin does not try to figure out if the source file is using German or English decimal notation. 'impasc' gives you the option of setting numeric separator appropriate to the file.
This code should work for your files:
dlgfile gr:=*.* mu:=1; // Select one or more files count = fname.GetNumTokens(CRLF); // How many selected? string nextfile; loop(ii,1,count) { nextfile$ = fname.GetToken(ii,CRLF)$; // get nextfile impasc fname:=nextfile$ option.FileStruct.NumericSeparator:=2; if(ii<count) newsheet; // if not done, add a new sheet }
|
Edited by - greg on 08/29/2008 1:48:17 PM |
 |
|
|
ahlers01
Germany
Posts |
Posted - 09/19/2008 : 3:06:49 PM
|
quote: Originally posted by greg
You should not use the 'open' command which does not have control over numeric separator. You should be using the 'impasc' command (new in Origin 8) which does.
Origin does not try to figure out if the source file is using German or English decimal notation. 'impasc' gives you the option of setting numeric separator appropriate to the file.
This code should work for your files:
dlgfile gr:=*.* mu:=1; // Select one or more files count = fname.GetNumTokens(CRLF); // How many selected? string nextfile; loop(ii,1,count) { nextfile$ = fname.GetToken(ii,CRLF)$; // get nextfile impasc fname:=nextfile$ option.FileStruct.NumericSeparator:=2; if(ii<count) newsheet; // if not done, add a new sheet }
Thanks Greg, this worked. However, it only worked when I imported to a worksheet. I want to import (single or multiple ASCII files) directly into a graph window. With "open -w" this was possible in the past (and still is possible now, but now only if the decimal separator setting is correct).
A bit of background about my application: I communicate to ORIGIN from a Labview (LV) program. The Labview program connects to ORIGIN using DDE (the program was written years ago when DDE was the only way to communicate). ORIGIN is the server part of the DDE and LV the client. The LV client invisibly runs in the background and monitors activities of the ORIGIN server. When the server issues the command 'Import' (I do this by pressing a customized button in ORIGIN) the LV client pops up a file selection dialog which offers a graphical thumbnail preview of the measurement files to allow the user to select one or more of them for import. Since the files have a complex header structure, LV strips off the header part and puts the naked data part into temp ASCII files which it (the client) eventually tells ORIGIN (the server) to import into the graph or WKS window currently open by using the "open -w <filename>" command.
This may all sound awfully complex, but at the time of writing it it was the only way for me to achieve this functionality of an import dialog of a complex data file with graphical preview (I am proficient LV programmer and know little of labtalk or C (which wasn't even available under ORIGIn at that time)).
-Franz |
 |
|
|
cpyang
USA
1406 Posts |
Posted - 09/19/2008 : 6:52:09 PM
|
maybe you can consider changing the labVIEW side to put data into Origin worksheet directly without using labtalk?
We are adding far more comprehensive labVIEW support in Origin 8. The following links show examples where a bundled array from LabVIEW can be wired into an Origin worksheet directly. We also have subvi that can allow a waveform, or dynamic data from LV to be wired to Origin worksheet.
reading from ascii (TXT) in LV and wire to worksheet via an 1D array cluster:
http://wiki.originlab.com/index.php?title=Simple_NLFit
reading LV binary file into waveform and wire into worksheet:
http://wiki.originlab.com/index.php?title=Waveform_Envelope
CP
|
 |
|
|
ahlers01
Germany
Posts |
Posted - 09/20/2008 : 3:16:04 PM
|
quote: Originally posted by cpyang
maybe you can consider changing the labVIEW side to put data into Origin worksheet directly without using labtalk?
We are adding far more comprehensive labVIEW support in Origin 8. The following links show examples where a bundled array from LabVIEW can be wired into an Origin worksheet directly. We also have subvi that can allow a waveform, or dynamic data from LV to be wired to Origin worksheet.
reading from ascii (TXT) in LV and wire to worksheet via an 1D array cluster:
http://wiki.originlab.com/index.php?title=Simple_NLFit
reading LV binary file into waveform and wire into worksheet:
http://wiki.originlab.com/index.php?title=Waveform_Envelope
CP
Hi CP, thanks for the info!
I actually have started rewriting my old application to make use of the extended COM functionality, and I'm progressing fairly rapidly.
I noticed in the links you posted some references to Labview VIs which I found neither in OriginApp_LV7.llb nor in OriginAppClassics_LV7.llb (I have Origin8, SR3): e.g. in the LV-Code snapshot shown in your first link, there is a VI icon which I cannot find in the two above LLBs:

Further, on page http://wiki.originlab.com/index.php?title=Category:LabVIEW_VI there is the statement: "OriginWave_LV7.llb was added in SR4 for waveform data handling.". So there seem to be more VIs available, but I cannot find mentioning of SR4 on www.originlab.com (Funnily, I only find SR2 as the highest SR there, though I have SR3 already).
Is there a way to get access to the newer VIs, before I reinvent the wheel? If they are still in the beta phase, I'd be willing to share my experience, of course.
Best regards
Franz
P.S.: I would like to send my data directly to a graph from Labview (which was possible with the old "open -w" command). With respect to the COM Server the example found in "\Origin8_SR3\Plotting Data.vi" helped me at lot to get started, though I have to go via an import to a wks followed by a plot ina graph window. Worksheets in Origin8 now have 'LongName', 'Units', and 'Comments' attributes, which a graph can automatically use for a correct axis labeling. How can I invoke that labeling from Labview? |
Edited by - ahlers01 on 09/20/2008 3:26:29 PM |
 |
|
|
cpyang
USA
1406 Posts |
Posted - 09/20/2008 : 4:54:42 PM
|
quote: Is there a way to get access to the newer VIs, before I reinvent the wheel? If they are still in the beta phase, I'd be willing to share my experience, of course.
It would be wonderful if you can help with labVIEW area, and you experience will be most helpful to us.
I have sent a zip file with the SR4 folder to your email address on this forum account.
We originally hope to release SR4 last week but we are running into some delay due to some other areas, so the wiki is updated but software not yet available.
CP
|
 |
|
| |
Topic  |
|
|
|