Post Reply 
(newRPL) Toggle Rectangular / Polar Display
06-12-2019, 10:23 PM
Post: #1
(newRPL) Toggle Rectangular / Polar Display
This is a little library implementing a toggle which alternates display of complex number on level 1 of the stack in rectangular or polar coordinate system.

It takes advantage of the possibility to assign new definitions not only to keys, but also to events associated to a key such as "key pressed" or "key released".

In particular, given a complex number on level 1, if the toggle key is pressed, and as long as it is pressed, its representation will switch to rectangular if originally in polar and vice versa.

When the toggle key is released, it will switch back to normal.

The library consists of two commands: "INSTTOG" and "UNINSTTOG" which, as their name suggest, are used to bind/unbind the toggle to your favourite key.

Both commands accept a string description of they key to which the toggle is associated, in the ASKKEY command format.

For example, if you want to associate the toggle to unshifted "." (dot) you must run

Code:

"DT." INSTTOG

To uninstall the toggle

Code:

"DT." UNINSTTOG

Here is the code of the library

Code:

"TOGGLE RECT/POLAR DISPLAY v1.0
(c) Stefano Priore 2019"
'$TITLE' STO

{ }
'$IGNORE' STO

{
  { 'INSTTOG' 1 0 "Bind toggle to a key
S →" }
{ 'UNINSTTOG' 1 0 "Remove toggle asn from key
S →" }
}
'$VISIBLE' STO

'TRPD'
'$LIBID' STO

«
  → 
    k « k IF 
     DUPDUP TYPE
     24 == SWAP "" ≠
     AND 
    THEN
     DUP ASSN 1 GET SWAP
     ".L" + 0 ASNKEY
     ASSN 2 GET SWAP
     ".U" + 0 ASNKEY
     0 KSTO 0 TSTO 
    ELSE
      24 DOERR 
    END
  »
»
'INSTTOG' STO

«
  → 
    k « k IF DUPDUP TYPE
    24 == SWAP "" ≠
    AND THEN
      DUP ".L" + DELKEY
      ".U" + DELKEY 
    ELSE
      24 DOERR 
    END
  »
»
'UNINSTTOG' STO

{ :: 
    IF 
     DEPTH
    THEN 
     IF 
      DUP TYPE 30 == 
     THEN 
      IF 
       DUP TYPEE FP 
      THEN 
       DUP TSTO 1 KSTO →RECT 
      ELSE 
       DUP TSTO 1 KSTO →POLAR 
      END 
     END 
    END 
  ;
  
  :: 
    IF 
     KRCL
    THEN
     DROP TRCL 0 KSTO 
    END 
  ;
}
'ASSN' STO

«
  'KPRESS' LIBSTO 
»
'KSTO' STO

«
  'KPRESS' LIBRCL 
»
'KRCL' STO

«
  'TEMP' LIBSTO 
»
'TSTO' STO

«
  'TEMP' LIBRCL 
»
'TRCL' STO


Attached File(s)
.zip  TRPD.zip (Size: 590 bytes / Downloads: 4)
Find all posts by this user
Quote this message in a reply
09-26-2020, 02:07 PM
Post: #2
RE: (newRPL) Toggle Rectangular / Polar Display
It works perfectly ;D
Find all posts by this user
Quote this message in a reply
Post Reply 




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