| T O P I C R E V I E W |
| Mike Buess |
Posted - 06/30/2002 : 11:43:52 AM Is there a LabTalk or OriginC technique for assigning the contents of a notes window to a string variable? Alternatively, can you save the text to a file? (I know how to assign the contents of a text file to %Z.)
Mike Buess Origin WebRing Member |
| 9 L A T E S T R E P L I E S (Newest First) |
| Mike Buess |
Posted - 10/14/2003 : 10:27:17 AM Hi Tilman,
Once your comfortable w/OC I think you'll find that more and more tasks will become simple and straightforward. Other than learning a whole new suite of functions there are (IMO) only two things you'll need to get over when stepping from LT to OC...
1> Stricter syntax (don't abbrev., watch out for caps, etc). 2> All variables must be declared before they can be used. This can still be a PITA for me at times, but the rewards have been worth it so far.
This task (reading text file) might be a good place to start.
Mike Buess Origin WebRing Member |
| tib |
Posted - 10/13/2003 : 5:07:36 PM Hi Mike, thanks for your comments. Since I haven't dealt with Origin C your solution is not yet that simple to me. By the way, I thought, I had a simple and pure LabTalk solution: Just import your text file into a worksheet and say that 9999 lines are the header. After import you can find the text in %Z. However, obviously it seems that Origin does not allow you to import a pure text file into a worksheet. Error: file.txt does not seem to consist of ASCII data. What a pitty. As usual, it could be simple but then it doesn't work. Again, it seems that I really have to learn Origin C to get simple straightforward tasks done. Thanks anyway, Tilman.
|
| Mike Buess |
Posted - 10/10/2003 : 10:08:28 AM Hi Tilman,
You can read a text file with the LabTalk file utilities module (FUM), but I think I was talking about an Origin C method above. Probably using stdiofile. It reads the file a line at a time and you could tack each line to the end of %Z. The FUM method is essentially the same.
...Actually, the easiest way to read a file into %Z is with a combination of LT and OC methods.
1. Open the file into a Notes window with LT's open -n. 2. Read Notes1 with the following OC function.
string ReadNotes(string strNoteWinName) { Note noteWin(strNoteWinName); return noteWin.Text; }
The labtalk script would look like this...
open -n filename Notes1; %Z=ReadNotes(Notes1)$;
...Notice the correction to argument of the ReadNotes function.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/10/2003 10:21:33 AM
Edited by - Mike Buess on 10/13/2003 1:12:53 PM |
| tib |
Posted - 10/10/2003 : 09:12:16 AM Hi CP, OK, I understand... in the longterm I should better switch to Origin C. But do you know the way how Mike assigns a text file to %Z in LabTalk? This should also work for me for the time being. Thanks, Tilman.
|
| cpyang |
Posted - 10/10/2003 : 08:49:11 AM quote: Why isn't there anything straightforward like %Z=NotesWindow!text$; ???
LabTalk interpreter converts %Z etc into actual text before making assignment '='. The assignment by the interpreter has a limitation on the total length of the statment, so sooner or later, problem will occur. I am trying to explain that LabTalk was not intended as a programming environment, and various limitations prevent LabTalk from being such.
Origin C, on the other hand, is a true programming language and since Origin C codes are compiled, such that errors in the code can be checked first by the compiler to prevent unintended results, which is quite often observed with LabTalk.
CP
|
| tib |
Posted - 10/10/2003 : 08:18:42 AM Let me ask again because I want to manipulate and extract text from a Notes window.
Isn't there a LabTalk (not C) command without the detour of writing and reloading a file from disk? Why isn't there anything straightforward like %Z=NotesWindow!text$; ???
May be I should think about switching to Origin C...? Is there anywhere a good tutorial (a better one than the LabTalk manual for LabTalk?) Thanks, Tilman.
By the way how do you store a text file from disk into %Z ? (with LabTalk)
Edited by - tib on 10/10/2003 08:33:43 AM |
| Mike Buess |
Posted - 07/01/2002 : 10:44:25 AM Thanks for both tips. I should be all set now!
Mike Buess Origin WebRing Member |
| CStorey |
Posted - 06/30/2002 : 8:13:19 PM Hi Mike,
You can use the Save -n LabTalk command to save Notes windows as text files.
Eg. Save -n [NotesWindowName] "%YDP\DP-DebugTrace.TXT";
Hope this helps, Craig
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
| easwar |
Posted - 06/30/2002 : 5:20:17 PM Hi Mike,
You can directly access the text in a notes window in Origin C:
void dd(string strNoteWinName) { Note noteWin(strNoteWinName); string strNoteText = noteWin.Text; printf("Contents of note window: %s\n%s",strNoteWinName, strNoteText); }
Easwar OriginLab. |