| Author |
Topic  |
|
|
cougar2
Germany
Posts |
Posted - 05/14/2004 : 03:19:52 AM
|
Hi,
I have got two problems (Origin 7.5):
a) I would like to use the switch command to insert different layouts, depending on the letter you choose with the command getnumber. However, the following doesn´t work, the getn command doesn´t transfer the variable %B in a proper way (nothing is inserted).
k=1; %B = "s p"; getn (Add Layout ) k:2s (choose) i:B (Please enter parameters); if (k==1) { switch (%B) { case "s": win -t Layout Layout_3d_s1_s2.otp Layout_s; break; case "p": win -t Layout Layout_3d_p.otp Layout_p; break; } };
The command win -t Layout Layout_3d_s1_s2.otp Layout_s; itself works.
b) When trying to import a large number (880) of worksheets into Origin, it cannot import more than about 800 or so (even when selecting small portions of a 100 at one time). Is there a way around?
Regards,
Cougar
|
|
|
Mike Buess
USA
3037 Posts |
Posted - 05/14/2004 : 08:38:20 AM
|
Hi Cougar,
a) getn (choose) i:B changes the value of i, not %B. Use switch(i) rather than switch(%B).
b) I'm not aware of any limit on the number of worksheets. What are you actually doing? Opening/appending worksheet (OGW) files? Or importing data files to new worksheets? If the latter, how are you importing (Import ASCII or Import Wizard)?
Mike Buess Origin WebRing Member |
 |
|
|
cougar2
Germany
Posts |
Posted - 05/14/2004 : 10:31:24 AM
|
Hi Mike,
thanks for your help.
Problem a): I changed the switch command, but it still doesn´t import the layout. To make it easier to check, I changed the win -t command into type commands below:
k=1; %B = "s_states p_states";
getn (Add Layout ) k:2s (choose) i:B (Please enter parameters); if (k==1) { switch(i) { case "s_states": type "s"; break; case "p_states": type "p"; break; } };
b) I´m importing data files to new worksheets with "Import Multiple ASCII". If I select too many at one time, Origin says that the length exceeds the allocated buffer. So I select only say 100 at a time and then import them in portions. In Origin 7, a big part of the already imported worksheets is suddenly "killed" (not existant anymore) when too many (>700) wks are already open and the addition process is running. In Origin 7.5, it is just denied to open more wks.
|
 |
