Author |
Topic  |
|
jdf726
78 Posts |
Posted - 02/13/2018 : 1:59:36 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): Pro 2016 Operating System: Win 7
I have text that contains substitution notation referring to cells in a workbook of the form [VG1 = %(info,"VG1",1)] Where "info" is the name of the book, "VG1" is the column name and the index refers to row.
This text is added to a label on a plot by executing (via originC) a labtalk command to make a label, with the right flags.
strScript.Format("label -px 5 5 -sl -n ttext %s;", titletext); LT_execute(strScript);
The text is also dumped to a note window
Note titlenote; titlenote.Create(); titlenote.text = titleforplot;
This part works very well, but I have later plotting tasks that benefit from using the same label, as stored in the note. In fact, I routinely copy and paste the text from the note window into new plots that are from the same data set, and it all works fine (including the link to the worksheet). Awesome!
The trouble arises if I want to do the equivalent thing programatically. I wrote an origin c function that can get the text from the note window
string getnote(string strNoteWinName) { Note noteWin(strNoteWinName); string strNoteText = noteWin.Text; return strNoteText; }
This can then be called from the command line like this
a$ = notes1; b$ = getnote(a$)$;
and you can do a$= and the label will printed - so the information is there!
NOW THE TROUBLE
I want to add (in labtalk proper this time) the label to a new plot,
string b$ label -px 5 5 -sl -n ttext b$
But this just puts "b$" literally there... so clearly I need to enable the content of b$ to be substituted into the argument...
string b$ = getnote(notes1)$; label -sl %(b$)
This enables substitution of b$ for its contents, but THOSE contents are not substituted.
If I put
string b$ = getnote(notes1)$; label -s %(b$)
then this works better, b$ has been swapped for its contents, but the substitution is not sufficiently deep. You can right click and set the substitution depth manually to '2' and then the link to the workbook kicks in
BUT 1) THat is still a manual action to set the substitution level (maybe not accessible in labtalk https://www.originlab.com/forum/topic.asp?TOPIC_ID=10917) 2) The string is truncated!!! So only the first half of the (multiline) string is visible.
POSSIBLE SOLUTIONS 1) Make a full, substituted string in originc in the first place that has fixed (not link to worksheet) values 2) Perform some kind of in-situ substitution, like c$ = %(b$) and then put c$ into the label (this is truncated, as above). 3) Someone tells me why the text is truncated, and how to set the substitution level programmatically!
|
|
jdf726
78 Posts |
Posted - 02/13/2018 : 2:05:41 PM
|
UPDATE:
string b$ = getnote(notes1)$; label -s -sl %(b$) works except for the truncation!
Why does the string get truncated after a certain length?!
I KNOW that you can insert a label of this length and format using the labtalk command, because I do that via originC the whole time (with the same label!!!)
I also know that the source string b$ has ALL of the information (it is not because of the link between OC and LT).
|
 |
|
jdf726
78 Posts |
Posted - 02/13/2018 : 2:19:06 PM
|
AAAAAAAAAAAAAAAGH!!!
If I use the 'long string register ' %Z to hold the result of the OriginC function
%Z = getnote(notes1)$;
and then pass this straight out to the label
label -s -sl %Z it works.
It turns out that even though b$ had all of the information, it was being truncated to 260 characters during the substitution.
Well, that is an hour (or more!) of my life I'll never get back again.
|
 |
|
|
Topic  |
|
|
|