====== rip_lib.js ======
rip_lib.js is a loadable JavaScript library for Synchronet (in the ''[[dir:exec]]/load'' directory) that provides functions for constructing [[wp>Remote Imaging Protocol|RIPscrip 1.54]] command strings.  RIPscrip (Remote Imaging Protocol) is a graphics protocol used by BBS terminals such as RIPterm to render vector graphics, buttons, and mouse-interactive regions over a serial connection.

To load the library in a Synchronet JavaScript script:
  require("rip_lib.js", "RIPWindow");

RIP command strings are sent to the client by printing them to the terminal, starting on a new line and prefixed with an exclamation mark (''!''). Individual RIP commands begin with the pipe character (''|'') followed by a command character.  The functions in this library return command strings that start with ''|'' (without the leading ''!'') so that multiple commands can be chained together into a single transmission.  When sending commands to the client, the entire batch should be prefixed with ''!''.  For example:
  var cmds = RIPColor("0F") + RIPRectangleNumeric(10, 10, 100, 50);
  console.print("\r!" + cmds + "\r\n");

Most RIP command functions come in two variants:
  * The primary variant (e.g., ''RIPColor'') takes **MegaNum string** parameters — base-36 encoded strings using digits 0–9 and uppercase letters A–Z.
  * The ''...Numeric'' variant (e.g., ''RIPColorNumeric'') takes plain **JavaScript numbers**, which are converted internally to MegaNum strings.

For simple scripts that build commands at runtime with known integer values, the ''...Numeric'' variants are usually more convenient.

====== MegaNum Encoding ======
RIPscrip uses a compact base-36 number encoding called MegaNum, which uses digits 0–9 and uppercase letters A–Z.  A 2-digit MegaNum can hold values 0–1295 (36² − 1).  The library provides utility functions for converting between integers and MegaNum strings.

The coordinate space for most RIPscrip graphics commands is 640×350 pixels (standard EGA resolution).

====== Constants ======

===== Color Constants =====
These numeric constants correspond to RIPscrip's 16-color palette and can be passed to the ''...Numeric'' variants of color-setting functions.
^ Constant                ^ Value ^ Color         ^
| RIP_COLOR_BLACK         | 0     | Black         |
| RIP_COLOR_BLUE          | 1     | Blue          |
| RIP_COLOR_GREEN         | 2     | Green         |
| RIP_COLOR_CYAN          | 3     | Cyan          |
| RIP_COLOR_RED           | 4     | Red           |
| RIP_COLOR_MAGENTA       | 5     | Magenta       |
| RIP_COLOR_BROWN         | 6     | Brown         |
| RIP_COLOR_LT_GRAY       | 7     | Light Gray    |
| RIP_COLOR_DK_GRAY       | 8     | Dark Gray     |
| RIP_COLOR_LT_BLUE       | 9     | Light Blue    |
| RIP_COLOR_LT_GREEN      | 10    | Light Green   |
| RIP_COLOR_LT_CYAN       | 11    | Light Cyan    |
| RIP_COLOR_LT_RED        | 12    | Light Red     |
| RIP_COLOR_LT_MAGENTA    | 13    | Light Magenta |
| RIP_COLOR_YELLOW        | 14    | Yellow        |
| RIP_COLOR_WHITE         | 15    | White         |

===== Font Constants =====
These numeric constants identify the available RIPscrip fonts and can be passed to ''RIPFontStyleNumeric''.
^ Constant            ^ Value ^ Font                     ^ Type       ^
| RIP_FONT_DEFAULT    | 0     | Default 8×8 font         | Bit-mapped |
| RIP_FONT_TRIPLEX    | 1     | Triplex Font             | Scalable   |
| RIP_FONT_SMALL      | 2     | Small Font               | Scalable   |
| RIP_FONT_SANS_SERIF | 3     | Sans Serif Font          | Scalable   |
| RIP_FONT_GOTHIC     | 4     | Gothic (Old English) Font| Scalable   |
| RIP_FONT_SCRIPT     | 5     | Script Font              | Scalable   |
| RIP_FONT_SIMPLEX    | 6     | Simplex Font             | Scalable   |
| RIP_FONT_TRIPLEX    | 7     | Triplex Script Font      | Scalable   |
| RIP_FONT_COMPLEX    | 8     | Complex Font             | Scalable   |
| RIP_FONT_EUROPEAN   | 9     | European Font            | Scalable   |
| RIP_FONT_BOLD       | 10    | Bold Font                | Scalable   |

