HP Forums
Z EDITOR: the last word in on-Prime editors - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Z EDITOR: the last word in on-Prime editors (/thread-4672.html)



Z EDITOR: the last word in on-Prime editors - StephenG1CMZ - 09-08-2015 08:12 AM

The ZED editor aims to provide functionality lacking in HP's own on-Prime editor.

The main functionality of this early release is to allow searching for strings - useful if you are having trouble remembering which file your procedure is in.

It works for both Notes and Programs.

Update: actually, "Z editor" fits much nicer on-screen -
I think I may change the name slightly at the next update.
Update: I have renamed the thread...

Code:

Version 0.2 deleted as it could stall the Android calculator.



RE: Z EDITOR: the last word in on-Prime editors - StephenG1CMZ - 09-09-2015 05:02 PM

Version 0.2 was found to cause a stall of the Android version when using PRINT EXPR to print files to the Terminal, and has now been deleted. No reports from other versions were received.

This was subsequently found to be caused by PRINTing a large file.
For future reference, A workaround would be to print the file in segments.


RE: Z EDITOR: the last word in on-Prime editors - StephenG1CMZ - 09-14-2015 02:54 PM

Here is Z EDITOR V0.3.
It drops the PRINT TERM FILE technology that i, at least, found problematic in V0.2.

Z EDITOR allows on-Prime searching and line numbering of Notes and Programs.
there is a programming bug: if you do two searches, you may see some results from your 1st search appended to the 2nd. Despite this, the program is useful for finding where your variables are used.
Code:


//ZED
//IDENT
 LOCAL ZED:="Z EDITOR V0_3 ";
 LOCAL CRID:=ZED+"© 2015 StephenG1CMZ";