|
|
cougar2
Germany
Posts |
Posted - 05/14/2004 : 10:35:36 AM
|
Sorry, just a quick addition: The worksheets are not just killed but the last imported wks contains all (or not all) columns of the killed wks.
|
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 05/14/2004 : 11:25:50 AM
|
Hi Cougar,
a) Sorry, I should have been more specific.
getn (choose) i:B;
This returns an integer value for i... i=0 if no item selected (avoid this by setting i=1 prior to getn) i=1 if first item selected. i=2 if 2nd item selected. etc.
To get the string value of the selection use %A=%[%B,#i]. So there are two ways to use your switch command...
(I) switch(i) { case 1: type "s"; break; case 2: type "p"; break; };
(II) %A=%[%B,#i]; switch(%A) { case "s_states": type "s"; break; case "p_states": type "p"; break; };
b) I'll have to think about this more but you might be stuck with this limitation. However, Origin 7.5 has an Origin C version of Import ASCII that might avoid the buffer overflow problem. I'll have to get back to you on this. (Maybe someone else knows already?)
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 05/14/2004 12:30:26 PM |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 05/14/2004 : 11:59:02 AM
|
Hi Cougar,
I'm not sure that any file dialog will handle that many files. You might consider selecting a folder and importing all files within that folder. See this topic for an Origin C method...
http://www.originlab.com/forum/topic.asp?TOPIC_ID=2952
In that topic the path is hard-coded into the function but you could use BrowseGetPath() instead. Also, the FindFiles() function is only available in Origin 7.5 but in Origin 7.0 you can use FindFirstFile() and FindNextFile() instead.
Of course that begs the question of whether or not an Origin project will handle that many worksheets. I imagine it's more a question of resources than available memory so you might have problems even if the worksheets are relatively small. In any case, large projects are more prone to corruption.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 05/14/2004 11:59:52 AM |
 |
|
|
cougar2
Germany
Posts |
Posted - 05/17/2004 : 07:06:43 AM
|
Hi Mike,
the OriginC function with BrowseGetPath() implemented works great. It´s a good way to get around the buffer limitation. Of course, it doesn´t help with the large number of worksheets (in Origin 7.5 I get "failed to create an empty document" and the CodeBuilder says "Runtime Error, failed to find object during method call" after worksheet no. 750). Now that it´s so easy to import the data, I will check it on other machines with more RAM. Let me ask some questions on the OriginC function:
a) In "ASCII Options | Other" I have unselected the Option Rename columns if 1st line contains Labels. Thus my columns are still named A, B, etc when doing Multiple ASCII Import. When I use the OriginC function, this option is neglected and the columns get the labels from the *.dat file. Can I modify this?
b) I have made a button that calls this function. When no worksheet is opened, which is my default setup when starting the import, the button is draft, not-clickable. Can I make it clickable like e.g. the Open Project button? Or do I have to create a Menu entry?
Best Regards,
Cougar
|
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 05/17/2004 : 08:11:15 AM
|
Hi Cougar,
a) Use the second ImportASCII method.
BOOL ImportASCII(LPCSTR lpcszFilename, BOOL bRenameWks=FALSE, int nMode = ASCIMP_MODE_REPLACE_DATA, BOOL bRenameCols=FALSE)
Example...
void ReadASCII(string strFile) { Worksheet wks; wks.Create(); if( wks ) wks.ImportASCII(strFile); // default args }
b) View->Toolbars->Button Groups->(select button)->Settings->Context->Always
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 05/17/2004 08:12:21 AM |
 |
|
|
cougar2
Germany
Posts |
Posted - 05/17/2004 : 10:08:27 AM
|
Mike,
I´m sorry but I didn´t completely express what I wanted. When importing files, (i) the worksheets are named according to the file names, (ii) the first line is taken as column labels (labels are displayed) and (iii) the column names A, B, C, etc. are preserved. With your function, (i) and (ii) are not realized. I tried to modify the ImportASCII method like this:
bool ImportASCII(LPCSTR lpcszFilename, bool bRenameWks=TRUE, int nMode = ASCIMP_MODE_REPLACE_DATA, bool bRenameCols=FALSE);
but that made no difference. Also, I tried to just write:
bool ImportASCII(BOOL bRenameCols=FALSE);
but that didn´t do either.
Cougar
|
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 05/17/2004 : 10:58:23 AM
|
Hi Cougar,
Try this...
void ReadASCII(string strFile) { Worksheet wks; wks.Create(); if( wks ) wks.ImportASCII(strFile,1); // rename wks, leave other args as default }
That will rename the wks but leave column names as they were. Unfortunately, it won't give you column labels you want. If you created a wks template to use with Import (Multiple) ASCII you can use that template in the ReadASCII function. I'm not certain that ImportASCII() reads the ASCII settings of the active wks so you might want to use LabTalk's open command instead...
void ReadASCII(string sFile) { Worksheet wks; wks.Create(GetAppPath()+"MyTemplate.otw"); // create wks from your template if( wks ) LT_execute("open -w "+sFile); //import sFile to active worksheet }
Hope that helps.
Mike Buess Origin WebRing Member |
 |
|
|
cougar2
Germany
Posts |
Posted - 05/18/2004 : 03:38:00 AM
|
Mike,
that helped indeed, it works nicely with the wks template. Thanks! Cougar
|
 |
|
| |
Topic  |
|
|
|