===== Button Style Flag Constants =====
These bit-flag constants are combined (with bitwise OR) and passed to ''RIPButtonStyleNumeric'' as the ''pFlags'' parameter.
^ Constant                          ^ Value ^ Description                              ^
| RIP_BTN_STYLE_CLIPBOARD           | 1     | Button is a "Clipboard Button"           |
| RIP_BTN_STYLE_INVERTABLE          | 2     | Button is "Invertable"                   |
| RIP_BTN_STYLE_RESET_AFTER_CLICK   | 4     | Reset screen after button click          |
| RIP_BTN_STYLE_CHISEL_EFFECT       | 8     | Display Chisel special effect            |
| RIP_BTN_STYLE_RECESSED            | 16    | Display Recessed special effect          |
| RIP_BTN_STYLE_DROPSHADOW_LBL      | 32    | Dropshadow the label (if any)            |
| RIP_BTN_STYLE_AUTOSTAMP_IMG_CLIPBRD | 64  | Auto-stamp image onto Clipboard          |
| RIP_BTN_STYLE_ICON                | 128   | Button is an "Icon Button"               |
| RIP_BTN_STYLE_PLAIN               | 256   | Button is a "Plain Button"               |
| RIP_BTN_STYLE_BEVEL               | 512   | Display Bevel special effect             |
| RIP_BTN_STYLE_MOUSE               | 1024  | Button is a Mouse Button                 |
| RIP_BTN_STYLE_UNDERLINE_HOTKEY    | 2048  | Underline hot-key in label               |
| RIP_BTN_STYLE_ICON_HOT_ICONS      | 4096  | Make Icon Button use Hot Icons           |
| RIP_BTN_STYLE_ADJ_VERT_CENTERING  | 8192  | Adjust vertical centering of label       |
| RIP_BTN_STYLE_RADIO_GROUP         | 16384 | Button belongs to a Radio Group          |
| RIP_BTN_STYLE_SUNKEN              | 32768 | Display Sunken special effect            |

====== Utility Functions ======
These are helper functions for working with RIPscrip MegaNum values and coordinate arrays.
^ Name                       ^ Returns ^ Signature                                                                         ^ Description ^
| toMegaNum                  | string  | toMegaNum(val, width)                                                             | Converts a non-negative integer to a base-36 MegaNum string of the specified width (zero-padded on the left). |
| fromMegaNum                | number  | fromMegaNum(megaStr)                                                              | Converts a MegaNum string back to an integer.  Throws an error if the string contains invalid characters. |
| isValidRIPMegaNumStr       | boolean | isValidRIPMegaNumStr(pStr)                                                        | Returns true if the string contains only digits 0–9 and uppercase letters A–Z (a valid MegaNum string). |
| getMaxMegaNumValue         | number  | getMaxMegaNumValue(pNumDigits)                                                    | Returns the maximum integer value representable by a MegaNum string of the given number of digits (36ⁿ − 1). |
| zeroPadStr                 | string  | zeroPadStr(pStr, pPaddedStrLen)                                                   | Zero-pads a string to the specified length, truncating if the string is too long. |
| verifyMegaNumStr           | string  | verifyMegaNumStr(pNumStr, pMaxLen, pDefault)                                      | Validates and sanitizes a MegaNum string, returning it zero-padded to ''pMaxLen'' digits.  Returns ''pDefault'' if the input is invalid. |
| filterArrayOfXYPoints      | array   | filterArrayOfXYPoints(pXYPoints, pNumMegaNumDigits)                               | Filters an array of ''{ x, y }'' point objects, keeping only those whose x and y values fit in a MegaNum of the given digit count. |
| getRIPCmdWithArrayOfXYPts  | string  | getRIPCmdWithArrayOfXYPts(pRIPCmd, pXYPoints, pNumDigitsForNPoints, pNumDigitsForPoints) | Builds a RIP command string for commands that take a variable number of XY coordinate pairs (used internally by the polygon/polyline functions). |