//

 LOCAL LF:=CHAR(10),SP:=" ";
 
 // STR
 LOCAL NWS:=" Not Working ";
 LOCAL ESCS:="TAP Esc TO CONTINUE";
 LOCAL ZFTYPS:={"ABOUT","INFO","HELP","Notes","Programs"};
 LOCAL ACTIONS:={"ANALYZE","FIND_SEARCH","SEARCHALL","VIEW","SEND","REPLACE"};
 LOCAL MECALL:=LF+"CONTACT StephenG1CMZ"+LF;
 EXPORT ZSRCHD;
 EXPORT ZSL;
 EXPORT ZLL:={0};
 EXPORT ZVL:={};

 LOCAL ZFTYPN,ZFN;
 LOCAL SRC,CNT;
 
 //

 BUSZY()
 BEGIN
  DRAWMENU("© 2015","G1CMZ","(BUSY)");
 END;

 GRNTCK ()
 BEGIN
  TEXTOUT_P("✔",G0,0,0,0,#FF00h,100,#0h);  
 END;

 ANLZ (ZFNAME,TXT)
 BEGIN
  LOCAL CH,I;
  
  BUSZY();
  ZLL:={};
  CNT:=1;
 
  FOR I FROM 1 TO SIZE(TXT) DO
   CH:=MID(TXT,I,1);  
   IF CH == LF THEN
    CNT:=CNT+1;
    ZLL(CNT):=I;
   END;
  END;
 END;
 //ANLZ AND SEARCHALL(LF) DO
 //A SIMILAR JOB

 ANALYZE (ZFNAME,TXT,CNT)
 BEGIN
 LOCAL SZ:=SIZE(TXT); 
 LOCAL SZS:=ZFNAME+LF+SZ+" CHARS "+LF+2*SZ+" BYTES"+LF; 
  MSGBOX(SZS+CNT+" LINES"+LF,1); 
 END;

 LINES(P)
 BEGIN
  LOCAL LC:=0;
  REPEAT 
  LC:=LC+1;
  UNTIL ZLL(LC)≥P  OR LC==SIZE(ZLL) ;
  RETURN LC; 
 END;

 CHSLIN(ZSL)
 BEGIN
  LOCAL TTL:=SIZE(ZSL)+" FOUND";
  LOCAL Q;

  IF SIZE(ZSL)>0 THEN
   CHOOSE(Q,TTL,ZSL);
  ELSE //WA.CHOOSE
    // 0 FOUND NEEDS NO TRANSLATION
    MSGBOX(TTL,1);
  END;
 END;

 VIEWER(ZFNAME,TXT) //NOT HP VIEW
 BEGIN
  LOCAL Z_EDITOR_VIEW:={};
  LOCAL I,ST,LO,HI,SZ;
  LOCAL FRAG:="NB: YOU MAY SEE OLD RESULTS APPENDED TO YOURS";
  LOCAL SVS:="SEARCH BEFORE VIEWING PLEASE";
 
  IF ZSRCHD THEN
   MSGBOX(" EDITING"+NWS+LF+FRAG,1);
   IF 1 THEN
    //ALWAYS INCLUDE 1ST LINE
    ST:=MID(TXT,1,ZLL(2));
    ZVL(1):=ST;

    FOR I:=1 TO SIZE(ZSL) DO
     LO:=ZLL(ZSL(I));
     IF (ZSL(I)+1)≤SIZE(ZLL) THEN
      HI:=ZLL(ZSL(I)+1);
     ELSE
      HI:=SIZE(TXT);
     END;
     SZ:=HI-LO;
  // MSGBOX("LO"+LO+LF+"HI"+HI);
     ST:=MID(TXT,LO,SZ);
  // MSGBOX("ST"+ST);
  // ZVL(I+1):=ST;
     ZVL(I+1):={ZSL(I),ST}
    END;
 
    Z_EDITOR_VIEW:=ZVL; //NICE NAME
    EDITLIST(Z_EDITOR_VIEW);
   END;
  ELSE
   MSGBOX(SVS,1);
  END;  
 END;

 SEARCHONE(ZFNAME,TXT)
 BEGIN
  LOCAL TTL:=CRID;
  LOCAL LBL:="FIND 1ST";
  LOCAL HLP:=ZFNAME;
  LOCAL IN:="";
  LOCAL W,P;
  LOCAL ZSL:={};

  W:=INPUT(IN,TTL,LBL,HLP,"","");
  IF W THEN
   BUSZY(); // ZSRCHD:=1;
   P:=INSTRING(TXT,IN);
   IF P THEN
    ZSL(1):=LINES(P)-1;
   END;
   CHSLIN(ZSL);
  END;
  
 END;

 SEARCHALL (ZFNAME,TXT)
 BEGIN
  LOCAL TTL:=CRID;
  LOCAL LBL:="FIND ALL";
  LOCAL HLP:=ZFNAME;
  LOCAL IN:="";
  LOCAL SZ:=SIZE(TXT);
  LOCAL W,P,PREL;
  LOCAL NFND;

  W:=INPUT(IN,TTL,LBL,HLP,"","");
  IF W THEN
   BUSZY(); ZSRCHD:=1;
   // ANLZ(ZFNAME,TXT);
   IF SIZE(IN)==0 THEN
    IN:=LF; //AVOID MATCH ALL
   END;
  
   P:=1; 
   ZSL:={}; NFND:=0;
 
   REPEAT
     PREL:=INSTRING(MID(TXT,P),IN);
     IF PREL THEN
      P:=P+PREL;
      NFND:=NFND+1;
      IF NFND==1 THEN
       GRNTCK;
      END;
      ZSL(NFND):=LINES(P-1)-1;
   // MSGBOX(LINES(P-1));
      ELSE
      //PRINT("ZERO");
     END;
   UNTIL PREL==0 OR P>SZ;

   CHSLIN(ZSL);
  END;
 END;

 ZSEND()
 BEGIN
 MSGBOX("CONNECTIVITY"+NWS+LF+MECALL+
  "FOR SUPPORT");
 END;

 ZREPL (ZFNAME,TXT)
 BEGIN
  MSGBOX(NWS);
 END;

 DOACTN (Q,ZFNAME)
 BEGIN
  
  CASE
  IF Q==1 THEN ANALYZE(ZFNAME,SRC,CNT) END;
  IF Q==2 THEN SEARCHONE(ZFNAME,SRC) END;
  IF Q==3 THEN SEARCHALL(ZFNAME,SRC) END;
  IF Q==4 THEN VIEWER(ZFNAME,SRC) END;

  IF Q==5 THEN ZSEND(); END;
  IF Q==6 THEN ZREPL(ZFNAME,SRC); END;

  //IF Q==2 THEN  END;
  DEFAULT
  END;

 END;

 ZEDF(ZFTYPE,ZF)
 BEGIN
  LOCAL Q;
  LOCAL ZFNAME:=ZFTYPE+"("+ZF+")";
  LOCAL ZFD:=ZFNAME+SP+SIZE(EXPR(ZFNAME))+" BYTES";
 
  // ANLZ EARLY
  SRC:=EXPR(ZFNAME);
  ANLZ(ZFNAME,SRC);
  ZSRCHD:=0;
  WHILE
   CHOOSE(Q,ZFNAME,ACTIONS) DO 
    DOACTN(Q,ZFNAME);
  END;
 END;

 ZEDCHSF(ZFTYPE)
 BEGIN
  LOCAL ZFILES:=EXPR(ZFTYPE);
  LOCAL LBL:=SIZE(ZFILES)+SP+ZFTYPE;
   
  IF SIZE(ZFILES)>0 THEN //WA.CHOOSE
   WHILE
    CHOOSE(ZFN,LBL,ZFILES) DO 
     ZEDF(ZFTYPE,STRING(ZFILES(ZFN))); 
    END;
  ELSE //WA.CHOOSE
   MSGBOX(0+SP+ZFTYPE,1); //EMPTY DIR
  END;
 END;

 ABOUT
()
  BEGIN
   LOCAL AS:="StephenG1CMZ is a software developer and systems tester. He would be happy to work to your requirements.";
   
   LOCAL AZ:="Z EDITOR is StephenG1CMZ's first HP Prime program. ";
 
 PRINT(); PRINT(CRID+LF);
 PRINT(AS+LF+LF+AZ+LF+LF+ESCS)
;
 WAIT;
 END;

 INFO()
 BEGIN
  LOCAL LS:="Legal: No liability is accepted and in any event will be limited to the amount paid for this program.";
 
  PRINT(); PRINT(CRID+LF);
  PRINT(LF+LS+LF+ESCS);
  WAIT;
 END;

 HELP()
 BEGIN
  LOCAL Q;
  LOCAL SR:="Search: ✔==FOUND 
To select all lines: search for Enter or OK."; 
  LOCAL VS:="Viewer:  
you might find the line numbering of the text useful. 
First search to populate the selected lines."; 
  LOCAL EAR:="Editing and Replacement: 
Not implemented yet.";  
  LOCAL EV:= "Exported variables:
ZLL: list of line feeds.
ZSL: list of selected line numbers. 
(Multiple matches on one line appear multiple times)";
  LOCAL ISH:="known issues:
REFER TO FORUM FOR LATEST";
  LOCAL TTL:="HELP";
  LOCAL HLPSEL:={"TIPS","VARS","SUPPORT"};
 
  WHILE CHOOSE(Q,TTL,HLPSEL) DO  
   PRINT(); PRINT(CRID);
   CASE
    IF Q==1 THEN  
     PRINT(SR+LF+VS+LF+EAR+LF);
     END;
    IF Q==2 THEN
     PRINT(EV+LF);
     END;
    IF Q==3 THEN
     PRINT(ISH+LF);
     END;
    DEFAULT
   END;
    PRINT(ESCS);
    WAIT;
  END;
 END;

 ZEDCHSFTYP()
 BEGIN
  LOCAL LBL:=CRID;
  WHILE  
   CHOOSE(ZFTYPN,LBL,ZFTYPS) DO
     CASE
      IF ZFTYPN==1 THEN ABOUT() END;
      IF ZFTYPN==2 THEN INFO() END;
      IF ZFTYPN==3 THEN HELP() END;
      DEFAULT
       BUSZY();
       ZEDCHSF(ZFTYPS(ZFTYPN));
      END;
   END;
 END;

 ZEDDO()
 BEGIN
   ZEDCHSFTYP(); 
 END;

 ZEDBYE()
 BEGIN
  LOCAL T:=LF+"THANKS FOR USING"+LF+ZED+LF;
  LOCAL G:="BY StephenG1CMZ";
  RETURN T+G;
 END;

EXPORT ZED_EDITOR()
BEGIN
 ZEDDO();
 RETURN ZEDBYE();
END;

There is a problem with INPUT. some inputs are interpreted by the Prime. For example, if you ask for an opening bracket, INPUT gives you a pair. So you can search for WAIT(), for example, but not wait(1. Does anyone have a fix for this?