home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1B / DATAFILE_PDCD1B.iso / _pocketbk / pocketbook / 004 / oscalls_zi / OSCALLS.TXT
Text File  |  1994-05-18  |  10KB  |  337 lines

  1.   1Extended OPL CallsExtended OPL Calls
  2.   
  3.   
  4.   
  5.   
  6.   
  7.   Author:
  8.   Graham Tappenden
  9.   
  10.   
  11.   Date:
  12.   11th May 1994
  13.   
  14.   
  15.   Version:
  16.   1.00
  17.   
  18.   
  19.   This document
  20.   u:\oscalls.doc
  21.   
  22.                                    
  23.                                     Introduction
  24.   This document is an attempt to list the may possible options available to the OPL-Programmer, which are normally only to be found in the SIBO 'C'-Programming Guides.
  25.   
  26.   The various tips and tricks are illustrated with examples in Standard OPL.
  27.   
  28.   There is no particular order to the points listed.  The information can be freely distributed, but is   Psion GmbH.  Thanks to David Wood at Psion PLC for helping me with these routines over the past few months.
  29.   
  30.   Neither the Author, nor Psion GmbH, takes any responsibility for and damage or loss of data which occurs as result of using information in this document.  The information is subject to change without notice.
  31.   
  32.                     Comments are shown in italics.
  33.                                     
  34.      Use of CALL and OS
  35.   
  36.   CALLs and OSs take a particular format.  This is briefly explained in the OPL Programming Manual, but is repeated here for reference.
  37.   
  38.   Using the 'Service' and 'Interrupt' reference in the 'C'-Programming Guide, it is possible to access the specific operating system call desired.
  39.   
  40.   
  41.   Format for Call:
  42.      ret%=CALL($xxyy,...,) xx = Service, yy = Interrupt
  43.   
  44.   Format for OS:
  45.      LOCAL ax%,bx%,cx%,dx%,si%,di% keep these together
  46.      LOCAL flags%
  47.      ax%=$xxyy xx = Service, yy = AL (parameter)
  48.      flags%=OS($zz,addr(ax%)) zz = Interrupt
  49.   
  50.   If an error occurs when using OS, (flags% AND 1) will be true,
  51.   the error code is given by ax% AND $ff00.
  52.   
  53.      Starting another process
  54.   
  55.   Here we start another process, and specify the name of the file to be opened.  The command line starts with 'C' for create, or 'O' for open.  The filename is stored in f$.  The 'Record' at the beginning of the command line in this example is the name of the icon under which the filename will appear in the System Screen.  If this is not a valid (ie. installed) icon, then the filename will appear under RunImg.
  56.   
  57.   
  58.   eg. Recorder with a filename
  59.   
  60.   PROC Record:(f$)
  61.      LOCAL cmdl$(128),helpnm$(128),hpid%,ret%
  62.      cmdl$="CRecord"+chr$(0)+".WVE"+" "+chr$(0)+f$+chr$(0) command line
  63.      helpnm$="rom::record.app"+chr$(0)
  64.      ret%=call($0187,addr(helpnm$)+1+addr(cmdl$),0,0,addr(hpid%)
  65.      call($0688,pid%) ProcResume
  66.   ENDP
  67.   
  68.   
  69.   Get Process ID
  70.   
  71.   Each process has an ID number.  Here we read the ID number for a specific process.
  72.   
  73.   eg. Get the process ID for the system shell.  pid% is defined globally to hold this variable.
  74.   
  75.      name$="sys$shll.*"
  76.      pid%=call($0188,addr(name$)+1) ProcIdByName
  77.   
  78.   
  79.   Getting the Process ID for the current process
  80.   
  81.   This short piece of code reads the ID for the current process.
  82.   
  83.      LOCAL pid%
  84.      pid%=CALL($0088)
  85.   
  86.   
  87.      Setting the priority of the process
  88.   
  89.   Once we have the ID for a process, we can change the priority of this process.
  90.   
  91.      LOCAL ax%,bx%,cx%,dx%,si%,di% keep these together
  92.      LOCAL flags% NB: pid% must be defined to be the process id
  93.   
  94.      bx%=pid%
  95.      ax%=$0398
  96.   
  97.      flags%=OS($88,addr(ax%)) ProcSetPriority
  98.   
  99.   
  100.   Changing the position of a process
  101.   
  102.   We can also change the position of this process, ie. whether it is in foreground or background.
  103.   
  104.      CALL($998d,pos%,pid%)
  105.   
  106.      For the current process, pid% can be set to zero.
  107.      For foreground, use pos%=0, for background, pos%=100.
  108.   
  109.      Language Code
  110.   
  111.   Programs written by Psion are in the majority Multi-lingual.  This means that if they run on an English machine, they run in English, on a German machine they run in German, and so on.
  112.   
  113.   Each language is assigned a number, which is used to recognise the machine in use.
  114.   
  115.   This example returns a string containing the number of the code for the resource file.
  116.   
  117.   PROC Lang$:
  118.      LOCAL ax%,bx%,cx%,dx%,si%,di% Keep these variables together
  119.      LOCAL flags%,a$(2)
  120.   
  121.      ax%=$1B00 GetLangData
  122.   
  123.      flags%=OS($008B,ADDR(ax%)) General Services
  124.   
  125.      IF flags% AND 1
  126.           RETURN("01") an error occured
  127.      ELSE
  128.           a$=NUM$(ax%,2)
  129.           IF LEN(a$)<2 :a$="0"+a$ :ENDIF makes two digits for filenames
  130.      ENDIF
  131.   ENDP
  132.   
  133.   The numbers currently in use are:
  134.         1   English
  135.         2   French
  136.         3   German
  137.         4   Spanish
  138.         5   Italian
  139.         6   Swedish
  140.         7   Danish
  141.         8   Norwegen
  142.         9   Finish
  143.         10  American
  144.         11  Swiss French
  145.         12  Swiss German
  146.         13  Portuguese
  147.         14  Turkish
  148.         15  Icelandic
  149.         16  Russian
  150.         17  Hungarian
  151.         18  Dutch
  152.         19  Belgian Flemish
  153.         20  Australian
  154.         21  New Zealand
  155.         22  Austrian
  156.         23  Belgian French
  157.      Simulating a key press
  158.   
  159.   There is a technique for the Series3a to simulate a keypress in another application.  This method only works for Object-oriented applicaitions.
  160.   
  161.   The following must be globally defined:
  162.      GLOBAL k%,m% keep these two together
  163.   
  164.   pid% is the process id, k% is the keycode, m% is the modifier
  165.      CALL($0483,pid%,$31,0,addr(k%)) MessSend
  166.   
  167.   
  168.   Capturing a key in background
  169.   
  170.   We can also when a particular key is pressed, even if the process requiring this key is not current.
  171.   
  172.      call($c58d,26,$404) wCaptureKey
  173.      This example captures key 26, ie. Ctrl-Z.
  174.   
  175.      
  176.   Capturing the off key
  177.   
  178.   The following parameters will capture the 'OFF' key.
  179.   
  180.      call($c58d,$2003,$e08)
  181.      
  182.      keya(kstat%,k%(1) queues for a key press
  183.   
  184.      The value returned in kstat% will NOT be -46 if a key is pressed, and for the off key,
  185.      k%(1) will be $2003.
  186.   
  187.      Reading an environment variable
  188.   
  189.   Environment variables are used to store data which is used by all applications.  Space for these variables is limited, and should normally not be used by OPL applications.
  190.   
  191.   PROC EnvGet:
  192.      LOCAL ax%,bx%,cx%,dx%,si%,di% keep these together
  193.      LOCAL flags%
  194.   
  195.      LOCAL env$(6),penv%,lenenv%
  196.      LOCAL buff$(255),pbuff%,lenbuff%
  197.   
  198.      env$="$WP_PW" name of the variable to search for, eg. $WP_PW
  199.      penv%=ADDR(env$+1)
  200.      lenenv%=LEN(env$)
  201.   
  202.      pbuff%=ADDR(buff$)+1
  203.   
  204.      ax%=$2100
  205.      bx%=0
  206.      di%=penv%
  207.      dx%=lenenv%
  208.      si%=pbuff%
  209.   
  210.      flags%=OS($008b,ADDR(ax%)) GenEnvBufferGet
  211.   
  212.      IF flags% AND 1
  213.           An error has occured, error code: ax% OR $ff00
  214.      ELSE
  215.           lenbuff%=ax%
  216.           POKEB ADDR(buff$),lenbuff% Insert leading count
  217.      ENDIF
  218.   ENDP
  219.   
  220.   Reading the user details
  221.   User details are stored in environment variable $WS_PW.
  222.   Bytes 4, 8, 12, and 16 contain the length (in bytes) of each of the four lines.
  223.   The first line begins at byte 19.
  224.   
  225.   Reading the current printer driver
  226.   The printer destination is stored in environment variable P$D. Zero for parallel, one for serial, and two for file.
  227.   The printer driver is stored in environment variable P$M.  This is generally a filename.
  228.   If printing to a file, the name is stored in P$F.
  229.   
  230.      Asynchronous WVE Playing
  231.   
  232.   This procedure will play a .WVE file asynchronously.
  233.   
  234.   PROC Play:(inname$,ticks%,vol%)
  235.      LOCAL name$(128),pstat%
  236.      name$=inname$+CHR$(0)
  237.      CALL($1E86,UADD(ADDR(name$),1),ticks%,vol%,0,pstat%)
  238.      IOWAITSTAT pstat%
  239.   ENDP
  240.   
  241.   
  242.   Cancelling Asynchronous Wave Playing
  243.   PROC Playc:
  244.      CALL($2086)
  245.   ENDP
  246.   
  247.      Window Server os-calls
  248.   
  249.   This is a list of the Window Server os-calls, given here for reference purposes only.
  250.   
  251.   gSetOpenAddress(bx,cx,dx)   $5f8d
  252.   wCancelCaptureKey(bx,cl,ch) $c68d
  253.   wCancelSystemModal(bx) $c88d
  254.   wCaptureKey(bx,cl,ch)  $c58d
  255.   wClientInfo(bx)     $8c8d
  256.   wClientPosition(bx,cx) $998d
  257.   wDisableLeaves(dx)  $0dd6
  258.   wDisablePauseKey()  $ce8d
  259.   wDrawButton(bx,cx,dx)  $608d
  260.   wEnablePauseKey()   $4d8d
  261.   wEndComput