====== RIP Command Functions ======
All RIP command functions return a string beginning with ''|''.  These strings are meant to be concatenated and then transmitted to the client, preceded by ''!'' at the start of the line.

For each function listed below that takes MegaNum string parameters, there is a corresponding ''...Numeric'' variant that accepts plain JavaScript integers instead.  For example, ''RIPLine'' takes MegaNum strings; ''RIPLineNumeric'' takes integers.  The ''...Numeric'' functions are not listed separately unless they are the only variant available (as with the polygon/polyline functions).

===== Window and Cursor Commands =====
These commands control the text and graphics windows, the cursor, and the viewport.
^ Name                  ^ Returns ^ Signature                                            ^ Description ^
| RIPKillMouseFields    | string  | RIPKillMouseFields()                                 | Destroys all previously defined hot mouse regions (Level 1, command ''|1K'').  Use at the beginning of each scene so mouse regions from the previous scene are cleared. |
| RIPResetWindows       | string  | RIPResetWindows()                                    | Resets the text and graphics windows to full screen, clears both windows, deletes all mouse regions and buttons, erases the Clipboard, and restores the default 16-color palette (Level 0, command ''|*''). |
| RIPEraseTextWindow    | string  | RIPEraseTextWindow()                                 | Clears the TTY text window to the current graphics background color and moves the cursor to the upper-left corner (Level 0, command ''|e''). |
| RIPEraseGraphicsWindow| string  | RIPEraseGraphicsWindow()                             | Clears the graphics viewport to the current background color (Level 0, command ''|E''). |
| RIPHome               | string  | RIPHome()                                            | Moves the text cursor to the upper-left corner of the text window (Level 0, command ''|H''). |
| RIPEraseEOL           | string  | RIPEraseEOL()                                        | Erases the current text line from the cursor position to the end of the line (Level 0, command ''|>''). |
| RIPGotoXY             | string  | RIPGotoXY(pX, pY)                                    | Moves the text cursor to the specified column (pX) and row (pY) in the text window.  Coordinates are 0-based (Level 0, command ''|g'').  Also: ''RIPGotoXYNumeric(pX, pY)''. |
| RIPWindow             | string  | RIPWindow(pX0, pY0, pX1, pY1, pWrap, pSize)          | Defines the position and size of the TTY text window in text-cell coordinates.  Setting all parameters to zero hides the window.  ''pWrap'' enables text wrapping; ''pSize'' selects the font size (Level 0, command ''|w'').  Also: ''RIPWindowNumeric''. |
| RIPViewport           | string  | RIPViewport(pX0, pY0, pX1, pY1)                      | Sets the graphics viewport boundaries in pixel coordinates (640×350 coordinate space).  Graphics outside the viewport are clipped.  Setting all parameters to zero disables the viewport (Level 0, command ''|v'').  Also: ''RIPViewportNumeric''. |

===== Drawing State Commands =====
These commands change the current drawing color, fill color, line style, font, and write mode used by subsequent drawing operations.
^ Name           ^ Returns ^ Signature                                   ^ Description ^
| RIPWriteMode   | string  | RIPWriteMode(pMode)                         | Sets the drawing write mode.  ''pMode'' is a number: 0=normal overwrite, 1=XOR mode (drawing the same item a second time erases it) (Level 0, command ''|W''). |
| RIPColor       | string  | RIPColor(pColor)                            | Sets the current drawing color (foreground color for lines, arcs, rectangles, and graphics text).  Does not affect fill color (Level 0, command ''|c'').  Also: ''RIPColorNumeric(pColor)''. |
| RIPFontStyle   | string  | RIPFontStyle(pFont, pDirection, pSize, pRes) | Sets the current font, orientation, and size for ''RIPText''/''RIPTextXY'' commands.  ''pDirection'': ''00''=horizontal, ''01''=vertical.  ''pSize'': ''01''=normal, ''02''=2× magnification, ..., ''0A''=10× (Level 0, command ''|Y'').  Also: ''RIPFontStyleNumeric''. |
| RIPLineStyle   | string  | RIPLineStyle(pStyle, pUserPattern, pThickness) | Defines the line pattern and thickness.  Built-in styles: 00=solid, 01=dotted, 02=centered, 03=dashed, 04=custom (uses ''pUserPattern'' as a 16-bit pattern).  ''pThickness'': 01=1px, 03=3px (Level 0, command ''|='').  Also: ''RIPLineStyleNumeric''. |
| RIPFillStyle   | string  | RIPFillStyle(pPattern, pColor)              | Sets the fill pattern (00–0B predefined) and fill color for subsequent fill operations (Level 0, command ''|S'').  Also: ''RIPFillStyleNumeric''. |
| RIPFilPattern  | string  | RIPFilPattern(pC1, pC2, pC3, pC4, pC5, pC6, pC7, pC8, pcCol) | Defines a custom 8×8 pixel fill pattern.  Each ''pC1''–''pC8'' parameter is a 2-digit MegaNum bit-pattern for one row (top to bottom).  ''pcCol'' is the fill color (Level 0, command ''|s'').  Also: ''RIPFilPatternNumeric''. |

