Post Reply 
PPLX: A few extras that might have been in PPL
09-09-2019, 08:50 PM
Post: #1
PPLX: A few extras that might have been in PPL
A few little extras that mIght have been included in PPL

Stephen Lewkowicz (G1CMZ)
Visit this user's website Find all posts by this user
Quote this message in a reply
09-09-2019, 08:53 PM (This post was last modified: 09-09-2019 08:54 PM by StephenG1CMZ.)
Post: #2
RE: PPLX: A few extras that might have been in PPL
PPLX v0. 1 provides implementation limits and TYPE's.
Code:

 LOCAL CRID:="PPLX V0.1 © 2019 StephenG1CMZ";
 
 LOCAL NA:="(N/A)"; //NOT APPLICABLE
 LOCAL SP:=" ";

 //Returns the type of the object:
 EXPORT TYPEREAL :=TYPE(3.1); //0: Real
 EXPORT TYPEINT  :=TYPE(#3);  //1: Integer
 EXPORT TYPESTR  :=TYPE("A"); //2: String
 EXPORT TYPECMPLX:=TYPE();   //3: Complex
 EXPORT TYPEMAT  :=TYPE([1]); //4: Matrix
 (inc vector)
 EXPORT TYPEERR  :=5;         //5: Error
 EXPORT TYPELST  :=TYPE({});  //6: List
 (inc set)
 EXPORT TYPECAS  :=TYPE(CAS("nop")); //7 CAS
 EXPORT TYPEFUN  :=TYPE('X'); //8: Function
 EXPORT TYPEUNIT :=TYPE(1_m); //9: Unit
 //14.?: cas object. The fractional part is the cas type.
 EXPORT ALLTYPES :={TYPEREAL,TYPEINT,TYPESTR,TYPECMPLX,TYPEMAT,TYPEERR,TYPELST,TYPECAS,TYPEF​UN,TYPEUNIT};  
 EXPORT TYPEIDS  :={"HomeSet_Real","HomeSet_Integers","Main_String","HomeSet_Complex","HomeSet_Matrix","AppData_ErrorPrefix","HomeSet_List","HomeSet_CAS","Program_Function","Units_Unit1"}; //MIXED STRINGFROMID 

 //Implementation Limits-Runtime
 //(Empirical on Android unless stated)
 //NB workarounds may exist, eg to create larger strings
 //EXPORT ImpREAL:={MIN(MAXREAL,CAS(maxreal),MINREAL});
 LOCAL  ImpINTb:=32; //STANDARD. MAX 64
 EXPORT ImpINT:=2^(ImpINTb-1);//{default 32,max 64,Less 1 when signed}
 EXPORT ImpSTR:=32*1024;//64KB
 //EXPORT ImpCMPLX:="TBD"; 
 EXPORT ImpMATSZ:= 20000-1;//TOTAL NUMBER OF ELEMENTS (MAT OR VEC)
  //NOTE: use of mat2list may require ImpLST instead
 EXPORT ImpMATSQ:= 141 ;   //141*141<20000 
 EXPORT ImpLST  := 10000;  //STATED
 EXPORT ImpMATSL:=MIN(ImpMATSZ,ImpLST);//safe limit if mat2list may be invoked 
 EXPORT ImpCHOOSE:=2047;   //EG SEE TOWER OF HANOI
 EXPORT ImpPRINT:=64;//ANDROID LIMIT: 64 MB CHARACTERS
 //Implementation Limits:Compiletime
 LOCAL ImpCASE:=127;//INCLUDES ANY DEFAULT
 EXPORT ALLImps:={{MAXREAL,MINREAL},{ImpINTb,ImpINT,STRINGFROMID("Modes_Standard")},(ImpSTR*2/1024)+" KB "+(ImpSTR)+" "+STRINGFROMID("Chars_Title"),,{ImpMATSQ+"*"+ImpMATSQ,ImpMATSZ},NA,ImpLST,NA,NA,NA,ImpCHOOSE,ImpPRINT+" MB"}; 

 EXPORT ABOUT()
 BEGIN
  PRINT();
  PRINT(CRID);
  PRINT("Useful extras that might have been useful in PPL.");
  PRINT("Note that Implementation Limits may have workarounds.");
  //Many programs need this info
  WAIT;
 END;

 EXPORT TYPENAME(TYPNUM)
 //Return name of TYPE
 BEGIN
  RETURN IFTE(TYPNUM<SIZE(TYPEIDS),STRINGFROMID(TYPEIDS(TYPNUM+1)),STRINGFROMID("Main_InvalidInput"));
 END;

 //UI OUT

 EXPORT STPAD(ST,LNG,DD)
 //CONSTRUCT A PADDED STRING (SPACES)
 //ST TO BE PADDED NOT TRUNCATED
 //LNG IS MINIMUM LENGTH
 //DD: DIRECTION  1 RIGHT −1 LEFT 0 CENTRE
 BEGIN
  LOCAL LL:=ABS(IP(LNG));//INGUARD
  LOCAL SPC:=LL-DIM(ST);
  LOCAL SPTMP:="";

  CASE
  IF DD>0 THEN //PAD R
   RETURN REPLACE(ST,LL+1,"");//SYN:JOE HORN
  END;
  IF DD<0 THEN //PAD L 
   RETURN REPLACE("",SPC+1,ST);
  END; 
  DEFAULT  //PAD C
   SPTMP:=ZPAD("",SPC/2,1);//spaces
   SPTMP:=SPTMP+ST+SPTMP;
   RETURN 
    IFTE(DIM(SPTMP)<LL,SPTMP+" ",SPTMP);//extra space if odd
  END;//CASE
 END;

 EXPORT OutImpLimits()
 //Display Implementation Limits
 BEGIN
  LOCAL II;
  LOCAL LH:=17;//LINEHEIGHT
  LOCAL IDS:=CONCAT(TYPEIDS,"Main_CHOOSE","PRINT");
  RECT_P();
  TEXTOUT_P(STRINGFROMID("Main_Program")+" "+STRINGFROMID("Toolbox_Limits")+" (PPL)",0,0);
  //MSGBOX(IDS(0));
  //PRINT(IDS);WAIT;
  FOR II FROM 1  TO SIZE(ALLImps) DO
   //MSGBOX((IDS(II)));
   TEXTOUT_P((II-1)+" "+STRINGFROMID(IDS(II)),0,LH*II);
   //IF ALLImps(II)≠NANS THEN
    TEXTOUT_P(ALLImps(II),320/3,LH*II);
   //END;
  END;
  TEXTOUT_P("PRINT",20,12*LH);
  WAIT;
 END;

 EXPORT PPLX()
 BEGIN 
  LOCAL ST;
  //PRINT();
  //PRINT(CRID);
  ABOUT();
  IF 0 THEN //TEST ImpPRINT
   ST:=STPAD("ACD",64*1024*1024,1);
   PRINT(DIM(ST)/1024/1024);
   PRINT(ST);
   PRINT("OK");
  END;
 
 END;

Implementation limits were tested on the Android VC: The values applicable to actual calculators and older firmware may differ.

Stephen Lewkowicz (G1CMZ)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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