Author |
Topic  |
|
jdf726
78 Posts |
Posted - 12/12/2019 : 09:27:03 AM
|
Origin Ver. and Service Release (Select Help-->About Origin): 2018SR1 Operating System: Win 7
I have a lot of projects each with a note window that has text that includes substitution notation ready to be evaluated, things like %(<bookname>,"<Column name>",3)
I want to loop over all of the projects and export the SUBSTITUTED text to files. I know how to do the project loop, but I have a problem with rendering the text 'with substitution'.
I use an x-function to read the note text (I couldn't do this in Labtalk...newer versions of Origin support more features but I haven't upgraded yet). This calls in Origin C something like Note noteWin(<notename>); string strNoteText = noteWin.Text; and returns the text that way. I can see it in the command window like
ReadNote(Notes,a);a$=
which gives output like
%(<bookname>,"<Column name>",3)
This is the un-substituted text, but I want to use substitution. Maybe I am being stupid, but I have tried what I thought were all the possible combinations of %() wrapped around the text, using quotes or using string registers to hold the data instead of a string variable, but I cannot seem to activate substitution unless I manually copy the output from the above and use b$ = <pasted output from above> then it renders!
What am I doing wrong? |
|
jdf726
78 Posts |
Posted - 12/12/2019 : 09:55:23 AM
|
Here is the simplest example of evaluating the substitution 'raw' versus outputting the contents of a variable, which is not evaluated.
 |
 |
|
jdf726
78 Posts |
Posted - 12/12/2019 : 10:08:49 AM
|
Is this the correct solution or a hacky workaround?
string getnotesub(string strNoteWinName, string opname) { Note noteWin(strNoteWinName); string strNoteText = noteWin.Text; LT_execute(opname+"$="+strNoteText+";"); return strNoteText; }
This runs (from Origin C) an LT execute command which puts the output into a named variable.
Phew! That was a mission. |
 |
|
yuki_wu
896 Posts |
Posted - 12/13/2019 : 01:08:27 AM
|
Hi,
Not sure which version you are using, but with Origin 2020 you can use a new LabTalk function eval():
str$ = note.text$; // get the text of the active Notes window.
strE$= "";
strE$ += "aa=" + str$;
eval(strE$); // evaluate the expression
aa=;
Hope it helps.
Regards, Yuki OriginLab
|
 |
|
jdf726
78 Posts |
Posted - 12/13/2019 : 05:55:18 AM
|
Thanks Yuki!
At some point afterwards I was thinking to myself "Hold on...is there an 'eval' function like in MatLab???" https://uk.mathworks.com/help/matlab/ref/eval.html
Is there documentation about eval() somewhere?
I found with the documentation about note windows that it assumes that you have the latest version, with easier programmatic access to the text contents.
How many of these commands work in Origin 2018 (v9.5.1.195)? https://www.originlab.com/doc/LabTalk/ref/Note-obj
A further complication is that the words 'note' and 'window' are so common in many documentation contexts that searching for the usage and version-dependent availability of labtalk 'note window' related commands proved difficult (for me anyway!) |
 |
|
yuki_wu
896 Posts |
Posted - 12/16/2019 : 12:45:10 AM
|
Hi,
I am sorry that eval() is a new function and we haven’t add it to our document in time, but we are working on this page now. Hope this document will go live soon.
Since we only provide support for the latest version according to our support policy and documentation in fact is a kind of support, we always assume that user have our latest version when he read document.
Thank you for pointing out the search issue. We will add more keywords in our CHM files (built-in help files )to help users pick out what they want easily in the future. BTW, I use “note window originlab labtalk” as keywords to google it, I can find the answer in the second entry. It is not a bad result, so I think we can try to google our document directly sometimes.
Regards, Yuki OriginLab
|
 |
|
jdf726
78 Posts |
Posted - 12/16/2019 : 08:39:31 AM
|
No worries Yuki!
I found the main documentation about the note window easily enough, and this does say 'since 2019b'. I guess maintaining a differential features matrix across versions is a bit time consuming.
I am actually quite excited about the new features of the html note window (I only just saw Chris' blog post http://blog.originlab.com/publishing/creating-html-reports-and-documents-in-origin-2019b) If I can easily create and export reports into html with embedded data then I can write a simple wrapper html page to browse these locally stored html files. I will also be to transfer these into OneNote, which I am using as an electronic lab notebook.
I'm pretty sure You can transfer into OneNote a bunch of ways e.g. using the MS Graph API or, more straightforwardly, copying and paste from a browser or using an O365 'Flow' to copy new html files from certain Sharepoint directories into new OneNote pages.
I'd be interested to hear if other users do data documentation this way. |
 |
|
Chris D
428 Posts |
|
jdf726
78 Posts |
Posted - 12/17/2019 : 05:13:50 AM
|
Thanks Chris!
I still need to upgrade my version to use that, but will check it out!
You might be interested in projects like this. https://github.com/quantum-matter/LabVIEW2OneNote
They made a labview wrapper for python routines that enables uploading of data to OneNote from labview via python with the MS Graph API.
I had a vague plan to execute this kind of python code directly from inside Origin (I'd like the text/table data to be embedded as well as images so that it is searchable/copyable).
quote: Originally posted by Chris D
Hi,
For graphs only, we have a "Send to OneNote" app: https://www.originlab.com/fileExchange/details.aspx?fid=488
Thanks, Chris Drozdowski Originlab Technical Support
|
 |
|
|
Topic  |
|
|
|