Finds the next binary tag.
BinaryTagFind( tag-struct )
(s) tag-struct: Structure returned from BinaryTagInit.
(s) returns a binary tag structure string, or "" on failure.
Note: This function is useful for editing HTML.
;BinaryTag Example 2 - Substitution in GoSubs ;Set up test case ;Setup input and output file names filedata=StrCat(DirGet(),"filedata.txt") filerslt=StrCat(DirGet(),"filerslt.txt") ;Set up a sample file for this example. ;Presumably you could have a library of these ;to choose from, making form letters easy to ;automate. fhandle=FileOpen(filedata,"WRITE") FileWrite(fhandle,"{{date}}") FileWrite(fhandle,"") FileWrite(fhandle,"Dear {{name}}") FileWrite(fhandle,"Thank you for your recent purchase of") FileWrite(fhandle,"our new {{product}}.") FileWrite(fhandle,"") FileWrite(fhandle,"Please feel free to call if you have ") FileWrite(fhandle,"any questions.") FileWrite(fhandle,"") FileWrite(fhandle,"{{salesperson}}") FileWrite(fhandle,"{{salespersonphone}}") FileClose(fhandle) ; Allocate a buffer much larger than required. bb=BinaryAlloc(10000) ;Using {{ and }} for open and close tags around keywords structure=BinaryTagInit(bb,"{{","}}") ;Not necessary in this example, but allows reuse of a ;BinaryBuffer if this code is placed in a loop editing ;multiple files. BinaryEodSet(bb,0) ;Read data into the BinaryBuffer BinaryRead(bb,filedata) While 1 structure=BinaryTagFind(structure) If structure=="" Then Break ; All done keyword=BinaryTagExtr(structure, 1) Value="???" ; keyword not found error value GoSub %keyword% structure = BinaryTagRepl(structure,Value) EndWhile BinaryWrite(bb,filerslt) BinaryFree(bb) Message("Result in",filerslt) Exit :date Value=TimeDate() Return :name Value="Ms. Jamie Dough" Return :product Value="Analog Osscilosophilator" Return :salesperson Value="Fred Ficklemeyer" Return :salespersonphone Value="888.555.1234" Return