Jump to content

Stupid OS/2 Tricks/REXX Commands

From EDM2
Revision as of 04:37, 20 January 2007 by Martini (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

OPEN.CMD

/* OPEN.CMD - opens a folder */ call RxFuncAdd "SysSetObjectData", "RexxUtil", "SysSetObjectData" folderpath="<drive>:\<path>" call SysSetObjectData folderpath, "OPEN=DEFAULT"; exit

/* where <drive> is the letter of the drive on which the subdirectory

  corresponding to the folder is located
  <path>  is the path to the subdirectory corresponding to the folder */

BIGDOS.CMD

/* Start a DOS session with the maximum free memory */ /* Xavier Caballe - December 1993 */

/* code added to make DOS session open in foreground */ /* M.Woo - 6 Jan 94 */

CALL RxFuncAdd SysLoadFuncs, RexxUtil,SysLoadFuncs; CALL SysLoadFuncs;

ClassName='WPProgram'; /* Object type */ Title='Big DOS'; /* Window title */ Program='EXENAME=*;'; /* Program to run */ Location='<WP_NOWHERE>'; /* Object location */ Type='PROGTYPE=VDM;'; /* DOS full screen session */ StartUp='STARTUPDIR=C:\;' /* Working directory */ Objectid='OBJECTID=<BIGDOS>;' /* Object ID */

/* Session Settings */

/* The Video_Mode_Restriction value *MUST BE* fifteen characters long */

Settings='SET VIDEO_MODE_RESTRICTION=CGA  ;' Settings=Settings||'SET DOS_UMB=1;' Settings=Settings||'SET DOS_HIGH=1;'

Open='OPEN=DEFAULT;' /* Open default view */

call SysCreateObject classname, title, location,,

   program||type||startup||objectid||settings||open, 'REPLACE'

call SysSetObjectData '<BIGDOS>', open Return

BITMAP.CMD

/* BITMAP.CMD: change the desktop bitmap at regular intervals

   Syntax:  BITMAP.CMD <interval in seconds> [/?]
   Copyright 1994 Jack Tan
*/
/* Check the interval value */
     arg interval
     if interval=="" | WORDPOS("/?", interval)<>0 then do
          SAY
          SAY "   BITMAP.CMD:  randomly change the desktop bitmap at",
              "periodic intervals"
          SAY "   Syntax:  BITMAP.CMD <interval in seconds> [/?]"
          SAY "   <interval> is the interval between bitmap changes,",
              "in seconds"
          exit 1
     end  /* Do */
     else if DATATYPE(interval, "Whole Number")<>1 then
          call badNumber interval
     else if interval<=0 then
          call badNumber interval
/* Prepare for the changes */
     signal on halt name exitProgram
     BootDrive  = VALUE("BOOTDRIVE", , "OS2ENVIRONMENT")
     BitmapSpec = BootDrive || "\OS2\BITMAP\*.BMP"
     call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
     call SysLoadFuncs
     SAY "BITMAP.CMD:  Hit Ctrl+Break to exit"
/* Execute the change */
     do forever
          call SysFileTree BitmapSpec, "bitmaps", "FO"
          if bitmaps.0>0 then do
               i = RANDOM(1, bitmaps.0)
               call SysSetObjectData "<WP_DESKTOP>"; "BACKGROUND="bitmaps.i";"
          end  /* Do */
          call SysSleep interval
     end /* Do */
exitProgram:
     SAY "             Successfully exited"
     exit 0
badNumber: procedure
     SAY "Bad interval value '"ARG(1)"'"
     exit 2

CHKDRIVE.CMD

EVAL.CMD

LARGE.CMD

PUTLONG.CMD

SETPTR.CMD

/* SetPtr.CMD -- set/remove a custom mouse pointer.

  Copyright 11 January 1994 by Jack Tan
  This is based on Dann Lunsford's SETMOUSE.CMD
      SETMOUSE.CMD by Dann Lunsford
      Short procedure to set mouse pointer to contents of specified .PTR file
      This file is in the public domain, but I'd appreciate it greatly if you
      would leave this notice in...     Author:  Dann Lunsford
                                                 Vortex BBS (1:203/726)
                                                 13-Aug-1993
  Be careful about adding/removing lines to this script -- it uses the
  SOURCELINE function, which is source-dependent.
  Syntax:  SetPtr.CMD <filename> [pointer index] [/X] [/L] [/?]
           <filename> is the name of the file containing the pointer.
           If <filename> does not exist, <filename>.PTR is searched.
           [pointer index] is an optional parameter.  It defaults to 1.
        Index  Pointer                       Default OS/2 icon
    ------------------------------------------------------------------
          1    normal OS/2 pointer           arrow
          2    text insertion                I-beam
          3    wait cursor                   clock
          4    size pointer                  (no icon)
          5    move pointer                  four-way arrow
          6    resize (NW to SE)             diagonal double arrow (\)
          7    resize (NE to SW)             diagonal double arrow (/)
          8    resize (horizontal)           horizontal double arrow (-)
          9    resize (vertical)             vertical double arrow (|)
          /X (optional) indicates that the custom pointer should be removed.
          /L (optional) lists currently installed pointers.
          /? (optional) displays this help.


  • /
/* Get arguments */
   PARSE ARG arguments
   bigArgs = TRANSLATE(arguments)
/* Show help */
   if arguments== | WORDPOS("/?", arguments)<>0 then do
      do i=12 to 33
         SAY SOURCELINE(i)
      end /* do */
      EXIT(1)
   end  /* Do */
 /* Setup the REXX function */
   call RxFuncAdd 'SysIni', 'RexxUtil', 'SysIni'
   Inifile  = 'User'
   App      = 'PM_SysPointer'
/* Show current pointers */
   if WORDPOS('/L', bigArgs)<>0 then do
      result = SysIni(Inifile, App, 'All:', 'list')
      if list.0<1 then
         SAY "No custom pointers have been set."
      else do
         SAY "Current custom pointers:"
         do  i=1 to 9
            result = SysIni(Inifile, App, i)
            if result<>"ERROR:" then
               SAY "   ("i")" LEFT(pointerDesc(i), 20),
                  SUBSTR(result, 5, LENGTH(result)-5)
         end  /* Do */
      end  /* Do */
      EXIT(0)
   end  /* Do */
/* Look for a '/X' */
   xPos = WORDPOS('/X', bigArgs)
   if xPos<>0 then do
      removePtr = 1
      arguments = DELWORD(arguments, xPos, 1)
   end  /* Do */
   else
      removePtr = 0
/* Look for a pointer index */
   pointerIndex = 1
   if WORDS(arguments)>1 | removePtr then do
      /* Last argument should be the pointer index, since any '/X'
         has already been removed.  If the last argument does not fit
         the requirements for a pointer index, assume that it is part
         of the filename.
      */
      guessIndex = WORD(arguments, WORDS(arguments))
      if LENGTH(guessIndex)==1 & VERIFY(guessIndex, '123456789')==0 then do
         arguments = DELWORD(arguments, WORDS(arguments))
         pointerIndex = guessIndex
      end /* Do */
   end  /* Do */
/* Set the filename */
   if removePtr<>1 then do
      arguments = STRIP(arguments)
      if SUBSTR(arguments, 1, 1)=='"' then
         arguments = DELSTR(arguments, 1, 1)
      if SUBSTR(arguments, LENGTH(arguments))=='"' then
         arguments = DELSTR(arguments, LENGTH(arguments))
      filename = STREAM(arguments, 'Command', 'Query Exists')
      if filename== then do
         /* Try again use .PTR extension */
         filename = STREAM(arguments".PTR", 'Command', 'Query Exists')
         if filename== then do
            SAY "Cannot find file:  '"arguments"'"
            EXIT(3)
         end  /* Do */
      end  /* Do */
   end  /* Do */
/* Execute the change */
   if removePtr then
      result = SysIni(Inifile, App, pointerIndex, 'DELETE:')
   else do
      Keyvalue = x2c('01000000')||filename||x2c('00')
      result = SysIni(Inifile, App, pointerIndex, Keyvalue)
   end  /* Do */
/* If the change failed... */
   if result<>"" then do
      returnCode = 3
      if removePtr then
         SAY "Unable to delete the pointer"
      else
         SAY "Unable to set the pointer"
   end  /* Do */
/* ... else print 'successful' message */
   else do
      returnCode = 0
      if removePtr then
         SAY "Pointer successfully removed"
      else
         SAY "The new pointer will become effective at the next system boot."
   end  /* Do */
/* Give some more information */
   if removePtr<>1 then
      SAY "   File    = "filename
   SAY "   Pointer = "pointerDesc(pointerIndex) "("pointerIndex")"
EXIT(returnCode)
pointerDesc: procedure
   return STRIP(SUBSTR(SOURCELINE(20+ARG(1)), 15, 30))
/* End of REXX script */

SETFONT.CMD

SHUTDOWN.CMD

SHREDDER.CMD

SLEEP.CMD