home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 8 / amigaformatcd08.iso / screenplay / shareware / pnp098 / doc / modules.doc < prev    next >
Text File  |  1996-09-11  |  4KB  |  98 lines

  1. A Module is almost a normal program, but it uses some arguments
  2. that make a module be able to exchange data with PNP.
  3.  
  4. However a module does not need to use these arguments. You can even
  5. start a normal program as a module if it does not take any argument.
  6. There are 6 arguments, but the 0. and the 2. aren't used yet.
  7. The arguments are:
  8.  
  9.     0   unused
  10.     1   a pointer to textattr from PNP
  11.     2   unused
  12.     3   a pointer to long (if the content is set to 1 (TRUE) PNP reads data from
  13.         the module)
  14.     4   a pointer to string (here you can store the data)
  15.     5   a pointer to long (its content must be set to 1 as soon as the module is closed)
  16.  
  17. The variables that are used to store the arguments must be defined as follows:
  18.  
  19.     DEF tattr:PTR TO textattr,insclicked;LONG,dataptr:LONG,closed:LONG
  20.  
  21.     ( in C you will have to use: struct textattr *tattr, char **dataptr,
  22.       long *insclicked, long *close)
  23.            ^                 ^
  24.            not sure about that
  25.  
  26.  
  27. The routine for reading the arguments can look as follows:
  28.  
  29.     PROC getargs()
  30.         DEF myargs:PTR TO LONG,rdargs,buf[255]:STRING /* ,htattr:PTR TO textattr */
  31.  
  32.         myargs:=[0,0,0,0,0,0]       /* initialise */
  33.         IF rdargs:=ReadArgs('S/A, W/A, A/A, B/A, C/A, D/A',myargs,NIL)
  34.  
  35.             /* Args 0,2 are not used yet */
  36.  
  37.             StringF(buf,'\s',myargs[1])
  38.             tattr:=Val(buf,NIL)          /* Now your modules uses the same font as PNP */
  39.  
  40.             StringF(buf,'\s',myargs[3])
  41.             insclicked:=Val(buf,NIL)
  42.  
  43.             StringF(buf,'\s',myargs[4])
  44.             dataptr:=Val(buf,NIL)
  45.  
  46.             StringF(buf,'\s',myargs[5])
  47.             closed:=Val(buf,NIL)
  48.  
  49.             FreeArgs(rdargs)
  50.  
  51.         ENDIF
  52.     ENDPROC
  53.  
  54.  
  55. If your module shall open a window you should use the following:
  56.  
  57.     PROC setupscreen()
  58.         IF (scr:=LockPubScreen('PNP'))=NIL THEN RETURN NOWB
  59.         IF (visual:=GetVisualInfoA(scr,NIL))=NIL THEN RETURN NOVISUAL
  60.         offy:=scr.wbortop+Int(scr.rastport+58)-10
  61.     ENDPROC
  62.  
  63. where scr is defined as PTR TO scr.
  64. The window will be opened on the PNP screen now.
  65.  
  66. Nearly everything else is a normal program. But if you want your module to be
  67. able to insert text in the editor you don't have to implement an ARexxport.
  68. Simply write:
  69.  
  70.     StrCopy(^dataptr,'your text',ALL)
  71.     ^insclicked:=1
  72.  
  73. The ^ before the variables indicates that you want to write to the content of the
  74. memoryarea the pointer points to. As these pointers are given by PNP, PNP can read
  75. this data. ^insclicked:=1 says that PNP shall look at ^dataptr and put the data
  76. via ARexx to the editor. After that ^insclicked is set to 0 by PNP.
  77.  
  78. If you want to store more than one line you can write:
  79.  
  80.     maxline:=10
  81.     FOR a:=1 TO maxline
  82.         StringF(txt,'\s',zeile[a].inh)  /* zeile[a].inh is an object,txt a STRING */
  83.         StrCopy(^dataptr,txt,ALL)       /* OBJECT mystring                        */
  84.         ^insclicked:=1                  /*      inh[255]:ARRAY                    */
  85.                                         /* ENDOBJECT                              */
  86.         REPEAT              /* Important: Wait until PNP has read the data !! */
  87.         UNTIL ^insclicked=0
  88.     ENDFOR
  89.  
  90. This is in most cases be done after the user has clicked an insertbutton, but
  91. of course you can also write a module that does not open a window but e.g.
  92. opens a file, reads the data and stores it to ^dataptr.
  93.  
  94. The last thing you must take care of is that ^closed must be set to 1 or TRUE
  95. if the modules is closed. This is necessary for the module handling of PNP.
  96.  
  97. See the example modules in PNP:modules/ too.
  98.