===== Palette Commands =====
These commands change the 16-color RIP display palette by selecting colors from the master 64-color EGA palette.
^ Name              ^ Returns ^ Signature                                              ^ Description ^
| RIPSetPalette     | string  | RIPSetPalette(pC1, pC2, ..., pC16)                     | Sets all 16 palette entries at once.  Each parameter is a 2-digit MegaNum string selecting a color from the 64-color master EGA palette (0–63).  Screen colors update immediately (Level 0, command ''|Q'').  Also: ''RIPSetPaletteNumeric''. |
| RIPOnePalette     | string  | RIPOnePalette(pColor, pValue)                          | Changes a single entry in the 16-color palette.  ''pColor'' is the palette index (0–15); ''pValue'' is the master EGA palette color code (0–63) (Level 0, command ''|a'').  Also: ''RIPOnePaletteNumeric''. |

===== Drawing Commands =====
These commands draw graphics primitives.  Unless noted otherwise, they use the current drawing color, line style, write mode, and viewport settings.
^ Name                    ^ Returns ^ Signature                                                           ^ Description ^
| RIPMove                 | string  | RIPMove(pX, pY)                                                     | Moves the graphics drawing cursor to (pX, pY) without drawing anything.  Used to set the starting position for ''RIPText'' (Level 0, command ''|m'').  Also: ''RIPMoveNumeric''. |
| RIPPixel                | string  | RIPPixel(pX, pY)                                                    | Draws a single pixel in the current drawing color at (pX, pY) (Level 0, command ''|X'').  Also: ''RIPPixelNumeric''. |
| RIPLine                 | string  | RIPLine(pX0, pY0, pX1, pY1)                                        | Draws a line from (pX0, pY0) to (pX1, pY1) using the current drawing color, line style, and thickness (Level 0, command ''|L'').  Also: ''RIPLineNumeric''. |
| RIPRectangle            | string  | RIPRectangle(pX0, pY0, pX1, pY1)                                   | Draws an unfilled rectangle using the current drawing color, line style, and thickness.  (pX0,pY0) and (pX1,pY1) are any two opposing corners (Level 0, command ''|R'').  Also: ''RIPRectangleNumeric''. |
| RIPBar                  | string  | RIPBar(pX0, pY0, pX1, pY1)                                         | Draws a filled rectangle using the current fill color and fill pattern.  No border is drawn (Level 0, command ''|B'').  Also: ''RIPBarNumeric''. |
| RIPCircle               | string  | RIPCircle(pXCenter, pYCenter, pRadius)                              | Draws a circle with the given center and radius in the current drawing color and line thickness.  Aspect-ratio corrected for EGA 640×350 resolution (Level 0, command ''|C'').  Also: ''RIPCircleNumeric''. |
| RIPOval                 | string  | RIPOval(pX, pY, pStartAng, pEndAng, pXRad, pYRad)                  | Draws an elliptical arc.  Center at (pX, pY); arc drawn counterclockwise from ''pStartAng'' to ''pEndAng'' (0=3 o'clock, 90=12 o'clock).  ''pXRad''×''pYRad'' are the semi-axes (Level 0, command ''|O'').  Also: ''RIPOvalNumeric''. |
| RIPFilledOval           | string  | RIPFilledOval(pXCenter, pYCenter, pXRad, pYRad)                     | Draws a complete filled ellipse.  Interior filled with current fill color/pattern; outline drawn with current drawing color and line thickness (Level 0, command ''|o'').  Also: ''RIPFilledOvalNumeric''. |
| RIPArc                  | string  | RIPArc(pX, pY, pStartAng, pEndAng, pRadius)                        | Draws a circular arc from ''pStartAng'' counterclockwise to ''pEndAng'' (0=3 o'clock, 90=12 o'clock).  Aspect-ratio aware (Level 0, command ''|A'').  Also: ''RIPArcNumeric''. |
| RIPOvalArc              | string  | RIPOvalArc(pX, pY, pStartAng, pEndAng, pRadX, pRadY)               | Draws an elliptical arc (like ''RIPOval'' but without aspect-ratio correction) (Level 0, command ''|V'').  Also: ''RIPOvalArcNumeric''. |
| RIPPieSlice             | string  | RIPPieSlice(pX, pY, pStartAng, pEndAng, pRadius)                   | Draws a circular pie slice.  Arc ends are connected to the center with two straight lines; interior filled with current fill color/pattern (Level 0, command ''|I'').  Also: ''RIPPieSliceNumeric''. |
| RIPOvalPieSlice         | string  | RIPOvalPieSlice(pX, pY, pStartAng, pEndAng, pRadX, pRadY)          | Draws an elliptical pie slice (filled) (Level 0, command ''|i'').  Also: ''RIPOvalPieSliceNumeric''. |
| RIPBezier               | string  | RIPBezier(pX1, pY1, pX2, pY2, pX3, pY3, pX4, pY4, pCnt)           | Draws a Bezier curve.  Start=(pX1,pY1), end=(pX4,pY4), control points=(pX2,pY2) and (pX3,pY3).  ''pCnt'' is the number of segments (more = smoother) (Level 0, command ''|Z'').  Also: ''RIPBezierNumeric''. |
| RIPPolygonNumeric       | string  | RIPPolygonNumeric(pXYPoints)                                        | Draws an unfilled closed polygon.  ''pXYPoints'' is an array of ''{ x, y }'' objects.  Always takes numeric values (Level 0, command ''|P''). |
| RIPFillPolygonNumeric   | string  | RIPFillPolygonNumeric(pXYPoints)                                    | Like ''RIPPolygonNumeric'' but the interior is filled with the current fill color/pattern (Level 0, command ''|p''). |
| RIPPolyLineNumeric      | string  | RIPPolyLineNumeric(pXYPoints)                                       | Draws an open multi-segment line (last point is NOT connected back to the first).  ''pXYPoints'' is an array of ''{ x, y }'' objects (Level 0, command ''|l''). |
| RIPFill                 | string  | RIPFill(pX, pY, pBorder)                                           | Performs a flood fill starting at (pX, pY), spreading until the ''pBorder'' color is encountered.  Fills with the current fill color and pattern (Level 0, command ''|F'').  Also: ''RIPFillNumeric''. |

