Example MultiValue Integration

Example MultiValue BASIC Integration

  1. Set your variables
  2. Check the server
  3. Make the document
  4. Send it to OpenOffice to render and print
  5. Set your variables

 

 

! initialize------------------------------------------------------------
tag=\\
val=\\
delim = “/” ; *for unix
template.id = “mytemplate.rtf”
outfile.id  = “myfinaldoc.rtf”
template.dir= ”/mydir/template/”
outfile.dir = “/mydir/output/”
outfile     = outfile.dir:outfile.id
template    = template.dir:template.id
host        = “192.168.1.1”
ux.user     = “myuser”
level       = “”
verbose     = 0
unix.printer= “HP_Laserjet”
!-----------------------------------------------------------------------
!set tags and values
this.tag = “%customer_name%  ; this.value = “John Galt”       ; GOSUB TagVal
this.tag = “%customer_addr1% ; this.value = “123 Abc Street”  ; GOSUB TagVal
this.tag = “%customer_city%” ; this.value = “New York”        ; GOSUB TagVal
this.tag = “%customer_state%”; this.value = “NY”              ; GOSUB TagVal
this.tag = “%customer_zip%”  ; this.value = “10019”           ; GOSUB TagVal
!check to see if server is alive
CALL bpi.server.checkalive( “192.168.1.1”, ux.user, level, status, verbose, ping.result, echo.result)
IF status THEN
   ! server is alive
   CALL bpi.oo.getstatus( host, ux.user, level, pid, verbose)
   IF pid THEN
      CRT \OpenOffice is busy on the server, can't render the document now.  Try again later\
   END ELSE
      ! OpenOffice is not busy, let's render a document
      CALL BPI.MakeDoc( template, outfile, tag, val, error, message)
      IF (error) THEN
         CRT \Ooops, there was an error when trying to makedoc.\
         CRT \error=\:error:\ \:message
         GOTO Exit
      END ELSE
         !Makedoc worked, lets send it to oo
         CALL bpi.oo.render( host, ux.user,template.id,template.dir, unix.printer, verbose, rstatus)
         IF rstatus EQ 1 THEN
            CRT \Congrats, OpenOffice is processing the print job, go pick it up\
         END ELSE
            CRT \Ooops, bpi.oo.render encountered an error\
            CRT \rstatus=\:rstatus
            GOTO Exit
         END
      END
  END
END ELSE
   CRT \Ooops, the server is not alive.  Host=\:host
   CRT \ping.result=\:ping.result
   CRT \echo.result=\:echo result
   GOTO Exit
END
!
TagVal:
   !Call the bpi.set.tagval which will update the tags and vals array
   CALL bpi.set.tagval( tags, vals, this.tag, this.value, “”, pos)
RETURN
!

Exit:
   CRT \I'm going to exit now\
  STOP
!