Author |
Topic  |
|
AlexD2
France
19 Posts |
Posted - 01/13/2014 : 3:03:46 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): 9.1 SR1 Operating System: Windows7 (32 bit)
Hello,
I don't understand why the following is not possible: >> dataset dset = %([Book1]1,3) Unknown function: %([BOOK1]1,3) %([Book1]1,3) Expression error! DSET:failed to add variable to local stack!
On the one hand, %([Book1]1,3) should be substituted with the name of the corresponding dataset: >> type %([Book1]1,3) Book1_C
On the other hand, the following works:
>> // Using the values in the dataset >> dataset dset >> dset = %([Book1]1,3) // Using
>> // Using the name of the dataset >> dataset dset = Book1_C
What am I doing wrong here?...
Thanks for any insight!
AlexD2
|
|
AlexD2
France
19 Posts |
Posted - 01/13/2014 : 8:18:02 PM
|
Mm...
Is it that in the specific case of a range declaration (or any type of declaration), the substitution is not executed before the execution?
Would this be related with the fact that substitutions can give different results depending on the context:
>> // Case 1: asked to return a string >> string strDs = %([Book1]Sheet1,A) >> type strDs$ Book1_A
>> // Case 2: asked to return values >> ds = %([Book1]Sheet1,A) >> type $(ds) 0 1 2 3 4 5 6 7 8 9 10
?
|
 |
|
lkb0221
China
497 Posts |
Posted - 01/15/2014 : 11:33:06 AM
|
I would say that there is a limitation that one cannot directly assign a new created dataset using substitution notation within the same line.
It's similar to the following example:
dataset dd1 = book1_A; // Works. dataset dd2 = "book1_A"; // Similar error appeared.
For the second problem, you should try the following because it's declared as a string so that need %() to find its run-time value and use $() to change the value back to string for "type" command
string aa$ = %([Book1]1,1); type aa$; // Return Book1_A type %(aa$); // Return Book1_A type $(aa$); // Return nothing type $(%(aa$)); // Return 1,2,3,4,5
Zheng OriginLab |
 |
|
AlexD2
France
19 Posts |
Posted - 01/15/2014 : 12:32:17 PM
|
Hi lkb0221,
Thanks for replying. I did not know about the $(%(aa$)) trick.
Yes, my question is why there is this limitation. Is there a fundamental reason why the syntax "dataset dset = %()" cannot be used? Or is it just that the developers did not take this case into account?
More specifically, I am wondering about what happens to the %() expression... According to the error message ("Unknown function: %(...)"), it seems like it is just not substituted:
>>dataset dset = %([Book1]1,1) Unknown function: %([BOOK1]1,1) %([Book1]1,1) Expression error! DSET:failed to add variable to local stack! #Command Error!
So why is it not substituted here?
I don't understand because in other cases, %([Book1]1,1) can be evaluated either as a string or as a dataset content depending on the context.
For instance: >>string dsname; >>dataset dset; >> >>dsname$ = %([Book1]1,1) // String requested >>type dsname$ Book1_A >> >>dset = %([Book1]1,1) // Content (dataset) requested >> type $(dset) 1 2 3 4 5
Similarly: >>type %([Book1]1,1) // String requested Book1_A >>type "%([Book1]1,1)" // Similar as above Book1_A >>type $(%([Book1]1,1)) // Content requested to be converted to string 1 2 3 4 5
Or what do you mean by "the second problem"?
Thanks,
AlexD2
|
 |
|
lkb0221
China
497 Posts |
|
AlexD2
France
19 Posts |
Posted - 01/15/2014 : 7:55:36 PM
|
Thanks for the additional information Zheng,
Just for the overview and to be sure I have it clear...
You say: "when a new dataset is created with an assignment statement, the statement should be a range notation."
However, all the following statements work: >>range rA = 1 >>dsA = rA // This is indeed a range >>dsB = Book1_B // This is not a range >>dsC = %([Book1]1,3) // This is not a range
Also, two of the above statements work equally with a declaration: >>range rA = 1 >>dataset dsA = rA // This works >>dataset dsB = Book1_B // This works
Just this one does not work: >>dataset dsC = %([Book1]1,3)
So just the syntax with a declaration AND a %() substitution does not work, which is why it gets confusing.
As you said, there is no fundamental reason why it could not work in principle so indeed it would be nice if it could be corrected in a later version.
Best,
Alex
|
 |
|
lkb0221
China
497 Posts |
Posted - 01/16/2014 : 2:30:33 PM
|
Hi, Alexandre
Actually this %([Book1]1,1) notation is a new notation which is introduced in Origin8, while Book1_A is much older. So their might be something we need to fix in the code running mechanism. However, we use a different section of code to deal with undefined variables, maybe that's why directly running "dsC = %([Book1]1,3" works.
I'll report this to our development team.
Zheng OriginLab |
Edited by - lkb0221 on 01/16/2014 2:30:54 PM |
 |
|
AlexD2
France
19 Posts |
Posted - 01/16/2014 : 4:42:55 PM
|
Ok. I see... Thank you very much for the explanation and for reporting.
Alex |
 |
|
|
Topic  |
|
|
|