===== Text Commands =====
These commands draw text in the graphics viewport using the current font, drawing color, and write mode.
^ Name        ^ Returns ^ Signature                 ^ Description ^
| RIPText     | string  | RIPText(pText)            | Draws ''pText'' at the current graphics drawing position (as set by ''RIPMove'' or ''RIPTextXY'').  The drawing position advances to the end of the last character drawn (Level 0, command ''|T''). |
| RIPTextXY   | string  | RIPTextXY(pX, pY, pText)  | Combines ''RIPMove'' and ''RIPText'': draws ''pText'' at the specified (pX, pY) position in the current font, color, and write mode (Level 0, command ''|@'').  Also: ''RIPTextXYNumeric''. |

===== Mouse and Button Commands =====
These Level 1 commands define interactive mouse regions and graphical buttons.
^ Name              ^ Returns ^ Signature                                                                                 ^ Description ^
| RIPMouse          | string  | RIPMouse(pNum, pX0, pY0, pX1, pY1, pClk, pClr, pRes, pText)                              | Defines a rectangular hot mouse region.  When clicked, sends ''pText'' to the host (use ''^M'' for carriage return).  ''pClk'': visually invert region while clicked; ''pClr'': clear screen on click.  Maximum 128 regions per scene (Level 1, command ''|1M'').  Also: ''RIPMouseNumeric''. |
| RIPButtonStyle    | string  | RIPButtonStyle(pWidth, pHeight, pLabelOrientation, pFlags, pBevelSize, pTxtLblDFore, pTxtLblDBack, pBright, pDark, pSurface, pGrpNum, pFlags2, pULineCol, pCornerCol, pRes) | Defines how subsequent ''RIPButton'' commands will be rendered.  Sets button type (icon/clipboard/plain), visual effects, label orientation, colors, and radio group assignment.  Does not draw anything (Level 1, command ''|1B'').  Also: ''RIPButtonStyleNumeric''. |
| RIPButton         | string  | RIPButton(pX0, pY0, pX1, pY1, pHotkey, pFlags, pRes, pTextStrs, pHostCmd)                | Creates a button using the most recent ''RIPButtonStyle'' definition.  ''pHotkey'' is the ASCII code of the activation key (''FF''=any key).  ''pTextStrs'' is an array of strings for the icon filename, text label, and host command (Level 1, command ''|1U'').  Also: ''RIPButtonNumeric''. |

