home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / MISC / HYPOC / HPIF.DOC < prev    next >
Encoding:
Text File  |  1994-11-05  |  21.0 KB  |  555 lines

  1. HyperPoc program interface:
  2. ===================================================================
  3. Changes in Version 2.2
  4. -------------------------------------------------------------------
  5. OnTick     A timer tick is now guaranteed when the OnTick bit
  6.            is set and the interval can be specified (default 1/2 sec)
  7.  
  8. helpClue   new function to control help system.
  9. ===================================================================
  10.  
  11. HyperPoc V2 allows to define program objects. User written programs 
  12. can be executed on card open or on activation. 
  13. This interface, is however, unsupported. We cannot give information exceeding
  14. the information offered with this text.
  15.  
  16. Program objects can:
  17.  
  18. 1. Place any graphic information on the current card.
  19. 2. Display an own window
  20. 3. Manage events from keyboard and other devices
  21. 4. Access to other cards via predefined HyperPoc routines
  22. 5. Access to other files within the system
  23. 6. Create files
  24.  
  25. How to:
  26.  
  27.  
  28. 1. Installation
  29.    Make sure to include HCIF.OPA into the \APP\HYPERPOC folder.
  30.    If you do not plan to use Program objects, you don't need this module.
  31.  
  32. =======================================================================
  33.  
  34. 2. Creation of program object
  35.  
  36.    Write the required OPL module.
  37.    The module must start with
  38.  
  39.         APP HYPERPOC
  40.         ENDA
  41.  
  42.         PROC modnam%:(parm$)
  43.  
  44.   modnam must be identical with the name of the module.
  45.   On invocation parm$ will contain the parameter string as defined in HyperPoc.
  46.  
  47.   We suggest to store the program into the folder ...\APP\HYPERPOC\SUB\ .
  48.   However, it may be stored elsewhere, especially during debugging.
  49.  
  50.   If you are creating your program on a PC, you may want to use OPLLINT
  51.   to check your program for missing definitions. Use HPREF.OPL to support
  52.   this process:
  53.  
  54.     OPLLINT modnam hpref -imc -rmodnam
  55.  
  56. =======================================================================
  57.  
  58. 3. Define program object on card or background.
  59.    This is done in the HyperPoc Editor (PSION-E or PSION-B) and PSION-P.
  60.    You are asked for the module name (modnam) and a parameter string.
  61.    This string will be passed to the module on invocation (parm$).
  62.  
  63. =======================================================================
  64.  
  65. 4. Programming guidelines
  66.    a) Use never variable names starting with HY.
  67.    b) Use never subroutine names starting with HY.
  68.    c) Close any windows you have opened before returning control back
  69.       to HyperPoc.
  70.    d) !!!!!!!!!!!!!!!!!! Files !!!!!!!!!!!!!!!!!!!!
  71.       Never, never use file commands such as ERASE, UPDATE, APPEND
  72.       without preceeding them by a USE B/C/D statement.
  73.       Unsolicited use of these statements can cause the corruption of
  74.       your stacks.
  75.       The file handle A cannot be used because it is used by HyperPoc.
  76.       During the debugging stage make backup copies of all of your
  77.       stacks.
  78.    e) Stacks
  79.       Never access physically do stacks. Stack data structures may 
  80.       change during updates and are not published for this reason.
  81.       HCIF provides a set of specialised routines for stack access (see below).
  82.  
  83. =======================================================================
  84.  
  85. 5. Interface routines
  86.  
  87.       cardnum% = findCd%:(stack$,srchmod%,srch$,addr(handle&))
  88.  
  89.         This routine finds a card in the specified stack. Set handle& = 0 for
  90.         the first call. Subsequent calls will find other cards matching the
  91.         specified search criterion.
  92.         The function returns 0 when no (more) cards are found.
  93.  
  94.            stack$               stack name (full path name).          
  95.  
  96.            srchmod% = 1         card text
  97.                       2         card keywords
  98.                       3         card number
  99.  
  100.            srch$ =              Text string, Keyword, or number
  101.                                 For srchmod% = 1 or = 2 srch$ may contain 
  102.                                 wild cards (*,?)
  103.  
  104.            handle&              Card handle. To be used with other 
  105.                                 access routines.
  106.                                 It is possible to manage different
  107.                                 cards simultanously using different
  108.                                 handle& and stack$ variables.
  109.  
  110.           cardnum%              logical card number
  111.                                 0 = no card found
  112.                                 2 = home card
  113.                                 >2  other cards
  114.  
  115. ---------------------------------------------------------------------------
  116.  
  117.       findBg:(stack$,addr(handle&))
  118.  
  119.       This routine finds the background of the specified stack.
  120.  
  121.            stack$               stack name (full path name).    
  122.            
  123.            handle&              Background handle. To be used with other 
  124.                                 access routines.
  125.                                 It is possible to manage different
  126.                                 backgrounds simultanously using different
  127.                                 handle& and stack$ variables.
  128.  
  129.         The global variable ObjPar% will contain the hypertext emphasis
  130.         (gStyle format) of the specified stack.
  131.  
  132. ---------------------------------------------------------------------------
  133.  
  134.       obj% = CdObj%:(stack$,addr(handle&),ObjMsk&)
  135.  
  136.         This routine returns objects of the current card or background
  137.         one by one with each call. When no more objects can be returned,
  138.         the result is 0.
  139.         The routine sets the following global variables:
  140.  
  141.                 ObjX%, ObjY%, ObjW%, ObjH%
  142.                 ObjTxt$   (128)
  143.                 ObjAttr$  (70)
  144.                 ObjPar%
  145.  
  146.         ObjX%, ObjY%, ObjW%, ObjH% contain object position and dimension.
  147.         ObjTxt$, ObjAttr$, ObjPar% depend on the object type
  148.  
  149.  
  150.         stack$          stack name (full path name).
  151.  
  152.         handle&         Card or background handle.
  153.  
  154.         ObjMsk&         Selection mask for objects.
  155.                         2**obj% will select objects of type obj%
  156.                         Combinations are possible.
  157.                         E.g. 2**2+2**5 = 36 = &00000024 
  158.                              selects texts and phone numbers
  159.                         Specify &ffffffff for all objects.
  160.  
  161.         
  162.         obj%            =  object type
  163.                                         0 no (more) object found
  164.                                         1 Application           &00000002
  165.                                         2 Text                  &00000004
  166.                                         3 Card link             &00000008
  167.                                         4 Icon                  &00000010
  168.                                         5 Phone #               &00000020
  169.                                         6 Polyline              &00000040
  170.                                         7 unused
  171.                                         8 Rectangle             &00000100
  172.                                         9 Clock                 &00000200
  173.                                         10 Keywords             &00000400
  174.                                         11 Bitmap               &00000800
  175.                                         12 Music                &00001000
  176.                                         13 Menu function        &00002000
  177.                                         14 Round rectangle      &00004000
  178.                                         15 HotTab               &00008000
  179.                                         16 unused
  180.                                         17 Explainer            &00020000
  181.                                         18 unused
  182.                                         19 Program              &00080000
  183.  
  184.         Application:
  185.  
  186.                         ObjTxt$ =       File name (e.g. DATA.DAT)
  187.                         ObjAttr$ =      Application name (e.g. WORLD)
  188.  
  189.         Text:
  190.  
  191.                         ObjTxt$ =       character string
  192.  
  193.                                 any character code n% < 32 
  194.                                 represents a gap of n% pixels instead
  195.                                 of a real character (created with TAB key).
  196.  
  197.                         ObjAttr$ = attribute string
  198.  
  199.                         ObjAttr$ is structured in the following way (dummy declarations only):
  200.  
  201.                             att$(i%) = mid$(ObjAttr$,3*i%-2,3)
  202.                                 for i% = 1 ... len(ObjAttr$)/3
  203.                                 is a single attribute for one text segment
  204.  
  205.                             slen%(i%) = asc(att$(i%)) and 127
  206.                                 is the length of the text element in characters
  207.  
  208.                             sind%(i%) = asc(att$(i%)) and 128
  209.                                 is an indicator if there are any character codes
  210.                                 < 32 (TABS) in the text segment.
  211.  
  212.                             font%(i%) = asc(mid$(att$(i%),2,1))
  213.                                 is the font number for the text segment
  214.                                 Note: HyperPoc font numbers are not identical
  215.                                 with gfont font id's. Use the function
  216.                                 trfont%: to translate a HyperPoc font number
  217.                                 into gfont font id's.
  218.  
  219.                             style%(i%) = asc(right$(att$(i%),1))
  220.                                 is the gStyle setting for the text segment
  221.  
  222.         Card link:
  223.                         ObjTxt$ = stackname
  224.                         ObjPar% = cardnumber
  225.         Icon:
  226.                         none
  227.         Phone #:
  228.                         ObjTxt$ = phone number (dirty)
  229.                                   Use strip$ (see below) for cleaning.
  230.                         ObjAttr$ = Header String ("",bh,ah,mb,pg,fx,em)
  231.                                    (Language dependend)
  232.         Polyline:
  233.                         none
  234.         Rectangle:
  235.                         none
  236.         Clock:
  237.                         none
  238.         Keywords:
  239.                         ObjTxt$ = keywords separated by comma
  240.         Bitmap:
  241.                         none
  242.         Music:
  243.                         none
  244.         Menu function:
  245.                         ObjPar% = Function code (= character code+512)
  246.         Round rectangle:
  247.                         none
  248.         HotTab:
  249.                         ObjPar% = object type associated with HotTab
  250.                         ObjTxt$ = name of HotTab
  251.  
  252.                         Objects associated with HotTabs can be found
  253.                         by position: 
  254.                                 If the HotTab has a name:
  255.  
  256.                                         x+w+3 , y
  257.                                      or 
  258.                                         x+w+3 , y+2
  259.  
  260.                                 else
  261.                                         x , y
  262.                                      or 
  263.                                         x , y+2
  264.  
  265.         Explainer:
  266.                         none
  267.         Program:
  268.                         none
  269.  
  270. -----------------------------------------------------------------------
  271.  
  272.         c% = getKey%:(control%)
  273.  
  274.         Get a key code or event code.
  275.  
  276.         control%        Control mask for animation
  277.                         1       inhibit animation
  278.                         2       inhibit music and sound
  279.                         4       pass control on timer tick
  280.                                 You have to provide a routine onTick:
  281.                         8       pass control on idle
  282.                                 You have to provide a routine onIdle:
  283.                         16      Disable Help system during this getKey
  284.                                 HelpKey is passed as result when pressed
  285.                         32      Pass MENU key to user routine
  286.  
  287.                         n*256   interval between timer ticks
  288.                                 in 1/2 seconds (n = 1...127)
  289.         
  290.         Note that the routine onIdle: is only started when the system is 
  291.         waiting for an event. Animation or onTick: routines may lead to the 
  292.         situation that the system is never idle.
  293.  
  294.         Both onIdle: and onTick: may return a character code to getKey:,
  295.         which is then passed to the caller of getKeY:.
  296.  
  297.         On receiving event codes (c% = 513...1023,1028)
  298.         you must(!) close your routine and pass control back to HyperPoc.
  299.         The event codes 1024,1025,1026,1027,1029 are not handled
  300.         by HyperPoc, so you better handle them yourself.
  301.  
  302.         After closing your files and windows use 
  303.                 RETURN c%
  304.         to inform HyperPoc about the event.
  305.  
  306.         It is strongly recommended to use this routine instead of 
  307.         get or getevent. While waiting for the event, 
  308.         HyperPoc will continue to process animation, music and stop watches. 
  309.         It will also handle the menu key.
  310.  
  311.         Note: Do not use instructions such as get, key, getevent, pause, iow, ioa
  312.               within these routines.
  313.  
  314.         As key modifier use the global variable km% instead of kmod.
  315.  
  316. -----------------------------------------------------------------------
  317.  
  318.         r% = showCd%:(stknam$,cdnum%)
  319.  
  320.         Opens the specified card of the specified stack and displays it.
  321.         The specified card becomes the current card. This function
  322.         allows the user program to navigate through cards.
  323.         If successful the result is -1, else 0.
  324.         curstk$ and cuCd% (see below) are modified by this function.
  325.  
  326.         This function cannot be used at card open time. When used
  327.         during this time it will have no effect and will return 0.
  328.  
  329. =======================================================================
  330.  
  331.  
  332. 6. Utility functions
  333.  
  334.         Some useful subroutines that can be used in a user module:
  335.  
  336.  
  337.         substr$ = extract$:(cslist$,i%)
  338.  
  339.         If cslist$ is a comma separated list, extract$ returns the i-th
  340.         element of this list (empty if i% is out of range).
  341.  
  342. -----------------------------------------------------------------------
  343.  
  344.         o$ = Obj$:(o%)
  345.  
  346.         Returns the object type name for object type o%.
  347.  
  348. -----------------------------------------------------------------------
  349.  
  350.         file$ = shtName$:(path$)
  351.  
  352.         Extracts the 8-byte file name from a full path name.
  353.         The first character of the file name will be upper case,
  354.         the following characters will be lower case.
  355.  
  356. -----------------------------------------------------------------------
  357.  
  358.         prTim:(sec%)
  359.  
  360.         gprints a time specified in seconds (sec%) as  hh:mm:ss
  361.  
  362. -----------------------------------------------------------------------
  363.  
  364.         atxt$ = asctxt$:(rawtxt$,len%,pat$)
  365.  
  366.         delivers the first len% bytes of rawtxt$ and replaces any
  367.         character code < 32 by pat$ (e.g. chr$(9)).
  368.  
  369.         A typical call for text objects could be:
  370.  
  371.               asctxt$:(right$(spec$,len(spec$)-1),asc(spec$)," ")
  372.  
  373. -----------------------------------------------------------------------
  374.  
  375.         dial$ = strip$:(phone$)
  376.  
  377.         Removes all characters unfit for dialling from phone$.
  378.         Translates also [country] into digits and processes +countrycode.
  379.         An empty string is returned on invalid country code.
  380.  
  381. -----------------------------------------------------------------------
  382.  
  383.         dial:( dial$,out% )
  384.  
  385.         Dials the specified dial string (dial$) using the preferences
  386.         of the current stack. strip$ is applied to dial$ before
  387.         actual dialling.
  388.         out% <> 0 causes the dial-out string to be dialled first.
  389.  
  390. -----------------------------------------------------------------------
  391.  
  392.         ret% = setrs:
  393.  
  394.         Before you print to a line printer you should call
  395.         this routine. The serial interface will be set to the values
  396.         defined with printer setup (PSION-Y). This routine includes
  397.         and LOPEN to the serial or parallel interface.
  398.         The response code is unequal zero in case of success.
  399.  
  400. -----------------------------------------------------------------------
  401.  
  402.         warning:(Msg$,Sever%)
  403.  
  404.         flashes Msg$ in lower right corner of screen and beeps.
  405.         Sever% indicates the severity (0..3) which is reflected
  406.         in duration and pitch of the beep.
  407.                 0 = Message (no beep)
  408.                 1 = Operator errors (e.g. wrong input string, low pitch beep)
  409.                 2 = Device errors (e.g. disk full, medium pitch beep)
  410.                 3 = System and program errors( high pitch beep)
  411.  
  412.  
  413. -----------------------------------------------------------------------
  414.  
  415.         helpClue:(Clue$)
  416.  
  417.         Sets a help clue (help keyword) for the help system to 
  418.         provide context sensitive help. Clue$ must be 1..9 characters.
  419.  
  420.         An empty string as Clue$ switches the help system off.
  421.  
  422. -----------------------------------------------------------------------
  423.  
  424.         gfnt% = trfont%:(hfnt%)
  425.  
  426.         Translates a HyperPoc Font number into a gfont font ID.
  427.         Returns the stack default font ID if hfnt% is not valid.
  428.  
  429.  
  430. =======================================================================
  431.  
  432.  
  433. 7. Variables:
  434.  
  435.         Never, never overwrite the following variables.
  436.  
  437.         curStk$  (128)  = full path name of current stack
  438.  
  439.         stkFol$  (128)  = path name of HyperPoc stack folder
  440.  
  441.         icnFol$  (128)  = path name of HyperPoc icon folder
  442.  
  443.         appFol$  (128)  = path name of HyperPoc module folder (...APP\HYPERPOC\)
  444.  
  445.         cuCd%           = logical number of current card
  446.  
  447.         km%             = key modifier (instead of kmod)
  448.  
  449.         sMod%           = last search mode (1,2,3)
  450.  
  451.         sKey$    (32)   = last search string
  452.  
  453.         onAct%          = true if program was invoked on activation
  454.                           false if program was invoked on card open
  455.  
  456. =======================================================================
  457.  
  458. 8. Permanent memory and semaphors
  459.  
  460.         The following variables are not used by HyperPoc and
  461.         are dedicated to be used by user programs. You may use them, for
  462.         instance, to remember logical card numbers or as semaphors.
  463.  
  464.         prVar1%
  465.         prVar2%
  466.         prVar3%
  467.         prVar4%
  468.  
  469.         prStrng$(128)
  470.  
  471.         You should not try to remember background and card handles
  472.         between program calls. Handles may change when a card is
  473.         edited. Better remember the logical card number and find
  474.         it again using findCd.
  475.  
  476.  
  477. =======================================================================
  478.  
  479. 9. Display media
  480.  
  481.         Programs can output into 
  482.  
  483.         a)      the current card.
  484.                 The current card is drawable 1.
  485.                 On program start, the global variables
  486.                 ObjX%, ObjY%, ObjW%, ObjH%
  487.                 contain the X- and Y-coordinates, width,
  488.                 and height of the current card.
  489.                 Always use graphic instructions like gprint
  490.                 to output into the card.
  491.  
  492.         b)      A window created by the program.
  493.                 Use gcreate to create the window.
  494.                 Always close the window when leaving the program.
  495.  
  496. =======================================================================
  497.  
  498. 10. Error handling
  499.  
  500. Your routine should handle any errors. Specify an ONERR clause to
  501. pass control to an error label. Before you leave the routine close
  502. all you files and windows. Return the errorcode with RETURN r% 
  503. (r% containing the error code).
  504.  
  505. =======================================================================
  506.  
  507. 11. Creating a parameter string
  508.  
  509. The size of the parameter string is limited to 50 characters.
  510. Normally you specify a parameter string when placing the program object
  511. onto the card.
  512. However, if the parameter syntax becomes complex, as in IMPDATA.OPL,
  513. you may want to support the input of the parameter string with a specialised
  514. dialogue box.
  515. To do so, define within the module a subroutine
  516.  
  517.         edParm$:(oldParm$)
  518.  
  519. This subroutine is called when a program object is created or modified.
  520. oldParm$ contains the old parameter string (empty for a new object).
  521. The new parameter string is passed to HyperPoc as the result of edParm$.
  522.  
  523. If HyperPoc does not find a subroutine edParm$ it will allow for the input
  524. of the raw parameter string.
  525.  
  526. =======================================================================
  527.  
  528. 12. Tips
  529.  
  530.  
  531. It is possible to change search criteria between subsequent findCd% calls.
  532. e.g.
  533.  
  534.          findCd%:(curStk$,3,num$(cuCd%,5),addr(handle&))
  535.          findCd%:(curStk$,1,"elephant",addr(handle&))
  536.  
  537. positions first to the current card, then starts searching for
  538. text "elephant" with the next card until stack end. 
  539.  
  540. At program invocation time, the graphic cursor is always positioned at
  541. the top left corner of the program representation, so can use gX and gY
  542. to find out about the position of the program object.
  543.  
  544. =======================================================================
  545.  
  546. 13. Examples
  547.  
  548.  
  549. PHLIST.OPL prints a phonelist from the address stack.
  550.  
  551. BROWSE.OPL displays all cards of a stack.
  552.  
  553. INDEX.OPL displays the sorted keywords of a stack.
  554.  
  555. IMPDATA.OPL imports PSION database records.