Pick.To.HTML

From Pickwiki
Revision as of 19:22, 26 July 2011 by Wjhonson (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
  • Sample the VOC, turning items into HTML rows, and attributes into HTML

columns. Write it to NTSHARE as an .html, then launch it through Accuterm

  • Writen by Will Johnson, Fast Forward Technologies, wjhonson@aol.com
  • Creative Commons License, this notice must be present in all derivative
works
     EQUATE FALSE TO 0, TRUE TO 1
     EQUATE STX TO CHAR(2), BS TO CHAR(8), TAB TO CHAR(9)
     EQUATE CR TO CHAR(13), EM TO CHAR(25), ESC TO CHAR(27)
  • TO.FILE = Host file directory in which to put the file
  • TO.ITEM = Name of item
  • MAPPED.DRIVE = Directory or mapped location that in Windows
  • puts you in same directory as TO.FILE
     GOSUB GET.PARAMETERS
     GOSUB OPEN.FILES
     GOSUB BUILD.OUTPUT
     SCRIPT = MAPPED.DRIVE:"\":TO.ITEM
     PRINT "Opening ":SCRIPT:" file"
     PRINT ESC:STX:'<':SCRIPT:CR
     STOP

GET.PARAMETERS:

     USER.ID = @LOGNAME
     IF INDEX(USER.ID,'\',1) THEN USER.ID = FIELD(USER.ID,'\',2)
     PRINT "Press the ENTER key to accept these default locations"
     TO.FILE = "NTSHARE.TEMP"
     PRINT "Directory to write result to: ":TO.FILE:
     PRINT STR(BS,LEN(TO.FILE)):
     INPUT NEW.TO.FILE
     IF NEW.TO.FILE #  THEN TO.FILE = NEW.TO.FILE
     TO.ITEM = USER.ID:"_temp.html"
     PRINT "File to write result to: ":TO.ITEM:
     PRINT STR(BS,LEN(TO.ITEM)):
     INPUT NEW.TO.ITEM
     IF NEW.TO.ITEM #  THEN TO.ITEM = NEW.TO.ITEM
     MAPPED.DRIVE = "M:\temp"
     PRINT "Mapped drive to write result to: ":MAPPED.DRIVE:
     PRINT STR(BS,LEN(MAPPED.DRIVE)):
     INPUT NEW.MAPPED.DRIVE
     IF NEW.MAPPED.DRIVE #  THEN MAPPED.DRIVE = NEW.MAPPED.DRIVE
     RETURN

OPEN.FILES:

     OPEN "VOC" TO F.VOC ELSE
        PRINT "Cannot open VOC file.  Hit ENTER.":
        INPUT CONT ; STOP
     END
     IF TO.FILE = "NTSHARE.TEMP" THEN
        K.VOC = "NTSHARE.TEMP"
        READ R.VOC FROM F.VOC,K.VOC ELSE
           R.VOC = "F":@AM:"D:/RWC/ntshare/temp":@AM:"D_VOC"
           WRITE R.VOC ON F.VOC,K.VOC
        END
     END
     OPEN TO.FILE TO F.TO.FILE ELSE
        PRINT "Cannot open ":TO.FILE:" file.  Hit ENTER.":
        INPUT CONT ; STOP
     END
     RETURN

BUILD.OUTPUT:

     CNT = 0 ; DONE = FALSE ; SELECT F.VOC
     OUTPUT =  ; S.COL = 1
     LOOP
        CNT += 1
        READNEXT K.VOC ELSE DONE = TRUE
     UNTIL DONE OR (CNT > 14) DO
        READ R.VOC FROM F.VOC,K.VOC THEN

T.OUTPUT = "" S.VOC = DCOUNT(R.VOC,@AM) FOR I.VOC = 1 TO S.VOC T.OUTPUT := "":R.VOC<I.VOC>:""

           NEXT I.VOC
           IF S.VOC > S.COL THEN S.COL = S.VOC

T.OUTPUT := "" OUTPUT := T.OUTPUT END REPEAT

  • Now build the header as KEY FIELD 1 FIELD 2 FIELD 3...

T.HEADER = "KEY"

     FOR I.COL = 2 TO S.COL

T.HEADER := "FIELD ":(I.COL-1):""

     NEXT I.COL

T.HEADER := "" START.TABLE = "<HTML>

" END.TABLE = "

</HTML>"

     OUTPUT = START.TABLE:T.HEADER:OUTPUT:END.TABLE
     WRITE OUTPUT ON F.TO.FILE,TO.ITEM
     RETURN

END