The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Problems with eval(IdentifierName,#recall)
02-27-2017, 03:08 PM (This post was last modified: 02-28-2017 01:13 PM by compsystems.)
Post: #1
Problems with eval(IdentifierName,#recall)
Hello, the following statements executed line by line in the history of CAS view, show the following output [8, 8, id2, id1, id0, 8, 8], but within a program [id1,id0,id2,id1,id1,id1,id1] Why?

Please follow the following steps orderly to see the problem

1: [Shift]+[mem] /userVars, [DELETE]id0, id1, id2 & CAS Vars id0, id1, id2

2: firts goto CAS & HISTORY VIEW
2.1: id0:=8; id1:='id0'; id2:='id1'; [ENTER] // store id2,id1,id0 in the CAS environment
2.2: [ id2, eval(id2), eval(id2,0), eval(id2,1), eval(id2,2), eval(id2,3), eval(id2,4) ]; [ENTER] // returns [8, 8, id2, id1, id0, 8, 8]

3: then goto HOME & HISTORY VIEW // recall IDs in the CAS environment
3.1: { id2, CAS.eval(id2), CAS.eval(id2,0), CAS.eval(id2,1), CAS.eval(id2,2), CAS.eval(id2,3), CAS.eval(id2,4) } [ENTER] // returns {id1,id0,id2,id1,id0,8,8}

4: NOW AS PRGM return or goto CAS mode

4.1: purge(id0, id1, id2); [ENTER] before running the program, to delete pre-assigned data, although it should not be so, since ID0, ID1, ID2 are local variables within of prgm, why is it calling EVAL to global variables? If id0 is local, should call local ID0 and not global ID0

id2,id1,id0; [ENTER] //returns id2,id1,id0
4.2: RCLidsCAS(); [ENTER] // returns [id1,id0,id2,id1,id1,id1,id1] ?
id2,id1,id0; [ENTER] //returns id2,id1,id0
4.3: RCLidsHOME(); [ENTER] // returns [id1,id0,id2,id1,id1,id1,id1] ?

5: switch HOME VIEW
id2,id1,id0; [ENTER] //returns id2,id1,id0
5.1: RCLidsHOME(); [ENTER] // returns [id1,id0,id2,id1,id1,id1,id1] ?
id2,id1,id0; [ENTER] //returns id2,id1,id0
5.2: RCLidsCAS(); [ENTER] // the virtual calculator is locked and creates global variables, id0, id1, id2, why?

PHP Code:
#cas
    
RCLidsCAS():=
    
begin
        local id0
id1id2;
        print;
        
id0:=8;
        
id1:='id0'// OR id1:=quote(id0);
        
id2:='id1';
        print(
"id2="+id2);wait;                     // "id2=8"           ok   id2 -> 'id1' -> 'id0' -> 8
        
print("eval(id2)=" + eval(id2)  ); wait;    // "eval(id2)=8"     ok   id2 -> 'id1' -> 'id0' -> 8
        
print(" ");
        print(
"eval(id2,0)=" + eval(id2,0) ); wait// "eval(id2,0)=id2" ok   id2 -> 'id2'
        
print("eval(id2,1)=" + eval(id2,1) ); wait// "eval(id2,1)=id1" ok   id2 -> 'id1'
        
print("eval(id2,2)=" + eval(id2,2) ); wait// "eval(id2,2)=id0" ok   id2 -> 'id1' -> 'id0'
        
print("eval(id2,3)=" + eval(id2,3) ); wait// "eval(id2,3)=8"   ok   id2 -> 'id1' -> 'id0' -> 8
        
print("eval(id2,4)=" + eval(id2,4) ); wait// "eval(id2,4)=8"   ok   id2 -> 'id1' -> 'id0' -> 8 -> 8
        //sto(9,id2);
        
return( [ id2, eval(id2), eval(id2,0), eval(id2,1), eval(id2,2), eval(id2,3), eval(id2,4) ] ); // [8, 8, id2, id1, id0, 8, 8]
    
end;
#end 

export RCLidsHOME()
begin
    local id0
id1id2;
    print;
    
id0:=8;
    
id1:='id0';
    
id2:='id1';
    print(
"id2="+id2);wait;                     // "id2=8"                 ok   id2 -> 'id1' -> 'id0' -> 8
    
print("eval(id2)=" + eval(id2)  ); wait;    // "eval(id2)=8"           ok   id2 -> 'id1' -> 'id0' -> 8
    
print(" ");
    print(
"eval(id2,0)=" CAS.eval(id2,0) ); wait// "eval(id2,0)=id1" ok   id2 -> 'id2'
    
print("eval(id2,1)=" CAS.eval(id2,1) ); wait// "eval(id2,1)=id1"   ok   id2 -> 'id1'
    
print("eval(id2,2)=" CAS.eval(id2,2) ); wait// "eval(id2,2)=id0"   ok   id2 -> 'id1' -> 'id0'
    
print("eval(id2,3)=" CAS.eval(id2,3) ); wait// "eval(id2,3)=8"     ok   id2 -> 'id1' -> 'id0' -> 8
    
print("eval(id2,4)=" CAS.eval(id2,4) ); wait// "eval(id2,4)=8"     ok   id2 -> 'id1' -> 'id0' -> 8 -> 8
    //sto(9,id2);
    
return( { id2CAS.eval(id2), CAS.eval(id2,0), CAS.eval(id2,1), CAS.eval(id2,2), CAS.eval(id2,3), CAS.eval(id2,4) } ); // {id1,id0,id2,id1,id0,8,8}
end

6: goto HOME VIEW
6.1: purge(id0, id1, id2); [ENTER]
6.2: Now if you define variables in HOME VIEW
id0:=8; id1:='id0'; id2:='id1';[ENTER] // store id2,id1,id0 in the HOME environment
7: goto CAS VIEW
7.1: RCLidsCAS(); [ENTER] returns [8, 8, id2, id1, id0, 8, 8] Why? EVAL command, must first call the local variables and then the global variables
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Problems with eval(IdentifierName,#recall) - compsystems - 02-27-2017 03:08 PM



User(s) browsing this thread: 1 Guest(s)