Example MultiValue BASIC Integration
- Set your variables
- Check the server
- Make the document
- Send it to OpenOffice to render and print
-
Set your variables
! initialize------------------------------------------------------------tag=\\val=\\delim = “/” ; *for unixtemplate.id = “mytemplate.odt”outfile.id = “myfinaldoc.odt”template.dir= ”/mydir/template/”outfile.dir = “/mydir/output/”outfile = outfile.dir:outfile.idtemplate = template.dir:template.idhost = “192.168.1.1”ux.user = “myuser”level = “”verbose = 0unix.printer= “HP_Laserjet”!-----------------------------------------------------------------------!set tags and valuesthis.tag = “%customer_name% ; this.value = “John Galt” ; GOSUB TagValthis.tag = “%customer_addr1% ; this.value = “123 Abc Street” ; GOSUB TagValthis.tag = “%customer_city%” ; this.value = “New York” ; GOSUB TagValthis.tag = “%customer_state%”; this.value = “NY” ; GOSUB TagValthis.tag = “%customer_zip%” ; this.value = “10019” ; GOSUB TagVal!check to see if server is aliveCALL bpi.server.checkalive( “192.168.1.1”, ux.user, level, status, verbose, ping.result, echo.result)IF status THEN! server is aliveCALL bpi.oo.getstatus( host, ux.user, level, pid, verbose)IF pid THENCRT \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 documentCALL BPI.MakeDoc( template, outfile, tag, val, error, message)IF (error) THENCRT \Ooops, there was an error when trying to makedoc.\CRT \error=\:error:\ \:messageGOTO ExitEND ELSE!Makedoc worked, lets send it to ooCALL bpi.oo.render( host, ux.user,template.id,template.dir, unix.printer, verbose, rstatus)IF rstatus EQ 1 THENCRT \Congrats, OpenOffice is processing the print job, go pick it up\END ELSECRT \Ooops, bpi.oo.render encountered an error\CRT \rstatus=\:rstatusGOTO ExitENDENDENDEND ELSECRT \Ooops, the server is not alive. Host=\:hostCRT \ping.result=\:ping.resultCRT \echo.result=\:echo resultGOTO ExitEND!TagVal:!Call the bpi.set.tagval which will update the tags and vals array
!Note, param 1 is the block. We are not using repeating data in this example so
| this can be blankCALL bpi.set.tagval2( \\,tags, vals, this.tag, this.value, \\, pos)RETURN!Exit:CRT \I'm going to exit now\STOP!