===== Text Region Commands =====
These Level 1 commands define a rectangular region for rendering pre-formatted text.
^ Name            ^ Returns ^ Signature                             ^ Description ^
| RIPBeginText    | string  | RIPBeginText(pX1, pY1, pX2, pY2, pRes) | Defines a rectangular portion of the graphics viewport for displaying text.  Follow with one or more ''RIPRegionText'' commands and terminate with ''RIPEndText''.  Text that overflows the bottom is discarded (Level 1, command ''|1T'').  Also: ''RIPBeginTextNumeric''. |
| RIPRegionText   | string  | RIPRegionText(pJustify, pText)          | Displays a pre-formatted line of text inside the region defined by ''RIPBeginText''.  ''pJustify'': false=left-align, true=full left/right justification (Level 1, command ''|1t''). |
| RIPEndText      | string  | RIPEndText()                            | Terminates the text block started by ''RIPBeginText'' (Level 1, command ''|1E''). |

===== Image Commands =====
These Level 1 commands work with the terminal's internal Clipboard for copying, pasting, saving, and loading icon images.
^ Name               ^ Returns ^ Signature                                                      ^ Description ^
| RIPGetImage        | string  | RIPGetImage(pX0, pY0, pX1, pY1, pRes)                         | Copies the rectangular screen region (pX0,pY0)–(pX1,pY1) to the internal Clipboard (Level 1, command ''|1C'').  Also: ''RIPGetImageNumeric''. |
| RIPPutImage        | string  | RIPPutImage(pX, pY, pMode, pRes)                               | Pastes the Clipboard contents at (pX, pY).  Mode: 00=COPY, 01=XOR, 02=OR, 03=AND, 04=NOT (inverse) (Level 1, command ''|1P'').  Also: ''RIPPutImageNumeric''. |
| RIPWriteIcon       | string  | RIPWriteIcon(pRes, pFilename)                                  | Writes the Clipboard contents to a disk icon file for later use with ''RIPLoadIcon''.  Overwrites any existing file with the same name (Level 1, command ''|1W'').  Also: ''RIPWriteIconNumeric''. |
| RIPLoadIcon        | string  | RIPLoadIcon(pX, pY, pMode, pClipboard, pRes, pFilename)        | Reads an icon from disk and displays it at (pX, pY).  The ''.ICN'' extension is appended automatically if omitted.  If ''pClipboard'' is true, the image is also copied to the Clipboard after being displayed.  Uses the same mode values as ''RIPPutImage'' (Level 1, command ''|1I'').  Also: ''RIPLoadIconNumeric''. |
| RIPCopyRegion      | string  | RIPCopyRegion(pX0, pY0, pX1, pY1, pRes, pDestLine)            | Copies a rectangular screen region vertically to ''pDestLine'' for scrolling effects.  X coordinates must be multiples of 8.  Ignores the current viewport (Level 1, command ''|1G'').  Also: ''RIPCopyRegionNumeric''. |

