Author |
Topic  |
|
tom3m
USA
27 Posts |
Posted - 02/08/2002 : 10:47:40 AM
|
Can anyone think of a reason why a script would run just fine in the script window but not from a user-defined button? I have plenty of other scripts that work just fine with buttons.
Thanks! |
|
Mike Buess
USA
3037 Posts |
Posted - 02/08/2002 : 3:07:22 PM
|
I think you'll have to show us the script.
Mike Buess Origin WebRing Member |
 |
|
tom3m
USA
27 Posts |
Posted - 02/11/2002 : 1:01:02 PM
|
I can't give you the script because it is long and heavily commented with confidential information. I was hoping there might be some standard lore about what to check.
I think I might have found the problem, though. When copying a range of data in a column from one worksheet to another, I found that only 30 values would copy over. I've gone over the index ranges and the "complex" copy command definition about 20 times and cannot find a mistake in my code (eg. am I creating a cell reference out of range or something?), so now I am just looping over the data and copying cell-by-cell. With the new loop instead of the copy command, the script runs just fine.
Does anyone know if there is a built-in limitation on the copy command?
Thanks! |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 02/11/2002 : 2:33:10 PM
|
My guess is that you are trying to copy to a newly created worksheet, which always contains 30 rows. Try increasing the number of rows in the new worksheet before you copy to it. Something like this...
win -t D; // Create new worksheet set %H -er 128; // Set the number of rows to 128 copy -b 1 Data1_A col(A) -b 1 -e 128; // Copy 128 rows from Data1_A to %H_A
I'm not sure why this is necessary when the script is run from a button but not when it's run from the script window. Anyone else?
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 02/11/2002 14:37:26 |
 |
|
andreas1
Germany
12 Posts |
Posted - 02/12/2002 : 02:52:11 AM
|
I had the same problem when running scripts directly, i.e., no buttons. I would be nice to have an automatic extension of the number of rows when copying into a new worksheet.
Andreas
|
 |
|
tom3m
USA
27 Posts |
Posted - 02/13/2002 : 3:39:39 PM
|
Hey - great suggestion - but not exactly my problem. I think my problem is related, though, and that I learned something from this.
I create the worksheet with the number of rows that I need and two columns to start. The first two columns of data always copy over ok. I use the "create" command, though, like:
create NEWDATA -w irows AA BB;
where irows is the number of rows to make the worksheet (with two columns AA and BB).
After that, I add columns to the new worksheet, two at a time, for each imported data set after the first (I am importing multiple ASCII files). I use the commands:
win -a NEWDATA; worksheet -c AA; worksheet -c BB;
to get the right worksheet and create the columns. After that I copy the data, rename the columns, and set the first of the new columns to be type=4 (X-variable).
Happily, I saved the version of the script that I had before changing to the loop over cell reference method to copy. I just tried inserting the command:
set %H -er irows;
right after creating the second of the two new columns, and now the script runs and I get a full copy of all cells!
I think the lesson here is important and not obvious from the labtalk manual. The command:
worksheet -c colName
will create a column named "colName" with the default number of rows (30), even if you are creating the column in a worksheet that has >30 rows in existing columns. In addition, there is no parameter in this command to tell origin how many rows in the new column. So if you use this, then make sure you use the set command above to force the new columns to have the right number of rows.
Thanks! |
 |
|
|
Topic  |
|