Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: syntax checker
_Syntax checker ; v1.00 17/09/1999 cancelactive=0 ; recovery setup xxact=WinGetactive() ; get edit window If IsKeyDown(@CTRL | @SHIFT) Then kino=1 ; cinema show ? Else kino=0 ; not today If kino Then AddExtender("wwsop32i.DLL") ; get projector if nec. lmax=500 ; max line length, should be enough If wGetSelstate() Then ; anything selected xxcurl2=wGetLineNo() ; get end of selection line number wCut() ; yes, copy it to clipboard xxcurl1=wGetLineNo() ; get start of selection line number Else ; xxcurl1=1 ; line # 1 for all wSelectAll() ; no, get the lot xxcurl2=wGetLineNo() ; get end of selection line number wCut() ; now EndIf ; afiles=(xxcurl2-xxcurl1+1)*lmax ; assuming max line lenght rbuf=BinaryAlloc(afiles) ; buf for current file cbuf=BinaryAlloc(afiles) ; buf in case of cancel nbuf=BinaryAlloc(afiles+10000) ; buf for modified selection + expansion :CANCEL ; like all good programs If cancelactive ; oops time? If kino Then aStatusbar(2,"",""," ",0) ; close show BinaryFree(rbuf) ; return to owner BinaryFree(nbuf) ; return to owner BinaryClipPut(cBuf, 1) ; restore text befor syntax check wPaste() ; stick back in edit file wGotoLine(xxcurl1) ; point back at original location BinaryFree(cbuf) ; return to owner Exit ; emergency exit Else ; cancelactive=1 ; strap on parachute EndIf ; BinaryClipGet(rBuf, 1) ; and stick it in the buffer BinaryClipGet(cBuf, 1) ; and stick it in recovery buffer ls=0 ; starting point for unmodified lines If kino Then aStatusbar(0,"",""," ",0) ; start cinema show totalbar=(xxcurl2-xxcurl1+1) ; total recs so far tsf=0 ; total so far Brk = BinaryEodGet(rBuf) ; max buffer While ls < Brk ; go through input buffer rc=0 ; no @crlf required le = BinaryIndexEx(rbuf,ls,@CRLF,@FWDSCAN,0) ; find end of line If le < 0 Then le = brk ; end of buffer; last line Else rc=1 ; @crlf required ll=le-ls ; ll is length of current line tsf=tsf+1 ; processed counter If ll <> 0 ; dataline=BinaryPeekStr(rbuf,ls,ll) ; process i/p record GoSub checksynif ; check for if problems GoSub checksynbrk ; check for odd delimiters ;add new subroutine here to cure YOUR problems return with dataline changed/unchanged ; If rc Then BinaryPokeStr(nbuf,BinaryEodGet(nbuf),StrCat(dataline,@CRLF)) ; add to new buffer with @crlf Else BinaryPokeStr(nbuf,BinaryEodGet(nbuf),dataline) ; add to new buffer data only ls=ls+StrLen(dataline) ; add length of old/modified data Else ; BinaryPokeStr(nbuf,BinaryEodGet(nbuf),@CRLF) ; add one blank line EndIf ; If rc Then ls=ls+2 ; minimum increase in rbuf size If kino Then aStatusbar(1,totalbar,"",totalbar,tsf) ; enjoy EndWhile ; BinaryEodSet(nbuf,ls) ; set length of restore BinaryClipPut(nBuf, 1) ; text format wPaste() ; stick back in edit file wGotoLine(xxcurl1) ; point back at original location BinaryFree(nbuf) ; free output buffer BinaryFree(rbuf) ; free input buffer BinaryFree(cbuf) ; free original screen data If kino Then aStatusbar(2,"",""," ",0) ; close show ;winactivate(xxact) ; get focus on edit window again Drop(parms,lmax,xxcurl1,xxcurl2,brk,afiles,brks,nbuf,kino,tsf,totalbar) ; drop 'em Drop(lmax,rbuf,ls,le,ll,xxact,x,dataline,dl2,x1,cancelactive,rc) ; drop 'em Display(1,"Syntax","checks finished") ; finished Exit ; finished syntax checking :checksynif ; do some basic == v = syntax checking dl2=dataline ; copy input x=StrIndex(dl2," ; ",0,@BACKSCAN) ; try cutting out the comment If x Then dl2=StrSub(dl2,1,x) ; data to scan x=StrIndexNC(dl2,"if",0,@FWDSCAN) ; always confuse == with = If x ; home in on trouble maker x1=StrIndexNC(dl2," then",x,@FWDSCAN) ; look for then on if line x=StrIndex(dl2,"=",x+2,@FWDSCAN) ; find first = sign If x1<x ; if then before = then forget it Else ; x1=1 ; set trap If x Then x1=StrIndex(dl2,"==",x,@FWDSCAN) ; check for == If !x1 Then dataline=AskLine("Syntax - missing == in line %tsf% ?","Hit enter to accept or edit line",dataline) EndIf ; EndIf ; Return ; :checksynbrk ; check for odd brackets, 95percent of my probs dl2=dataline ; copy input x=StrIndex(dl2," ; ",0,@BACKSCAN) ; try cutting out the comment If x Then dl2=StrSub(dl2,1,x) ; data to scan x=1 ; scanning position brks=0 ; set up count While x<=StrLen(dl2) ; set up loop for scan x1=StrScan(dl2,"()[]{""''``}%%",x,@FWDSCAN) ; scan for delimters in list If x1 ; if found If brks Then brks=0 ; incr count Else brks=1 ; decr count EndIf ; If !x1 Then Break ; scanned all? Else x=x1+1 ; scan again start at next position EndWhile ; If brks Then dataline=AskLine("Syntax - missing delimter in line %tsf% ?","Hit enter to accept or edit line",dataline) Return ;
Article ID: W14967
File Created: 2003:05:28:10:23:10
Last Updated: 2003:05:28:10:23:10