Post Reply 
Error Msg : Unmatch control word
01-06-2015, 12:27 AM (This post was last modified: 01-06-2015 12:40 AM by compsystems.)
Post: #6
RE: Error Msg : Unmatch control word
sorry for my bad English

Error Msg : Unmatch control word this happens sometimes when a function is not defined, and tries to call or function that not belongs to HOME or CAS mode

Is hard build n programs or subrutines in a single file, it is best to create separates functions. but this requires an external editor

PrimeComm is a external program editor project, which is stopped = (.

/!\ some instructions do not operate in certain modes (CAS/HOME), the good thing is that you can now specify CAS (#cas ... #end) and not CAS in a single file


An example

Code:
#cas

    // © complex algebra library
    // © complex numbers and functions
    // © version 0.01 January 2015
    // © By JaiMeza 

    cplxA := 3+4*i; // numeric complex
    cplxB := x+y*i; // symbolic complex

    // © modulus of a complex number given in standard form
    modulus(z)
    begin
        return abs(z);
    end;

    // © real part of a complex number given in standard form
    realPart(z)
    begin
        return re(z);
    end;

    // © imaginary part of a complex number given in standard form
    imagPart(z)
    begin
        return im(z);
    end;

    // © conjugate of a complex number given in standard form
    conjugat(z)
    begin
        return conj(z);
    end;

    // © argument of a complex number given in cartesian form (x,y)
    cartArg(x,y)
    begin
        // © arguments x, y
        if getMode_angle() == "RADIAN" then
            return ((π/2)*sign(y) - atan(x/y));
        else
            return ((90)*sign(y) - atan(x/y));
        end;
    end;

    //  © argument of a complex number given in cartesian form
    argument(z)
    begin
        Return arg(z)
    end;

    // © conversion from polar to cartesian form
    polarRθtoCartXY(r,θ)
    begin
        return ( [[ r*cos(θ), r*sin(θ) ]] )
    end;

    exeSample()
    begin
        cplx1 := 3+4*i;
        cplx2 := x+y*i;
        print();
        print( "*** Examples ***" ); freeze;
        print( "cplx1 = " + cplx1 );
        print( "cplx2 = " + cplx2 );
        
        print("");
        print( "modulus( " + cplx1 + ") = " + modulus(cplx1) );
        print( "modulus( " + cplx2 + ") = " + modulus(cplx2) );
        
        print("");
        print( "realpart( " + cplx1 + ") = " + realPart(cplx1) );
        print( "realpart( " + cplx2 + ") = " + realPart(cplx2) );
        
        print("");
        print( "imagpart( " + cplx1 + ") = " + imagPart(cplx1) );
        print( "imagpart( " + cplx2 + ") = " + imagPart(cplx2) );
        print("");
        print( "conjugat( " + cplx1 + ") = " + conjugat(cplx1) );
        print( "conjugat( " + cplx2 + ") = " + conjugat(cplx2) );
        
        print("");
        print("RADIAN");
        setMode_angle( "RADIAN" );
        print( "polarRθtoCartXY( 5, 0.927295218002_r ) = " + polarRθtoCartXY( 5, 0.927295218002) );
        print( "cartArg( 3, 4 ) = " + cartArg( 3, 4 ) );
        print( "argument( " + cplx1 + ") = " + approx( argument(cplx1) ) );
        
        print("");
        print("DEG");        
        setMode_angle( "DEG" );
        print( "polarRθtocartXY( 5, 53.1301023542_° ) = " + polarRθtoCartXY( 5, 53.1301023542) );
        print( "cartArg( 3, 4 ) = " + cartArg( 3, 4) );
        print( "argument( " + cplx1 + ") = " + approx( argument(cplx1) ) );
        
        freeze;
        
        return "Done";
    end;

#end // endCAS

//#home //  no CAS functions
    export getMode_angle()
    begin
        if AAngle == 1 then
            return( "RADIAN" );
        else
            if AAngle == 2 then
                return( "DEG" );
            else 
              return( "SYS_ANGLE" );
            end;
        end;
    end;
    
    export setMode_angle( angle_mode )
    begin
        if angle_mode == "RADIAN" then
            AAngle := 1
        else
            if angle_mode == "DEG" then
                AAngle := 2
            else 
              AAngle := 0
            end;
        end;
    end;
//#end;


/!\ The getMode_angle function can not be defined in CAS MODE, requires be outside, in the above code if I move the instruction (#end) to end, the code generates an error and does not say that part, I take long time to discover.


I'm happy with the evolution of the HP-Prime =), the issue is time.

I think the more power is more complex programming
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Error Msg : Unmatch control word - compsystems - 01-06-2015 12:27 AM
RE: Error Msg : Unmatch control word - Han - 01-06-2015, 01:20 PM



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