The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Very long string in label
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

denis.crete

France
Posts

Posted - 02/18/2006 :  2:15:19 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 6
Operating System: Win 2000

Hello,
I would like to automatically generate a legend in the form of a double-entry table for a large number of curves.
In the case of 90 curves, the message string to give to the label command would be an 11 lines text:

B 10G2 20G4 40G8 61G2 122G4
F X' X" X' X" X' X" X' X" X' X"
725 \L(1) \L(2) \L(3) \L(4) \L(5) \L(6) \L(7) \L(8) \L(9) \L(10)
1440 \L(11) \L(12) \L(13) \L(14) \L(15) \L(16) \L(17) \L(18) \L(19) \L(20)
5760 \L(21) \L(22) \L(23) \L(24) \L(25) \L(26) \L(27) \L(28) \L(29) \L(30)
11520 \L(31) \L(32) \L(33) \L(34) \L(35) \L(36) \L(37) \L(38) \L(39) \L(40)
20525 \L(41) \L(42) \L(43) \L(44) \L(45) \L(46) \L(47) \L(48) \L(49) \L(50)
33040 \L(51) \L(52) \L(53) \L(54) \L(55) \L(56) \L(57) \L(58) \L(59) \L(60)
53040 \L(61) \L(62) \L(63) \L(64) \L(65) \L(66) \L(67) \L(68) \L(69) \L(70)
73040 \L(71) \L(72) \L(73) \L(74) \L(75) \L(76) \L(77) \L(78) \L(79) \L(80)
93025 \L(81) \L(82) \L(83) \L(84) \L(85) \L(86) \L(87) \L(88) \L(89) \L(90)

(where the column and rows headers are parameters extracted from the dataset names).

Apparently, this string is too long to fit in a %letter string variable (are they limited to about 256 characters ?);
The lousy solution that I have found consists in chopping the string in several parts
and stowing the concatenation of these parts in the "message" parameter of a label command:

%L=B ; for (k=0; k<NHoriz; k++) %L=%L\t%[%($(2*k+1)),>'H']\t;
# %L contains the first line;
%L=%L\r\nF; for (k=0; k<NHoriz; k++) {%L=%L\tX'\tX"}
# now it contains lines 1 & 2;
%M=""; for (f=0; f<NVert && f<2;f++)
{ %M=%M\r\n%[%[%($(1+2*NHoriz*f)),>4],'H'];
for (k=0; k<2*NHoriz; k++) %M=%M\t\L($(1+k+2*NHoriz*f));
};
# %M contains lines 3 & 4
%N=""; for (f=2; f<NVert && f<4;f++)
{ %N=%N\r\n%[%[%($(1+2*NHoriz*f)),>4],'H'];
for (k=0; k<2*NHoriz; k++) %N=%N\t\L($(1+k+2*NHoriz*f));
};
# %N contains lines 5 & 6;
%O=""; for (f=4; f<NVert && f<6;f++)
{ %O=%O\r\n%[%[%($(1+2*NHoriz*f)),>4],'H'];
for (k=0; k<2*NHoriz; k++) %O=%O\t\L($(1+k+2*NHoriz*f));
};
# %O contains lines 7 & 8
%P=""; for (f=6; f<NVert && f<8;f++)
{ %P=%P\r\n%[%[%($(1+2*NHoriz*f)),>4],'H'];
for (k=0; k<2*NHoriz; k++) %P=%P\t\L($(1+k+2*NHoriz*f));
};
# %P contains lines 9 & 10
%Q=""; for (f=8; f<NVert && f<10;f++)
{ %Q=%Q\r\n%[%[%($(1+2*NHoriz*f)),>4],'H'];
for (k=0; k<2*NHoriz; k++) %Q=%Q\t\L($(1+k+2*NHoriz*f));
};
# %Q contains line 11
label -s -sa %L%M%N%O%P%Q;


I tried also this:

label -n Legende -s -sa B;
for (k=0; k<NHoriz; k++) Legende.text$=Legende.text$\t%[%($(2*k+1)),>'H']\t;
Legende.text$=Legende.text$\r\nF; for (k=0; k<NHoriz; k++) {Legende.text$=Legende.text$\tX'\tX"}
for (f=0; f<NVert ;f++)
{ Legende.text$=Legende.text$\r\n%[%[%($(1+2*NHoriz*f)),>4],'H'];
for (k=0; k<2*NHoriz; k++) Legende.text$=Legende.text$\t\L($(1+k+2*NHoriz*f));
};

but it does not work...
Does anyone have a suggestion ?
Thank you in advance.
Denis

Mike Buess

USA
3037 Posts

Posted - 02/18/2006 :  3:36:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Denis,

All string variables except %Z are limited to 256 characters but %Z can hold over 8000 characters which should be enough for your label. However, Origin 6.0 has a limitation on the number of characters in a text label as described in this KB entry...
http://www.originlab.com/www/support/resultstech.aspx?ID=275&language=English

If you are running against the latter limitation you either assign the legend text to the text variable %Z and use legend.text$=%Z (legend must already exist) or split your legend into multiple labels and align them with the Object Edit toolbar or by script. I haven't examined your scripts yet so perhaps that is what you are trying to do already. However, here is the general approach that I might use to split the legend. (The order of the arguments for the label command is important.)

%Z=B 10G2 20G4 40G8 61G2 122G4
F X' X" X' X" X' X" X' X" X' X";
label -s -sa -n Legend0 %Z; // create label with your 1st 2 lines
Legend0.top=0; // move to top of page
%N=725 1440 5760 11520 20525 33040 53040 73040 93025; // make sure I didn't leave one out!
for(ii=1;ii<10;ii++) {
kk=10*(ii-1);
%Z=%[%N,#ii]; // start next line
for(jj=kk+1;jj<=kk+10;jj++) {%Z=%Z \l($(jj))}; // finish next line
label -s -sa -n Legend$(ii) %Z; // create label
Legend$(ii).left = Legend$(ii-1).left; // align left wrt to previous label
Legend$(ii).top = Legend$(ii-1).top + Legend$(ii-1).height; // place it below previous label
};

Once all legends are created you can group them from the Object Edit toolbar so you can move them as one object.

...Performed the simple test of counting the number of characters in your legend and came up with 740. (Should have done that to begin with. ) According the KB article I cited above this is below the 1524 character limitation for Origin 6.X text labels but above the 680 character limit for assigning text to labels with the label command. Therefore, the following should work for a single legend.

%Z=your full legend text;
label -s -sa -n legend junk; // create legend with default text
legend.text$=%Z; // replace with desired text

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 02/18/2006 3:42:18 PM

Edited by - Mike Buess on 02/18/2006 4:20:28 PM
Go to Top of Page

denis.crete

France
Posts

Posted - 02/20/2006 :  04:13:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, Mike! It works perfectly. I choose the solution involving only the use of %Z, with the command
label -s -sa -n legend0 %Z;
I did not try to create several labels, but I'm sure it could have been done as well. It might even be a good solution for me as it separates the columns header from the rest.
I finally found where these limitations are quoted in LabTalk's help.

Thank you also for this very quick answer.
Best regards
Denis

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000