===== Query and File Transfer Commands =====
These commands query the terminal for information, play back local RIP files, and initiate file transfers.
^ Name                  ^ Returns ^ Signature                                      ^ Description ^
| RIPQuery              | string  | RIPQuery(pMode, pRes, pText)                   | Queries the terminal for text variable values (e.g., ''$FULL_NAME$'') and instructs it to send data to the host.  ''pMode'': 0=process immediately, 1=process on graphics window click, 2=process on text window click (Level 1, ESC command).  Also: ''RIPQueryNumeric''. |
| RIPReadScene          | string  | RIPReadScene(pRes, pFilename)                  | Suspends current RIPscrip execution and plays back a local ''.RIP'' file.  State changes (colors, fonts, etc.) made during playback remain in effect afterward.  Must be the last command on its line, followed by a carriage return (Level 1, command ''|1R'').  Also: ''RIPReadSceneNumeric''. |
| RIPFileQuery          | string  | RIPFileQuery(pMode, pRes, pFilename)           | Queries the terminal for the existence and/or metadata of a local file, sending a response to the host.  ''pMode'': 00=exists (no CR), 01=exists (with CR), 02=size, 03=size+date+time, 04=filename+size+date+time (Level 1, command ''|1F'').  Also: ''RIPFileQueryNumeric''. |
| RIPEnterBlockMode     | string  | RIPEnterBlockMode(pMode, pProtocol, pFileType, pRes) | Auto-initiates a file transfer protocol.  ''pMode'': false=download, true=upload.  ''pProtocol'': 0=Xmodem, 1=Xmodem/CRC, 2=Xmodem-1K, 3=Xmodem-1K(G), 4=Kermit, 5=Ymodem, 6=Ymodem-G, 7=Zmodem.  Must be the last command on its line (Level 9 system command).  Also: ''RIPEnterBlockModeNumeric''. |
| RIPNoMore             | string  | RIPNoMore()                                    | Signals the end of RIPscrip commands, activating mouse regions and processing any queued mouse clicks.  The spec recommends sending three or more consecutive ''RIPNoMore'' commands for noise immunity (Level 0, command ''|#''). |

====== Example Usage ======
This example draws a colored rectangle, adds some text, and defines a clickable mouse region:
  require("rip_lib.js", "RIPWindow");

  // Build a batch of RIP commands
  var cmds = "";

  // Reset to a clean state
  cmds += RIPResetWindows();

  // Set drawing color to light cyan and draw a filled bar
  cmds += RIPFillStyleNumeric(1, RIP_COLOR_BLUE);   // solid fill, blue
  cmds += RIPBarNumeric(10, 10, 200, 50);

  // Draw a border around the bar in white
  cmds += RIPColorNumeric(RIP_COLOR_WHITE);
  cmds += RIPRectangleNumeric(10, 10, 200, 50);

  // Draw text inside the bar
  cmds += RIPColorNumeric(RIP_COLOR_YELLOW);
  cmds += RIPFontStyleNumeric(RIP_FONT_DEFAULT, 0, 1, 0);
  cmds += RIPTextXYNumeric(20, 25, "Hello RIP!");

  // Define a mouse region over the bar that sends "HELLO^M" when clicked
  cmds += RIPMouseNumeric(0, 10, 10, 200, 50, true, false, 0, "HELLO^M");

  // Signal end of RIPscrip scene (send 3 times for noise immunity)
  cmds += RIPNoMore() + RIPNoMore() + RIPNoMore();

  // Transmit the commands to the client
  console.print("\r!" + cmds + "\r\n");

A minimal example using only MegaNum string parameters:
  require("rip_lib.js", "RIPWindow");

  // Draw a red line from (0,0) to (100,100) and print text
  var cmds = RIPColor("0C")                 // light red
           + RIPLine("00", "00", "2S", "2S") // (0,0) to (100,100); 100 decimal = "2S" in base-36
           + RIPTextXY("00", "00", "Line drawn!")
           + RIPNoMore();
  console.print("\r!" + cmds + "\r\n");

====== See Also ======
  * [[https://carl.gorringe.org/pub/code/javascript/RIPtermJS/docs/RIPscrip154.txt|RIPscrip 1.54 Specification]]
  * [[https://breakintochat.com/wiki/Remote_Imaging_Protocol_(RIP)|Remote Imaging Protocol on Break Into Chat]]
  * [[:custom:javascript:lib:|custom:javascript:lib index]]

{{tag>}}