Returns the text between the last-returned pair of binary tags.
BinaryTagExtr( tag-struct, flags )
(s) tag-struct: Structure returned from BinaryTagInit.
(i) flags: see below.
(s) returns the text, or "" on failure.
Note: This function is useful for editing HTML.
Flags |
Meaning |
0 |
default. |
1 |
Strip out tabs, carriage returns, and line feeds. |
|
|
;BinaryTag Example 3 - Replace <b>xxx</b> in HTML files with ;<strong>xxx</strong> per html style guidelines ;Set up test case ;Setup input and output file names filedata=AskFilename("HTML file to convert","","HTML files|*.html;*.htm","*.html",1) filerslt=FileMapName(filedata,"*.new") ; Allocate a buffer much larger than required. fsize=FileSize(filedata) bb=BinaryAlloc(fsize+10000) ;Find <b> and </b> for open and close tags around strings. ;Note BinaryTagFind is NOT case sensitive structure=BinaryTagInit(bb,"<b>","</b>") ;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 strongdata=BinaryTagExtr(structure,1) Value=StrCat("<STRONG>",strongdata,"</STRONG>") structure = BinaryTagRepl(structure,Value) EndWhile BinaryWrite(bb,filerslt) BinaryFree(bb) Message("Result in",filerslt) Exit