Page Date 2004-05-18 DD-Software |
|
|
|
MyWbtHelp current version |
DDBEAUTY.WBT Version 0.99v 2003:06:27 - Source Code Formatter - Cross Reference List Generator - Drop Statement Generator - Dialog Sorter for WWWDLGED statement lines (Version 'WWWDLGED,5.0' only.) - Comma Aligner for WWWDLGED statement lines or for other code lines that need to be aligned on comma position. - EqualSign Aligner for group aligning of statement lines along the first EqualSign in leftmost position of the line. - UDF Statement Colorizer 7 simple tools for WinBatch programmer's daily work. How to adapt it into WinBatch Studio Editor? Read simple instructions at top of ddbeauty.wbt file. |
Example EqualSignAligner Example CommaAligner Example DropMaker Example DialogSorter Example CrossReferencer Example Beautifier |
;========================================================================================================================================== ; DDBEAUTY.WBT Version 0.99v 20030627 world wide beta test (c)20010401.Detlev Dalitz ;========================================================================================================================================== ; Seven simple tools for WinBatch Scripts ; d = Droplist Generator ; b = Beautifier/Formatter ; c = Crossreference List Generator ; ds = Dialog Sorter for WWWDLGED statement lines (Version 'WWWDLGED,5.0' only.) ; ca = Comma Aligner for WWWDLGED statement lines or for other code lines that should be aligned on comma position ; ea = EqualSign Aligner to group align statement lines along the first EqualSign on lefthand line position. ; u = udf colorize collect into WIL.CLR ;========================================================================================================================================== ; Usage (1) on commandline: ; winbatch.exe ddbeauty.wbt [d|b|bc|c|ds|u|ca|ea] [infile.wbt outfile.wbt] ; ; Usage (2) embedded in WinBatch Studio Environment. ;========================================================================================================================================== ; For proper use in WinBatch Studio and having the tools in the right click mouse menu, ; you have to copy the menu section "_DD.BeautyTools" into the file WSP-USER.MNU. ; Note: ; Older versions of WinBatch did have only one unique menu file WSPOPUP.MNU. ; With the use of WSP-USER.MNU, the WinBatch version can be upgraded ; without having side effects in the personal WSP-USER.MNU file. ; ; For example: ; ; |<==LeftMargin ; | ; | ; |_Undo ; Undoes the last editing action ; | wEdUndo() ; | ; |_DD.BeautyTools ; call the beautiful tools ; | Beautify ; | call("%yourWBTfolder%\ddbeauty.wbt","b") ; | ; | DropMaker ; | call("%yourWBTfolder%\ddbeauty.wbt","d") ; | ; | CrossRef ; | call("%yourWBTfolder%\ddbeauty.wbt","c") ; | ; | DialogSort ; | call("%yourWBTfolder%\ddbeauty.wbt","ds") ; | ; | CommaAlign ; | call("%yourWBTfolder%\ddbeauty.wbt","ca") ; | ; | EqualSignAlign ; | call("%yourWBTfolder%\ddbeauty.wbt","ea") ; | ; | UDFColorizer ; | call("%yourWBTfolder%\ddbeauty.wbt","u") ; | ; ;========================================================================================================================================== ; For using the "DropMaker" tool in WinBatch Studio environment you have to mark/select/highlight ; some area of WinBatch code and then use "DropMaker" from the right click menu. ; "DropMaker" will insert a "drop()" statement into the code, ; including all variables collected from the marked area. ; For applying "Beautify" or "Crossreference" you also can use the mouse. ; For tweaking the hardcoded user configuration search for the string "User configurable" in this script. ;========================================================================================================================================== ; Enjoy! Viel Spass! ;========================================================================================================================================== ;========================================================================================================================================== InStudio = (RtStatus()==10) ;------------------------------------------------------------------------------------------------------------------------------------------ For i=0 To 9 CallParam%i% = "" If IsDefined(Param%i%) Then CallParam%i% = Param%i% Next ;------------------------------------------------------------------------------------------------------------------------------------------ GoSub Test_Stuff ;------------------------------------------------------------------------------------------------------------------------------------------ GoSub Beauty_DefineGlobalVar ;------------------------------------------------------------------------------------------------------------------------------------------ If (CallParam0>1) sGlobal = ItemReplace(CallParam2,33,sGlobal,@TAB) ; TheFileIn, no check, file must exist sGlobal = ItemReplace(CallParam3,32,sGlobal,@TAB) ; TheFileOut, no check, existing file will be overwritten InStudio = @FALSE Else If InStudio IsClipSelAll = @FALSE If !wGetSelstate() wSelectAll() IsClipSelAll = @TRUE EndIf wEdCopy() SelInfo = wSelInfo() sGlobal = ItemReplace(wGetFilename(),33,sGlobal,@TAB) ; TheFileIn EndIf EndIf ;------------------------------------------------------------------------------------------------------------------------------------------ Select (CallParam0>0) Case @FALSE ; GoSub Beauty_InteractiveMenu ; not present in this version MsgTitle = ItemExtract(1,sGlobal,@TAB) MsgText = StrCat("No Parameters specified",@LF,"Usage: WinBatch.exe ddbeauty.wbt [d|b|bc|c|ds|ca|ea infile.wbt outfile.wbt]") Pause(MsgTitle,MsgText) Break Case @TRUE CallParam1 = StrLower(CallParam1) Continue Case (CallParam1=="d") If InStudio Then GoSub Beauty_DropMaker Else Pause(ItemExtract(1,sGlobal,@TAB),"Please use DropMaker in WinBatch Studio Editor") Break Case (CallParam1=="b") GoSub Beauty_Beautifier Break Case (CallParam1=="c") GoSub Beauty_CrossReferencer Break Case (CallParam1=="bc") Case (CallParam1=="cb") GoSub Beauty_Beautifier GoSub Beauty_CrossReferencer Break Case (CallParam1=="ds") If InStudio Then GoSub Beauty_DialogSorter Else Pause(ItemExtract(1,sGlobal,@TAB),"Please use DialogSorter in WinBatch Studio Editor") Break Case (CallParam1=="ca") If InStudio Then GoSub Beauty_CommaAligner Else Pause(ItemExtract(1,sGlobal,@TAB),"Please use CommaAligner in WinBatch Studio Editor") Break Case (CallParam1=="ea") If InStudio Then GoSub Beauty_EqualSignAligner Else Pause(ItemExtract(1,sGlobal,@TAB),"Please use EqualSignAligner in WinBatch Studio Editor") Break Case (CallParam1=="u") If InStudio Then GoSub Beauty_ColorizeCollector Else Pause(ItemExtract(1,sGlobal,@TAB),"Please use UDF Colorize Collector in WinBatch Studio Editor") Break EndSelect Exit ;========================================================================================================================================== ;========================================================================================================================================== :Beauty_ColorizeCollector GoSub Beauty_InitColorizeCollector If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CollectUdfs GoSub Beauty_MessageClose Return ; from GoSub Beauty_ColorizeCollector ;========================================================================================================================================== :Beauty_DialogSorter GoSub Beauty_InitDialogSorter If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CleanupPre GoSub Beauty_SortDialogObjects GoSub Beauty_CleanupPost GoSub Beauty_PasteDialogStatement GoSub Beauty_MessageClose Return ; from GoSub Beauty_DialogSorter ;========================================================================================================================================== :Beauty_DropMaker GoSub Beauty_InitDropMaker If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CleanupPre GoSub Beauty_DeleteComments GoSub Beauty_DeleteLiterals GoSub Beauty_DeleteCommentsInLine GoSub Beauty_DeleteComparators GoSub Beauty_CreateDropList GoSub Beauty_DeleteDupDrops GoSub Beauty_FormatDropStatement GoSub Beauty_PasteDropStatement GoSub Beauty_MessageClose Return ; from GoSub Beauty_DropListMaker ;========================================================================================================================================== :Beauty_Beautifier GoSub Beauty_InitBeautifier If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CleanupPre GoSub Beauty_Tokenize GoSub Beauty_Indentation GoSub Beauty_CleanupPost If !InStudio Then GoSub Beauty_AddLogo If InStudio Then GoSub Beauty_CloseClip Else GoSub Beauty_CloseFile GoSub Beauty_MessageClose Return ; from GoSub Beauty_Beautifier ;========================================================================================================================================== :Beauty_CrossReferencer GoSub Beauty_InitCrossRef If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CleanupPre GoSub Beauty_MarkComments If ShowLiterals Then GoSub Beauty_MarkLiterals Else GoSub Beauty_DeleteLiterals GoSub Beauty_MarkCommentsInLine GoSub Beauty_ReplaceOperators GoSub Beauty_MarkEmptyLines GoSub Beauty_PrepareSort GoSub Beauty_Sort GoSub Beauty_CreateReport GoSub Beauty_AppendReportToScript GoSub Beauty_MessageClose Return ; from GoSub Beauty_CrossReferencer ;========================================================================================================================================== :Beauty_CommaAligner GoSub Beauty_InitCommaAligner If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CleanupPre GoSub Beauty_CommaAlign GoSub Beauty_CleanupPost GoSub Beauty_PasteDialogStatement GoSub Beauty_MessageClose Return ; from GoSub Beauty_CommaAligner ;========================================================================================================================================== :Beauty_EqualSignAligner GoSub Beauty_InitEqualSignAligner If InStudio Then GoSub Beauty_OpenClip Else GoSub Beauty_OpenFile GoSub Beauty_CleanupPre GoSub Beauty_EqualSignAlign GoSub Beauty_CleanupPost GoSub Beauty_PasteDialogStatement GoSub Beauty_MessageClose Return ; from GoSub Beauty_EqualSignAligner ;========================================================================================================================================== ;========================================================================================================================================== :Beauty_InitBeautifier ; --- User configurable --- IndentTab = 3 ; (caution: Linelength Max. 255 Byte!) ; User configurable LeftMargin = 0 ; User configurable ShiftCommentToLeftMargin = @FALSE ; 1=shift the commentline to the left margin, 0=do not shift ; User configurable UseTabsOut = @FALSE ; 1=use tabs on output, 0=do not use tabs ; User configurable AskDialogBeautify = @TRUE ; 1=use following dialog, 0=do not use dialog ; User configurable ; --- Do not change --- sGlobal = ItemReplace(ItemExtract(23,sGlobal,@TAB),31,sGlobal,@TAB) TheFileIn = FileMapName(ItemExtract(33,sGlobal,@TAB),"*.*") If AskDialogBeautify Verify_List = "IsInt(LeftMargin),IsInt(IndentTab),LeftMargin>=0,LeftMargin<=20,IndentTab>=0,IndentTab<=20" Verify_Count = ItemCount(Verify_List,",") Verify_Dialog = @FALSE While !Verify_Dialog MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Beautifier Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=175 MyDialogHeight=84 MyDialogNumControls=11 MyDialog01=`004,050,164,DEFAULT,PUSHBUTTON,DEFAULT ,"&OK",1` MyDialog02=`006,006,164,DEFAULT,VARYTEXT ,TheFileIn ,""` MyDialog03=`006,022,048,DEFAULT,STATICTEXT,DEFAULT ,"&Left Margin (0..20)"` MyDialog04=`006,034,048,DEFAULT,STATICTEXT,DEFAULT ,"&Indentation (0..20)"` MyDialog05=`050,066,078,DEFAULT,PUSHBUTTON,DEFAULT ,"&Abort",0` MyDialog06=`054,020,016,DEFAULT,EDITBOX ,LeftMargin,""` MyDialog07=`054,032,016,DEFAULT,EDITBOX ,IndentTab ,""` MyDialog08=`082,022,052,DEFAULT,STATICTEXT,DEFAULT ,"&Shift comment to left"` MyDialog09=`082,034,050,DEFAULT,STATICTEXT,DEFAULT ,"Use &Tabs on output"` MyDialog10=`136,020,036,DEFAULT,CHECKBOX ,ShiftCommentToLeftMargin,"",1` MyDialog11=`136,034,036,DEFAULT,CHECKBOX ,UseTabsOut,"",1` ButtonPushed=Dialog("MyDialog") If (ButtonPushed==0) Then Exit ; leave the script just here the hard way Verify_Dialog = @TRUE For iVerify=1 To Verify_Count Verify_Item = ItemExtract(iVerify,Verify_List,",") Verify_Dialog = (Verify_Dialog && (%Verify_Item%)) If !Verify_Dialog Then Break Next EndWhile EndIf Drop(ButtonPushed,iVerify,TheFileIn,Verify_Count,Verify_Dialog,Verify_Item,Verify_List,AskDialogBeautify) DropWild("MyDialog*") ExtraSpace = 0 Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_InitDialogSorter ; --- User configurable --- DialogSortDirection = 2 ; 1=xpos, 2=ypos ; User configurable DialogSortZero = 2 ; 1=ZeroLeading, 2=ZeroSuppress ; User configurable AskDialogSort = @TRUE ; 1=use following dialog, 0=do not use dialog ; User configurable ; --- Do not change --- sGlobal = ItemReplace(ItemExtract(26,sGlobal,@TAB),31,sGlobal,@TAB); actual modul TheFileIn = FileMapName(ItemExtract(33,sGlobal,@TAB),"*.*") If AskDialogSort MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Dialog Sorter Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=172 MyDialogHeight=84 MyDialogNumControls=7 MyDialog01=`004,050,164,DEFAULT,PUSHBUTTON ,DEFAULT,"&OK",1` MyDialog02=`006,006,164,DEFAULT,VARYTEXT ,TheFileIn,""` MyDialog03=`030,022,050,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &X-pos",1` MyDialog04=`030,032,050,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &Y-pos",2` MyDialog05=`048,066,078,DEFAULT,PUSHBUTTON ,DEFAULT,"&Abort",0` MyDialog06=`104,022,052,DEFAULT,RADIOBUTTON,DialogSortZero,"&Leading Zeroes",1` MyDialog07=`104,034,052,DEFAULT,RADIOBUTTON,DialogSortZero,"&Suppress Zeroes",2` ButtonPushed=Dialog("MyDialog") If (ButtonPushed==0) Then Exit; the hard way out EndIf Drop(TheFileIn,AskDialogSort,ButtonPushed) DropWild("MyDialog*") IndentTab = 0 LeftMargin = 0 ExtraSpace = 16 Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_InitCrossRef ; --- User configurable --- ShowLiterals = @TRUE ; 1=show literals in crossreference output, 0=do not show ; User configurable ShortenLiterals = @FALSE ; 1=shorten literals, 0=do not shorten ; User configurable AskDialogCrossRef = @TRUE ; 1=use following dialog, 0=do not use dialog ; User configurable ; --- Do not change --- sGlobal = ItemReplace(ItemExtract(24,sGlobal,@TAB),31,sGlobal,@TAB) TheFileIn = FileMapName(ItemExtract(33,sGlobal,@TAB),"*.*") If AskDialogCrossRef MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Cross Reference Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=175 MyDialogHeight=84 MyDialogNumControls=7 MyDialog01=`006,006,164,DEFAULT,VARYTEXT ,TheFileIn,""` MyDialog02=`012,022,052,DEFAULT,STATICTEXT,DEFAULT,"Show &Literals"` MyDialog03=`056,022,036,DEFAULT,CHECKBOX ,ShowLiterals,"",1` MyDialog04=`012,034,050,DEFAULT,STATICTEXT,DEFAULT,"&Shorten Literals"` MyDialog05=`056,034,036,DEFAULT,CHECKBOX ,ShortenLiterals,"",1` MyDialog06=`004,050,164,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog07=`048,066,078,DEFAULT,PUSHBUTTON,DEFAULT,"&Abort",0` ButtonPushed=Dialog("MyDialog") If (ButtonPushed==0) Then Exit ; the hard way out EndIf Drop(TheFileIn,AskDialogCrossRef,ButtonPushed) DropWild("MyDialog*") ; --- Do not change --- sGlobal = ItemReplace(ItemExtract(24,sGlobal,@TAB),31,sGlobal,@TAB) hBBLit1 = BinaryAlloc(5) hBBLit2 = BinaryAlloc(5) BinaryPokeStr(hBBLit1,0,"00000") BinaryPokeStr(hBBLit2,0,"@@@@@") IndentTab = 0 LeftMargin = 0 LitList = "" ExtraSpace = 0 Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_InitCommaAligner ; --- Do not change --- IndentTab = 0 LeftMargin = 0 ExtraSpace = 250 sGlobal = ItemReplace(ItemExtract(29,sGlobal,@TAB),31,sGlobal,@TAB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_InitEqualSignAligner ; --- Do not change --- IndentTab = 0 LeftMargin = 0 ExtraSpace = 250 sGlobal = ItemReplace(ItemExtract(30,sGlobal,@TAB),31,sGlobal,@TAB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_InitDropMaker ; --- Do not change --- IndentTab = 0 LeftMargin = 0 ExtraSpace = 0 sGlobal = ItemReplace(ItemExtract(22,sGlobal,@TAB),31,sGlobal,@TAB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_InitColorizeCollector ; --- Do not change --- IndentTab = 0 LeftMargin = 0 ExtraSpace = 0 sGlobal = ItemReplace(ItemExtract(27,sGlobal,@TAB),31,sGlobal,@TAB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_OpenFile TheFileIn = ItemExtract(33,sGlobal,@TAB) WorkMark = @CRLF ; important crlf WorkMarkSize = StrLen(WorkMark) num = FileSize(TheFileIn) If !num Then Exit ; nothing to do; the hard way out hBBTemp = BinaryAlloc(num) num = BinaryRead(hBBTemp,TheFileIn) Lines = BinaryStrCnt(hBBTemp, 0, num - 1, @CRLF) AppSize = (num + 2*WorkMarkSize + Lines * (LeftMargin + IndentTab + 4 + ExtraSpace)) AppSize = Max(2048,AppSize) hBB = BinaryAlloc(AppSize) BinaryEodSet(hBB,0) BinaryPokeStr(hBB,0,WorkMark) BinaryCopy(hBB,WorkMarkSize,hBBTemp,0,num) BinaryPokeStr(hBB,BinaryEodGet(hBB),WorkMark) BinaryFree(hBBTemp) Drop(AppSize,hBBTemp,Lines,num,WorkMark,WorkMarkSize,TheFileIn) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_OpenClip WorkMark = @CRLF ; important crlf WorkMarkSize = StrLen(WorkMark) num = BinaryClipGet(0,1) If !num Then Exit ; nothing to do; the hard way out hBBTemp = BinaryAlloc(num) num = BinaryClipGet(hBBTemp,1) Lines = BinaryStrCnt(hBBTemp, 0, num-1, @CRLF) AppSize = (num + 2*WorkMarkSize + Lines * (LeftMargin + IndentTab + 4 + ExtraSpace)) AppSize = Max(2048,AppSize) hBB = BinaryAlloc(AppSize) BinaryEodSet(hBB,0) BinaryPokeStr(hBB,0,WorkMark) BinaryCopy(hBB,WorkMarkSize,hBBTemp,0,num) BinaryPokeStr(hBB,BinaryEodGet(hBB),WorkMark) BinaryFree(hBBTemp) Drop(AppSize,hBBTemp,Lines,num,WorkMark,WorkMarkSize) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CloseClip BinaryClipPut(hBB,1) If IsClipSelAll Then wSelectAll() wEdPaste() BinaryFree(hBB) Drop(hBB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CloseFile BinaryWrite(hBB, ItemExtract(32,sGlobal,@TAB)) ; TheFileOut BinaryFree(hBB) Drop(hBB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CleanupPre sGlobalNr = 2 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message BinaryReplace(hBB,@TAB ," " ,@TRUE) ; change one tab to one white space BinaryReplace(hBB,@CRLF,@CR ,@TRUE) ; unify EOL BinaryReplace(hBB,@LF ,@CR ,@TRUE) ; unify EOL BinaryReplace(hBB,@CR ,@CRLF,@TRUE) ; unify EOL ; delete leading blanks BinaryEodSet(hBB,BinaryEodGet(hBB)-1) ; workaround bug in BinaryReplace sBlank = StrCat(@LF," ") While BinaryReplace(hBB,sBlank,@LF,@TRUE) EndWhile Drop(sBlank) BinaryEodSet(hBB,BinaryEodGet(hBB)+1) ; workaround bug in BinaryReplace ; delete trailing blanks sBlank = StrCat(" ",@CR) While BinaryReplace(hBB,sBlank,@CR,@TRUE) EndWhile Drop(sBlank) ; insert one white space before eol BinaryReplace(hBB,@CR,StrCat(" ",@CR),@TRUE) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CleanupPost sGlobalNr = 3 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message ; delete trailing blanks sBlank = StrCat(" ",@CR) While BinaryReplace(hBB,sBlank,@CR,@TRUE) EndWhile Drop(sBlank) ; delete WorkMarks sBBTag = BinaryTagInit(hBB,@CR,@LF) sBBTag = BinaryTagFind(sBBTag) If (sBBTag<>"") Then sBBTag = BinaryTagRepl(sBBTag,"") BinaryEodSet(hBB,BinaryEodGet(hBB)-2) Drop(sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_AddLogo sOut = StrCat("; ", TimeYmdHms()," ",ItemExtract(1,sGlobal,@TAB),@CRLF) BinaryPokeStr(hBB,BinaryEodGet(hBB),sOut) Drop(sOut) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_Tokenize ; Set the default token and count the lines. MaxLines = BinaryReplace(hBB,@LF,StrCat(@LF,"1",@TAB),@TRUE) ; Define the relevant keywords and group them into lists following the indentation rules. sKeywordList1 = "1,Break ,Continue ,Return ,Return(,Drop ,Drop(" ;sKeywordList2 = "2,EndIf ,Return ,Return(,Exit ,Next ,EndSelect ,EndSwitch ,EndWhile " sKeywordList2 = "2,EndIf ,Exit ,Next ,EndSelect ,EndSwitch ,EndWhile " sKeywordList3 = "3,If ,If(,While ,While(,For ,Select ,Select(,Switch ,Switch(" sKeywordList4 = "4,Case ,Case(" sKeywordList5 = "5,Then " sKeywordList6 = "6,#DefineFunction ,#EndFunction ,#DefineSubRoutine ,#EndSubRoutine ,#Include ,Call " sKeywordList7 = "7,:,;" ; very special keywords ; Replace the default token with the indentation token. iCount = 1 iTokenCount = 7 For iToken=1 To iTokenCount iKeywordCount = ItemCount(sKeywordList%iToken%,",") For iKeyword=2 To iKeywordCount sKeyword = ItemExtract(iKeyword,sKeywordList%iToken%,",") sSearch = StrCat(@LF,"1",@TAB,sKeyword) sReplace = StrCat(@LF,iToken,@TAB,sKeyword) iReplaceCount = BinaryReplace(hBB,sSearch,sReplace,@FALSE) iCount = iCount + iReplaceCount sGlobalNr = 18 Beauty_Message_MaxCount = MaxLines Beauty_Message_Count = iCount GoSub Beauty_Message Next Next :SpecialIfThen ; Check for "If ... Then" in the same line, maybe there are trailing comments. starttag = StrCat("3",@TAB,"If") ; Find "If " or "If(". sBBTag = BinaryTagInit(hBB,starttag,@CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break TokenOffset = BinaryTagIndex(sBBTag,1) ThisLine = BinaryTagExtr(sBBTag,1) ; Load the tag extracted content into a temporary binary buffer. hBBTemp = BinaryAlloc(1+StrLen(ThisLine)) BinaryPokeStr(hBBTemp,0,ThisLine) BinaryPokeStr(hBBTemp,BinaryEodGet(hBBTemp),@CR) ; Delete literals. sQuote = StrSub(StrClean(ThisLine,"""'`","",@FALSE,2),1,1) If (sQuote>"") sBBTempTag = BinaryTagInit(hBBTemp,sQuote,sQuote) While @TRUE sBBTempTag = BinaryTagFind(sBBTempTag) If (sBBTempTag=="") Then Break sBBTempTag = BinaryTagRepl(sBBTempTag,"") EndWhile EndIf Drop(sQuote,sBBTempTag) ;Message("1",StrCat('#',BinaryPeekStr(hBBTemp,0,BinaryEodGet(hBBTemp)),'#')) ; Delete inline Comment. sBBTempTag = BinaryTagInit(hBBTemp,";",@CR) While @TRUE sBBTempTag = BinaryTagFind(sBBTempTag) If (sBBTempTag=="") Then Break sBBTempTag = BinaryTagRepl(sBBTempTag,@CR) EndWhile Drop(sBBTempTag) ;Message("2",StrCat('#',BinaryPeekStr(hBBTemp,0,BinaryEodGet(hBBTemp)),'#')) ; Delete trailing blanks. sBlank = StrCat(" ",@CR) While BinaryReplace(hBBTemp,sBlank,@CR,@TRUE) EndWhile Drop(sBlank) ;Message("3",StrCat('#',BinaryPeekStr(hBBTemp,0,BinaryEodGet(hBBTemp)),'#')) ; Check for "lonely then". ; Workaround for a common syntactical misuse of "if...then...endif". ; However, the whole bunch of existing "if...then...else...endif" quirks cannot be handled here. If (BinaryIndexEx(hBBTemp,BinaryEodGet(hBBTemp),StrCat("Then",@CR),@BACKSCAN,@FALSE)==-1) If (BinaryIndexEx(hBBTemp,BinaryEodGet(hBBTemp),"Then",@BACKSCAN,@FALSE)>-1) iReplaceCount = BinaryPokeStr(hBB,TokenOffset,"1") ; Treat this line as a normal line. EndIf EndIf BinaryFree(hBBTemp) Drop(hBBTemp) iCount = iCount+iReplaceCount EndWhile sGlobalNr = 18 Beauty_Message_MaxCount = MaxLines Beauty_Message_Count = iCount GoSub Beauty_Message :SpecialElse ; Check "Else" lines and do the proper indentation. starttag = StrCat("1",@TAB,"Else ") sBBTag = BinaryTagInit(hBB,starttag,@CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break TokenOffset = BinaryTagIndex(sBBTag,1) KeywordOffset = TokenOffset + 2 ; Length of StrCat("1",@TAB) BinaryPokeStr(hBB,KeywordOffset,"Else") ; Force standard writing of "Else". ThisLine = BinaryTagExtr(sBBTag,1) ThisLine = StrTrim(ThisLine) If (ThisLine > "") ; Load the line into a temporary binary buffer. hBBTemp = BinaryAlloc(2+StrLen(ThisLine)) BinaryPokeStr(hBBTemp,0,ThisLine) BinaryPokeStr(hBBTemp,BinaryEodGet(hBBTemp),@CR) ; Delete literals. sQuote = StrSub(StrClean(ThisLine,"""'`","",@FALSE,2),1,1) If (sQuote > "") sBBTempTag = BinaryTagInit(hBBTemp,sQuote,sQuote) While @TRUE sBBTempTag = BinaryTagFind(sBBTempTag) If (sBBTempTag=="") Then Break sBBTempTag = BinaryTagRepl(sBBTempTag,"") EndWhile EndIf ; Delete inline Comment. sBBTempTag = BinaryTagInit(hBBTemp,";",@CR) While @TRUE sBBTempTag = BinaryTagFind(sBBTempTag) If (sBBTempTag=="") Then Break sBBTempTag = BinaryTagRepl(sBBTempTag,@CR) EndWhile ; Delete Spaces. While BinaryReplace(hBBTemp," ","",@TRUE) EndWhile If (BinaryEodGet(hBBTemp) > 1) iReplaceCount = BinaryPokeStr(hBB,TokenOffset,"5") Else iReplaceCount = BinaryPokeStr(hBB,TokenOffset,"4") EndIf BinaryFree(hBBTemp) Else iReplaceCount = BinaryPokeStr(hBB,TokenOffset,"4") EndIf iCount = iCount+iReplaceCount EndWhile sGlobalNr = 18 Beauty_Message_MaxCount = MaxLines Beauty_Message_Count = iCount GoSub Beauty_Message Drop(hBBTemp,sBBTempTag,sGlobalNr,iCount,iKeyword,iKeywordCount) Drop(iReplaceCount,iToken,iTokenCount,sKeyword,sKeywordList1,sKeywordList2,sKeywordList3) Drop(sKeywordList4,sKeywordList5,sKeywordList6,sKeywordList7,sQuote,sReplace,sSearch,starttag) Drop(sBBTag,ThisLine,TokenOffset,KeywordOffset) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_Indentation Indent = 0 sBBTag = BinaryTagInit(hBB,@LF,@TAB) i = 1 While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break Token = BinaryTagExtr(sBBTag,1) If !((100*i/MaxLines) mod 10) sGlobalNr = 19 Beauty_Message_MaxCount = MaxLines Beauty_Message_Count = i GoSub Beauty_Message EndIf i = i+1 Select Token Case 1 ; NN Fill = Indent Break Case 3 ; NR Fill = Indent Indent = Indent+IndentTab Break Case 5 ; RL Indent = Indent+IndentTab Fill = Indent Indent = Max(0,Indent-IndentTab) Break Case 2 ; LN Indent = Max(0,Indent-IndentTab) Fill = Indent Break Case 4 ; LR Indent = Max(0,Indent-IndentTab) Fill = Indent Indent = Indent+IndentTab Break Case 6 ; LF Indent = 0 Fill = 0 Break Case 7 ; LL Fill = Indent If ShiftCommentToLeftMargin Then Fill = 0 Break EndSelect FillStr = StrFill(" ",LeftMargin) If !UseTabsOut Then IndentStr = StrFill(" ",Fill) Else IndentStr = StrFill(@TAB,(Fill/IndentTab)) FillStr = StrCat(FillStr,IndentStr) sBBTag = BinaryTagRepl(sBBTag,StrCat(@LF,FillStr)) EndWhile Drop(Fill,FillStr,i,Indent,IndentStr,sBBTag,Token,MaxLines) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_DeleteComments sGlobalNr = 4 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sBBTag = BinaryTagInit(hBB,StrCat(@LF,";"),@CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break sBBTag = BinaryTagRepl(sBBTag,StrCat(@LF," ",@CR)) EndWhile Drop(sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_DeleteLiterals sGlobalNr = 5 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message OpList = """\`\'" OpItemCount = ItemCount(OpList,"\") For i=1 To OpItemCount OpItem = ItemExtract(i,OpList,"\") sBBTag = BinaryTagInit(hBB,OpItem,OpItem) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break sBBTag = BinaryTagRepl(sBBTag,"") EndWhile Next i Drop(i,OpItem,OpItemCount,OpList,sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_MarkLiterals sGlobalNr = 6 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message LitTag = "#_$_" OpList = """/`/'" OpItemCount = ItemCount(OpList,"/") For i=1 To OpItemCount OpItem = ItemExtract(i,OpList,"/") sBBTag = BinaryTagInit(hBB, OpItem, OpItem) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break LitStr = BinaryTagExtr(sBBTag,1) LitStr = StrCat(OpItem,LitStr,OpItem) If ShortenLiterals LitStrLen = StrLen(LitStr) LitStrFixLen = 26 If ((LitStrLen / 2) > LitStrFixLen) LitStr = StrCat(StrSub(LitStr,1,LitStrFixLen),"<.>",StrSub(LitStr,LitStrLen-LitStrFixLen+1,LitStrFixLen)) EndIf EndIf LitList = ItemInsert(LitStr,-1,LitList,@TAB) LitItemCount = ItemCount(LitList,@TAB) LitItemCount = StrFixLeft(LitItemCount,"0",5) BinaryPokeStr(hBBLit1,0,LitItemCount) BinaryOr(hBBLit1,0,hBBLit2,0,5) LitStr = BinaryPeekStr(hBBLit1,0,5) LitStr = StrCat(" ",LitTag,LitStr," ") sBBTag = BinaryTagRepl(sBBTag,LitStr) EndWhile Next i Drop(i,LitItemCount,LitTag,LitStr,LitStrFixLen,LitStrLen,OpItem,OpItemCount,OpList,sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_DeleteCommentsInLine sGlobalNr = 7 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sBBTag = BinaryTagInit(hBB,";",@CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break sBBTag = BinaryTagRepl(sBBTag,StrCat(" ",@CR)) EndWhile Drop(sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_DeleteComparators sGlobalNr = 8 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message OpList = "==/>=/<=/!=" OpItemCount = ItemCount(OpList,"/") For i=1 To OpItemCount num = BinaryReplace(hBB,ItemExtract(i,OpList,"/"),"",@TRUE) Next i Drop(i,num,OpList,OpItemCount) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CreateDropList sGlobalNr = 9 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message DropStr = "" DropItem_old = "" eqPos = -1 While @TRUE eqPos = BinaryIndexEx(hBB,eqPos+1,"=",@FWDSCAN,0) If (eqPos==-1) Then Break i = 0 While @TRUE i = i + 1 Char = BinaryPeekStr(hBB,eqPos-i,1) If (Char<>" ") Then Break EndWhile RightPos = eqPos-i While @TRUE i = i + 1 Char = BinaryPeekStr(hBB,eqPos-i,1) If (Char==@LF) Then Break If (Char==" ") Then Break EndWhile LeftPos = eqPos-i+1 DropItem = BinaryPeekStr(hBB,LeftPos,RightPos-LeftPos+1) DropItem = StrTrim(DropItem) If (StrScan(DropItem, "][",1,@FWDSCAN) > 0) Then Continue ; skip over array elements If (DropItem==DropItem_old) Then Continue DropStr = ItemInsert(DropItem,-1,DropStr,",") DropItem_old = DropItem EndWhile DropStr = ItemSort (DropStr,",") Drop(Char,DropItem,DropItem_old,eqPos,i,LeftPos,RightPos) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_DeleteDupDrops ;delete duplicates i=1 While (i<ItemCount(DropStr,",")) If (ItemExtract(i,DropStr,",")==ItemExtract(i+1,DropStr,",")) DropStr = ItemRemove(i+1,DropStr,",") Else i = i+1 EndIf EndWhile Drop(i) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_FormatDropStatement ;order Drop statements by DropItems Per Line DropItemCount = ItemCount(DropStr,",") If (DropItemCount==0) DropStr = StrCat(@CRLF,"; nothing to drop") DropStrLines = 1 Drop(DropItemCount) Return EndIf ;Comment = " ; auto Drop" Comment = "" ItemsPerDrop = 8 i = 1 While (i<=DropItemCount) DropItem = ItemExtract(i,DropStr,",") DropItem = StrCat("Drop(",DropItem) DropStr = ItemReplace(DropItem,i,DropStr,",") i = i-1+ItemsPerDrop If (i<=DropItemCount) DropItem = ItemExtract(i,DropStr,",") DropItem = StrCat(DropItem,")",Comment,@CRLF) DropStr = ItemReplace(DropItem,i,DropStr,",") Else DropStr = StrCat(DropStr,")",Comment,@CRLF) EndIf i = i+1 EndWhile DropStr = StrReplace(DropStr,StrCat(@CRLF,","),@CRLF) DropStr = StrCat(@CRLF,DropStr) DropStrLines = 1+(DropItemCount/ItemsPerDrop) Drop(Comment,DropItem,DropItemCount,DropItemsPerLine,i) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_PasteDropStatement ClipPut(DropStr) If InStudio If wGetSelstate() wClearSel() GotoLine = ItemExtract(3,SelInfo,@TAB) GotoCol = ItemExtract(4,SelInfo,@TAB) If (GotoCol==1) GotoLine = GotoLine - 1 EndIf wGotoLine(GotoLine) wEnd() wPaste() wHome() wGotoLine(GotoLine + DropStrLines) EndIf EndIf Drop(GotoCol,GotoLine) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_SortDialogObjects ; Sort object lines of WIL Dialog for tabbing around the fields. sGlobalNr = 25 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sBBTag = BinaryTagInit(hBB,@LF,StrCat(" ",@CR)) ; fetch the dialog name dialog_name = "" While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break dialog_line = BinaryTagExtr(sBBTag,1) If (dialog_line=="") Then Continue If (StrTrim(ItemExtract(2,dialog_line,"="))=="`WWWDLGED,5.0`") dialog_name = StrTrim(ItemExtract(1,dialog_line,"=")) dialog_name = StrSub(dialog_name,1,StrLen(dialog_name)-StrLen("Format")) Break EndIf EndWhile If (dialog_name=="") TheLogo = ItemExtract(1,sGlobal,@TAB) MsgText = StrCat('"DialogSort" needs a complete dialog script marked.',@CRLF,@CRLF) MsgText = StrCat(MsgText,'From line:',@CRLF,@TAB,'ExampleFormat=`WWWDLGED,5.0`',@CRLF) MsgText = StrCat(MsgText,'To line:',@CRLF,@TAB,'Buttonpushed=Dialog("Example")') Message(TheLogo,MsgText) Return ; accident, no WIL Dialog EndIf ; fetch object lines dialog_pos = StrLen(dialog_name) + 1 dialog_object_list = "Caption,X,Y,Width,Height,NumControls,Format" dialog_object_list = StrLower(dialog_object_list) sort_list = "" While @TRUE sBBTag=BinaryTagFind(sBBTag) If (sBBTag=="") Then Break dialog_line = BinaryTagExtr(sBBTag,1) If (dialog_line=="") Then Continue dialog_object = StrTrim(ItemExtract(1,dialog_line,"=")) dialog_object = StrSub(dialog_object,dialog_pos,-1) dialog_object = StrLower(dialog_object) If (ItemLocate(dialog_object,dialog_object_list,",") > 0) Then Continue If IsInt(dialog_object) dialog_object = ItemExtract(2,dialog_line,"=") ; Assuming BackQuote sign is only be used twice to quote entire dialog line. dialog_object = ItemExtract(2,dialog_object,"`") dialog_x = ItemExtract(1,dialog_object,",") dialog_y = ItemExtract(2,dialog_object,",") dialog_w = ItemExtract(3,dialog_object,",") dialog_h = ItemExtract(4,dialog_object,",") dialog_x = StrTrim(dialog_x) dialog_y = StrTrim(dialog_y) dialog_w = StrTrim(dialog_w) dialog_h = StrTrim(dialog_h) If IsInt(dialog_x) Then dialog_x = 0 + dialog_x If IsInt(dialog_y) Then dialog_y = 0 + dialog_y If IsInt(dialog_w) Then dialog_w = 0 + dialog_w If IsInt(dialog_h) Then dialog_h = 0 + dialog_h sort_x = StrFixLeft(dialog_x,"0",3) sort_y = StrFixLeft(dialog_y,"0",3) If (DialogSortZero == 1) If IsInt(dialog_x) Then dialog_x = StrFixLeft(dialog_x,"0",3) If IsInt(dialog_y) Then dialog_y = StrFixLeft(dialog_y,"0",3) If IsInt(dialog_w) Then dialog_w = StrFixLeft(dialog_w,"0",3) If IsInt(dialog_h) Then dialog_h = StrFixLeft(dialog_h,"0",3) EndIf dialog_object = ItemReplace(dialog_x,1,dialog_object,",") dialog_object = ItemReplace(dialog_y,2,dialog_object,",") dialog_object = ItemReplace(dialog_w,3,dialog_object,",") dialog_object = ItemReplace(dialog_h,4,dialog_object,",") sort_item = "" Select DialogSortDirection Case 2 sort_item = ItemInsert(sort_y,-1,sort_item,"|") sort_item = ItemInsert(sort_x,-1,sort_item,"|") Break Case 1 sort_item = ItemInsert(sort_x,-1,sort_item,"|") sort_item = ItemInsert(sort_y,-1,sort_item,"|") Break EndSelect sort_item = ItemInsert(dialog_object,-1,sort_item,"|") sort_list = ItemInsert(sort_item,-1,sort_list,@TAB) bb_pos= BinaryTagIndex(sBBTag,1) sBBTag = BinaryTagRepl(sBBTag,"") EndIf EndWhile ;bb_header = BinaryPeekStr(bb,0,bb_pos-1) bb_footer = BinaryPeekStr(hBB,bb_pos+1,BinaryEodGet(hBB)-bb_pos) sort_list = ItemSort(sort_list,@TAB) sort_count = ItemCount(sort_list,@TAB) BinaryEodSet(hBB,bb_pos) For isort=1 To sort_count dialog_line = "" sort_item = ItemExtract(isort,sort_list,@TAB) dialog_object = ItemExtract(3,sort_item,"|") dialog_object = ItemInsert("",0,dialog_object,"`") dialog_object = ItemInsert("",-1,dialog_object,"`") dialog_nr = StrFixLeft(isort,"0",2) dialog_name_nr = StrCat(dialog_name,dialog_nr) dialog_line = ItemInsert(dialog_name_nr,0,dialog_line,"=") dialog_line = ItemInsert(dialog_object,-1,dialog_line,"=") dialog_line = StrCat(dialog_line,@CRLF) BinaryPokeStr(hBB,BinaryEodGet(hBB),dialog_line) Next BinaryPokeStr(hBB,BinaryEodGet(hBB),bb_footer) Drop(bb_footer,bb_pos,dialog_h,dialog_line,dialog_name,dialog_name_nr,dialog_nr,dialog_object) Drop(dialog_object_list,dialog_pos,dialog_w,dialog_x,dialog_y,isort,sort_count,sort_item) Drop(sort_list,sBBTag,sort_x,sort_y) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CommaAlign ; Align columns on comma position. sGlobalNr = 28 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sListWidthMax = "" For iPass=1 To 2 sBBTag = BinaryTagInit(hBB,@LF,StrCat(" ",@CR)) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag == "") Then Break sLine = BinaryTagExtr(sBBTag,1) sLine = StrTrim(sLine) sLineNewL = "" sLineNewR = "" sListWidth = "" iWidth = 0 If (StrIndexWild(sLine,"*=*",1) == 1) iWidth = iWidth + 1 sItem = ItemExtract(1,sLine,"=") sItem = StrTrim(sItem) iItemLen = StrLen(sItem) sListWidth = ItemInsert(iItemLen,iWidth,sListWidth,@TAB) sLine = ItemRemove(1,sLine,"=") sLine = StrTrim(sLine) If (iPass == 2) Then sLineNewL = StrCat(StrFix(sItem," ",ItemExtract(iWidth,sListWidthMax,@TAB)),"=") EndIf iStrLen = StrLen(sLine) For i=1 To 3 If (i == 1) Then sQuote = "`" If (i == 2) Then sQuote = "'" If (i == 3) Then sQuote = '"' If (StrIndexWild(sLine,StrCat(sQuote,"*",sQuote),1) == 1) iStrLen = iStrLen - 2 sLine = StrSub(sLine,2,iStrLen) Break EndIf sQuote = "" Next iLastComma = 0 iChar = 1 While @TRUE sChar = StrSub(sLine,iChar,1) Select 1 Case (sChar == '"') Case (sChar == "'") Case (sChar == "`") While @TRUE iChar = iChar + 1 If (iChar >= iStrLen) Then Break sCharTemp = StrSub(sLine,iChar,1) If (sCharTemp == sChar) Then Break EndWhile Break Case (sChar == "") Case (sChar == ",") iWidth = iWidth + 1 sItem = StrSub(sLine,1+iLastComma,iChar-1-iLastComma) sItem = StrTrim(sItem) iLastComma = iChar If (iPass == 1) Then sListWidth = ItemInsert(StrLen(sItem),iWidth,sListWidth,@TAB) If (iPass == 2) Then sLineNewR = ItemInsert(StrFix(sItem," ",ItemExtract(iWidth,sListWidthMax,@TAB)),-1,sLineNewR,",") Break EndSelect If (iChar > iStrLen) Then Break iChar = iChar + 1 EndWhile If (iPass == 1) iWidthMaxCount = ItemCount(sListWidthMax,@TAB) iWidthCount = ItemCount(sListWidth,@TAB) iCount = Max(iWidthCount,iWidthMaxCount) sListWidthTemp = "" For iItem=1 To iCount sItemWidthMax = ItemExtract(iItem,sListWidthMax,@TAB) sItemWidth = ItemExtract(iItem,sListWidth,@TAB) sItemWidthNew = sItemWidthMax If (sItemWidth > sItemWidthMax) Then sItemWidthNew = sItemWidth sListWidthTemp = ItemInsert(sItemWidthNew,-1,sListWidthTemp,@TAB) Next sListWidthMax = sListWidthTemp Drop(iCount,iItem,iWidthCount,iWidthMaxCount,sItemWidth,sItemWidthMax,sItemWidthNew,sListWidthTemp) EndIf If (iPass == 2) If (sQuote > "") Then sLineNewR = StrCat(sQuote,sLineNewR,sQuote) sBBTag = BinaryTagRepl(sBBTag,StrCat(@LF,sLineNewL,sLineNewR,@CR)) EndIf EndWhile Next Drop(i,iChar,iCount,iItem,iItemLen,iLastComma,iPass,iStrLen) Drop(iWidth,iWidthCount,iWidthMaxCount,sBBTag,sCharTemp,sItem,sItemWidth,sItemWidthMax) Drop(sItemWidthNew,sLine,sLineNewL,sLineNewR,sListWidth,sListWidthMax,sListWidthTemp,sQuote) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_EqualSignAlign ; Group align statement lines along the leftmost EqualSign position. sGlobalNr = 28 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message ; Pass 1 ; Read lines and store the maximum width of the first item in line, that is separated by equal sign "=". iWidthMax = 0 sBBTag = BinaryTagInit(hBB,@LF,StrCat(" ",@CR)) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag == "") Then Break sLine = BinaryTagExtr(sBBTag,1) sLine = StrTrim(sLine) If (StrIndexWild(sLine,"*=*",1) == 1) sItem = ItemExtract(1,sLine,"=") sItem = StrTrim(sItem) iItemLen = StrLen(sItem) If (iItemLen>iWidthMax) Then iWidthMax = iItemLen EndIf EndWhile ; Pass 2 ; StrFix the first item in line by maximum width as detected in Pass 1, and replace the line. sBBTag = BinaryTagInit(hBB,@LF,StrCat(" ",@CR)) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag == "") Then Break sLine = BinaryTagExtr(sBBTag,1) sLine = StrTrim(sLine) If (StrIndexWild(sLine,"*=*",1) == 1) sItem = ItemExtract(1,sLine,"=") sItem = StrTrim(sItem) sItem = StrFix(sItem," ",iWidthMax) sLine = ItemReplace(sItem,1,sLine,"=") EndIf sBBTag = BinaryTagRepl(sBBTag,StrCat(@LF,sLine,@CR)) EndWhile Drop(iItemLen,iWidthMax,sBBTag,sItem,sLine) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_PasteDialogStatement BinaryClipPut(hBB,1) wEdPaste() BinaryFree(hBB) Drop(hBB) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CollectUDFs ;collect udfs from marked area and copy them into Studio's INI file "WIL.CLR" If InStudio If wGetSelstate() GotoLine = ItemExtract(1,SelInfo,@TAB) GotoCol = ItemExtract(2,SelInfo,@TAB) wClearSel() EndIf EndIf ItemList="" struct=BinaryTagInit(hBB,"#DefineSubRoutine","(") While @TRUE struct=BinaryTagFind(struct) If (struct=="") Then Break item=StrTrim(BinaryTagExtr(struct,0)) ItemList=ItemInsert(item,-1,ItemList,@TAB) EndWhile struct=BinaryTagInit(hBB,"#DefineFunction","(") While @TRUE struct=BinaryTagFind(struct) If (struct=="") Then Break item=StrTrim(BinaryTagExtr(struct,0)) ItemList=ItemInsert(item,-1,ItemList,@TAB) EndWhile If (ItemList=="") Drop(GotoCol,GotoLine,item,ItemList,struct) Return EndIf :firststuff ;Is it my udf? udflist="" udfpatternlist="udf*,*udf,uds*,*uds" pcount=ItemCount(udfpatternlist,",") iCount=ItemCount(ItemList,@TAB) For i=1 To iCount item=ItemExtract(i,ItemList,@TAB) For p=1 To pcount udfpattern=ItemExtract(p,udfpatternlist,",") If (StrIndexWild(item,udfpattern,1) > 0) If (ItemLocate(item,udflist,@TAB)==0) Then udflist=ItemInsert(item,-1,udflist,@TAB) Break EndIf Next Next udfcount=ItemCount(udflist,@TAB) For i=1 To udfcount IniWritePvt("KEYWORDS",ItemExtract(i,udflist,@TAB),"UDF",StrCat(DirHome(),"WIL.CLR")) Next :secondstuff ; modify color user dialog rgb1 ="Black.0,0,0" rgb2 ="Blue.0,0,255" rgb3 ="Green.0,255,0" rgb4 ="Red.255,0,0" rgb5 ="Cyan.0,255,255" rgb6 ="Yellow.255,255,0" rgb7 ="Magenta.255,0,255" rgb8 ="Dark Blue.0,0,128" rgb9 ="Dark Cyan.0,128,128" rgb10="Dark Gray.064,064,064" rgb11="Dark Green.0,160,0" rgb12="Dark Magenta.128,0,128" rgb13="Dark Red.128,0,0" rgb14="Dark Yellow/Brown.128,096,048" rgb15="Gray.128,128,128" rgb16="Light Gray.192,192,192" rgb17="Lighter Gray.221,221,221" rgblist="" dialoglist="" For i=1 To 17 rgblist=ItemInsert(ItemExtract(2,rgb%i%,"."),-1,rgblist,@TAB) dialoglist=ItemInsert(ItemExtract(1,rgb%i%,"."),-1,dialoglist,@TAB) Next dialoglist_save=dialoglist Canceled=@FALSE Done=@FALSE While !Done IntControl(33,0,0,0,0) dialoglist=dialoglist_save RGBSelectFormat=`WWWDLGED,5.0` RGBSelectCaption=`UDF Color Selection` RGBSelectX=400 RGBSelectY=60 RGBSelectWidth=70 RGBSelectHeight=150 RGBSelectNumControls=4 RGBSelect01=`014,002,040,DEFAULT,STATICTEXT,DEFAULT ,"Select udf color"` RGBSelect02=`000,014,070,130 ,ITEMBOX ,dialoglist,DEFAULT` RGBSelect03=`003,135,028,DEFAULT,PUSHBUTTON,DEFAULT ,"&OK" ,1` RGBSelect04=`035,135,030,DEFAULT,PUSHBUTTON,DEFAULT ,"&Cancel" ,2` ButtonPushed=Dialog("RGBSelect") Select ButtonPushed Case 1 If (dialoglist<>"") dialogpos=ItemLocate(dialoglist,dialoglist_save,@TAB) rgbvalue=ItemExtract(1,ItemExtract(dialogpos,rgblist,@TAB),".") IniWritePvt("COLORS","UDF",rgbvalue,StrCat(DirHome(),"WIL.CLR")) Done=@TRUE EndIf Break Case 2 Done=@TRUE Canceled=@TRUE Break EndSelect EndWhile Drop(ButtonPushed,dialoglist,dialoglist_save,dialogpos,i) DropWild("rgb*") If Canceled Drop(Canceled) Return EndIf :thirdstuff ;put list on top of the file ItemList="" struct=BinaryTagInit(hBB,"#DefineSubRoutine",")") While @TRUE struct=BinaryTagFind(struct) If (struct=="") Then Break item=StrTrim(BinaryTagExtr(struct,0)) item=StrCat("; ",StrFix(StrCat(item,")")," ",115)," ; ",TimeYmdHms()) ItemList=ItemInsert(item,-1,ItemList,@TAB) EndWhile struct=BinaryTagInit(hBB,"#DefineFunction",")") While @TRUE struct=BinaryTagFind(struct) If (struct=="") Then Break item=StrTrim(BinaryTagExtr(struct,0)) item=StrCat("; ",StrFix(StrCat(item,")")," ",115)," ; ",TimeYmdHms()) ItemList=ItemInsert(item,-1,ItemList,@TAB) EndWhile ItemList=StrCat(";",StrFill("-",138),@TAB,ItemList,@TAB,";",StrFill("-",138),@TAB) iLineCount=ItemCount(ItemList,@TAB)-1 ItemList = StrReplace(ItemList,@TAB,@CRLF) ClipPut(ItemList) If InStudio wTopOfFile() wPaste() wGotoLine(GotoLine+iLineCount) wGotoCol(GotoCol) EndIf Drop(GotoCol,GotoLine,iLineCount,i,iCount,item,ItemList,p,pattern) ; auto Drop Drop(patternlist,pcount,struct,udfcount,udflist) ; auto Drop Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_MarkComments sGlobalNr = 10 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sBBTag = BinaryTagInit(hBB,StrCat(@LF,";"),@CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break sBBTag = BinaryTagRepl(sBBTag,StrCat(@LF,"#_Comment_Line ",@CR)) EndWhile Drop(sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_MarkCommentsInLine sGlobalNr = 11 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sBBTag = BinaryTagInit(hBB,";",@CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break sBBTag = BinaryTagRepl(sBBTag,StrCat(" #_Comment_InLine ",@CR)) EndWhile Drop(sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_ReplaceOperators sGlobalNr = 12 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sOpList = "-\+\=\!\<\>\&\|\^\*\/\%%\~\(\)\,\." iOpItemCount = ItemCount(sOpList,"\") BinaryEodSet(hBB,BinaryEodGet(hBB)-1) ; workaround bug in BinaryReplace For i=1 To iOpItemCount sOpItem = ItemExtract(i,sOpList,"\") While BinaryReplace(hBB,sOpItem," ",@TRUE) EndWhile Next i BinaryEodSet(hBB,BinaryEodGet(hBB)+1) ; workaround bug in BinaryReplace ; Beauty_OneSpaceCleaning While BinaryReplace(hBB," "," ",@TRUE) EndWhile Drop(i,iOpItemCount,sOpList,sOpItem) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_MarkEmptyLines sGlobalNr = 13 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message sBBTag = BinaryTagInit(hBB, StrCat(@LF," "), @CR) While @TRUE sBBTag = BinaryTagFind(sBBTag) If (sBBTag=="") Then Break sBBTag = BinaryTagRepl(sBBTag,StrCat(@LF,"#_Empty_Line ",@CR)) EndWhile Drop(sBBTag) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_PrepareSort LastExclusive = Exclusive(@ON) ; Try to run WIL interpreter somewhat faster. ; copy words and linenumbers to buffer2 for sorting and reporting ; somewhat slow, but works ... sGlobalNr = 14 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message words_sum = BinaryStrCnt(hBB,0,BinaryEodGet(hBB)-1," ") bb2_NameSize = 30 bb2_LineSize = 5 bb2_RecSize = bb2_NameSize+bb2_LineSize bb2_Size = words_sum*bb2_RecSize hBB2 = BinaryAlloc(bb2_Size) bb2_Offset = 0 Eow = " " EowLen = StrLen(Eow) Eol = @CRLF EolLen = StrLen(Eol) Line = 0 wordbegin = 0 words = 0 While @TRUE wordend = BinaryIndexEx(hBB,wordbegin,Eow,@FWDSCAN,@TRUE) If (wordend<0) Then Break If !((100*words/words_sum) mod 10) sGlobalNr = 20 Beauty_Message_MaxCount = words_sum Beauty_Message_Count = words GoSub Beauty_Message EndIf words = words+1 wordlen = wordend-wordbegin LineStr = StrFixLeft(Line," ",bb2_LineSize) BinaryCopy(hBB2,bb2_Offset,hBB,wordbegin,wordlen) BinaryPokeStr(hBB2,bb2_Offset+bb2_NameSize,LineStr) bb2_Offset = bb2_Offset+bb2_RecSize wordbegin = wordend+EowLen If (BinaryPeekStr(hBB,wordbegin,EolLen)==Eol) Line = Line+1 wordbegin = wordbegin+EolLen EndIf EndWhile BinaryReplace(hBB2,""," ",@TRUE) BinaryFree(hBB) Exclusive(LastExclusive) ; Back to previous WIL interpreter performance. Drop(Eol,EolLen,Eow,EowLen) Drop(Line,LineStr,num,wordbegin,wordend,wordlen,words) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_Sort ; Do the beautiful sort. sGlobalNr = 15 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message BinarySort(hBB2,bb2_RecSize,0,bb2_RecSize,@STRING|@ASCENDING) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_CreateReport sGlobalNr = 16 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message LastExclusive = Exclusive(@ON) ; Try to run WIL interpreter somewhat faster. LitTag = "#_$_" LitCodeTag = StrCat(LitTag,"?????") words = 1 sReport = "" bb2_Offset = bb2_RecSize ; skip over workmark Line=0 Name = BinaryPeekStr(hBB2,bb2_Offset,bb2_NameSize) While (bb2_Offset<bb2_Size) literal = (StrSub(Name,1,4)==LitTag) If literal LitCode = StrSub(Name,5,5) BinaryPokeStr(hBBLit1,0,LitCode) BinaryXor(hBBLit1,0,hBBLit2,0,5) LitNr = BinaryPeekStr(hBBLit1,0,5) Name = StrFix(StrCat(LitTag,LitNr)," ",30) LitStr = ItemExtract(LitNr,LitList,@TAB) While @TRUE LitNestedPos = StrIndexWild(LitStr,LitCodeTag,1) If !LitNestedPos Then Break LitNestedCode = StrSub(LitStr,LitNestedPos+StrLen(LitTag),5) BinaryPokeStr(hBBLit1,0,LitNestedCode) BinaryXor(hBBLit1,0,hBBLit2,0,5) LitNestedNr = BinaryPeekStr(hBBLit1,0,5) replace = ItemExtract(LitNestedNr,LitList,@TAB) search = StrCat(" ",LitTag,LitNestedCode," ") LitStr = StrReplace(LitStr,search,replace) EndWhile EndIf sReport = StrCat(sReport,Name,@TAB) Name_old = Name LineList = "" Line_old = "" While @TRUE Line = BinaryPeekStr(hBB2,bb2_Offset+bb2_NameSize,bb2_LineSize) If !((100*words/words_sum) mod 10) sGlobalNr = 21 Beauty_Message_MaxCount = words_sum Beauty_Message_Count = words GoSub Beauty_Message EndIf words = words+1 If (Line<>Line_old) Line_old = Line LineList = ItemInsert(Line,-1,LineList,",") EndIf bb2_Offset = bb2_Offset+bb2_RecSize If !(bb2_Offset<bb2_Size) Then Break Name = BinaryPeekStr(hBB2,bb2_Offset,bb2_NameSize) If (Name<>Name_old) Then Break EndWhile Items = ItemCount(LineList,",") If (Items==1) If literal LineList = StrCat(LineList,@TAB,LitStr) EndIf Else it = 11 While !(it>Items) Item = ItemExtract(it,LineList,",") Item = StrCat(@CR,StrFill(" ",bb2_NameSize),@TAB,Item) LineList = ItemReplace(Item,it,LineList,",") it = it + 10 EndWhile EndIf sReport = StrCat(sReport,LineList,@CR) EndWhile BinaryFree(hBB2) Exclusive(LastExclusive) ; Back to previous WIL interpreter performance. Drop(hBB2_Offset,it,Item,Items,Line,Line_old,LineList,Name,Name_old) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_AppendReportToScript sGlobalNr = 17 Beauty_Message_MaxCount = "" Beauty_Message_Count = "" GoSub Beauty_Message TheFileIn = ItemExtract(33,sGlobal,@TAB) TheFileOut = ItemExtract(32,sGlobal,@TAB) sReport = StrCat(TheFileIn,@CR,@CR,sReport) sReport = StrCat(@CR,StrFill("-",100),@CR,sReport) sReport = StrCat(sReport,@CR,TimeYmdHms()," ",ItemExtract(1,sGlobal,@TAB)) sReport = StrCat(sReport,@CR,StrFill("-",100)) sReport = StrReplace(sReport,@CR,StrCat(@CRLF,";",@TAB)) If InStudio ClipPut(sReport) wClearSel() wEndOfFile() wPaste() Else hFA = FileOpen(TheFileOut,"APPEND") FileWrite(hFA,sReport) FileClose(hFA) EndIf Drop(hFA,sReport,TheFileIn,TheFileOut) Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_MessageClose If InStudio wStatusMsg("") Else BoxShut() EndIf Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_DefineGlobalVar ; I use this way of a string list because of issues while using arrays in WinBatch Studio sGlobal = "" ; 33 Items sGlobal = ItemInsert("Beautifier Tools v0.99v (c)20010401-20030627 Detlev Dalitz",-1,sGlobal,@TAB) ; 01 sGlobal = ItemInsert("Cleanup Pre ...",-1,sGlobal,@TAB) ; 02 sGlobal = ItemInsert("Cleanup Post ...",-1,sGlobal,@TAB) ; 03 sGlobal = ItemInsert("Deleting Comments ...",-1,sGlobal,@TAB) ; 04 sGlobal = ItemInsert("Deleting Literals ...",-1,sGlobal,@TAB) ; 05 sGlobal = ItemInsert("Marking Literals ...",-1,sGlobal,@TAB) ; 06 sGlobal = ItemInsert("Deleting InLine Comments ...",-1,sGlobal,@TAB) ; 07 sGlobal = ItemInsert("Deleting Operators ...",-1,sGlobal,@TAB) ; 08 sGlobal = ItemInsert("Creating Droplist ...",-1,sGlobal,@TAB) ; 09 sGlobal = ItemInsert("Marking Comments ...",-1,sGlobal,@TAB) ; 10 sGlobal = ItemInsert("Marking InLine Comments ...",-1,sGlobal,@TAB) ; 11 sGlobal = ItemInsert("Replacing Operators ...",-1,sGlobal,@TAB) ; 12 sGlobal = ItemInsert("Marking Empty Lines ...",-1,sGlobal,@TAB) ; 13 sGlobal = ItemInsert("Preparing ...",-1,sGlobal,@TAB) ; 14 sGlobal = ItemInsert("Sorting ...",-1,sGlobal,@TAB) ; 15 sGlobal = ItemInsert("Reporting ...",-1,sGlobal,@TAB) ; 16 sGlobal = ItemInsert("Writing ...",-1,sGlobal,@TAB) ; 17 sGlobal = ItemInsert("Tokenize ... # ",-1,sGlobal,@TAB) ; 18 sGlobal = ItemInsert("Indentation ... # ",-1,sGlobal,@TAB) ; 19 sGlobal = ItemInsert("Preparing ... # ",-1,sGlobal,@TAB) ; 20 sGlobal = ItemInsert("Reporting ... # ",-1,sGlobal,@TAB) ; 21 sGlobal = ItemInsert("DropMaker",-1,sGlobal,@TAB) ; 22 sGlobal = ItemInsert("Beautify",-1,sGlobal,@TAB) ; 23 sGlobal = ItemInsert("CrossRef",-1,sGlobal,@TAB) ; 24 sGlobal = ItemInsert("Sorting Dialog Objects ...",-1,sGlobal,@TAB) ; 25 sGlobal = ItemInsert("Dialog Sorter",-1,sGlobal,@TAB) ; 26 sGlobal = ItemInsert("UDF Colorize Collector",-1,sGlobal,@TAB) ; 27 sGlobal = ItemInsert("Aligning ...",-1,sGlobal,@TAB) ; 28 sGlobal = ItemInsert("CommaAligner",-1,sGlobal,@TAB) ; 29 sGlobal = ItemInsert("EqualSignAligner",-1,sGlobal,@TAB) ; 30 sGlobal = ItemInsert(".",-1,sGlobal,@TAB) ; Reserved for current modul. ; 31 sGlobal = ItemInsert("",-1,sGlobal,@TAB) ; Reserved for TheFileOut. ; 32 sGlobal = ItemInsert("",-1,sGlobal,@TAB) ; Reserved for TheFileIn. ; 33 If !IsDefined(Beauty_Message_MaxCount) Then Beauty_Message_MaxCount = "" If !IsDefined(Beauty_Message_Count) Then Beauty_Message_Count = "" Return ;------------------------------------------------------------------------------------------------------------------------------------------ :Beauty_Message ; uses sGlobal,sGlobalNr,Beauty_Message_MaxCount,Beauty_Message_Count sOut = "" If IsInt(Beauty_Message_MaxCount) Then If IsInt(Beauty_Message_Count) Then If Beauty_Message_Count Then sOut = StrCat(Beauty_Message_MaxCount,"/",Beauty_Message_Count) sOut = StrCat(ItemExtract(sGlobalNr,sGlobal,@TAB),sOut) ; current task sOut = StrCat(ItemExtract(31,sGlobal,@TAB)," ",sOut) ; current modul If (RtStatus()==10) ; InStudio wStatusMsg(sOut) Else sOut = StrCat("out:",@TAB,ItemExtract(32,sGlobal,@TAB),@CRLF,@CRLF,sOut) sOut = StrCat("in:",@TAB,ItemExtract(33,sGlobal,@TAB),@CRLF,sOut) BoxOpen(ItemExtract(1,sGlobal,@TAB),sOut) EndIf Return ;========================================================================================================================================== :Test_Stuff ; --- test stuff begin --- If (CallParam0==0) ; only for debugging and testing in WinBatch Studio Editor ; CmdLine="bc ""W:\WINBATCH\2001\Test\test.wbt"" ""W:\WINBATCH\2001\Test\test.txt""" ; CmdLine="b ""W:\WINBATCH\2001\WinBatch Test\Test.Beat.wbt"" ""W:\WINBATCH\2001\WinBatch Test\Test.Beat.wbt""" ; CmdLine="bc" ; CmdLine="d" ; CmdLine="b" ; CmdLine="ds" ; CmdLine="ca" ; CmdLine="ea" ; CmdLine="u" If IsDefined(CmdLine) ParseData(CmdLine) For i=0 To 9 CallParam%i% = "" If IsDefined(Param%i%) Then CallParam%i% = Param%i% Next i EndIf EndIf ; --- test stuff end --- Return ;========================================================================================================================================== *EOF*
;=========================================================================================================================================== ; Example for EqualSignAligner ;=========================================================================================================================================== ; Pre: sSearch=StrCat(@LF,"1",@TAB,sKeyword) sReplace=StrCat(@LF,iToken,@TAB,sKeyword) iReplaceCount=BinaryReplace(hBB,sSearch,sReplace,@FALSE) iCount=iCount+iReplaceCount sItemList="" ; Post: sSearch =StrCat(@LF,"1",@TAB,sKeyword) sReplace =StrCat(@LF,iToken,@TAB,sKeyword) iReplaceCount=BinaryReplace(hBB,sSearch,sReplace,@FALSE) iCount =iCount+iReplaceCount sItemList ="" ;===========================================================================================================================================
;=========================================================================================================================================== ; Examples for CommaAligner ;=========================================================================================================================================== ; Pre: MyDialog01=`006,006,164,DEFAULT,VARYTEXT,TheFileIn,""` MyDialog02=`012,022,052,DEFAULT,STATICTEXT,DEFAULT,"Show&Literals"` MyDialog03=`056,022,036,DEFAULT,CHECKBOX,ShowLiterals,"",1` MyDialog04=`012,034,050,DEFAULT,STATICTEXT,DEFAULT,"&ShortenLiterals"` MyDialog05=`056,034,036,DEFAULT,CHECKBOX,ShortenLiterals,"",1` MyDialog06=`004,050,164,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog07=`048,066,078,DEFAULT,PUSHBUTTON,DEFAULT,"&Abort",0` ; Post: MyDialog01=`006,006,164,DEFAULT,VARYTEXT ,TheFileIn ,"" ` MyDialog02=`012,022,052,DEFAULT,STATICTEXT,DEFAULT ,"Show&Literals" ` MyDialog03=`056,022,036,DEFAULT,CHECKBOX ,ShowLiterals ,"" ,1` MyDialog04=`012,034,050,DEFAULT,STATICTEXT,DEFAULT ,"&ShortenLiterals"` MyDialog05=`056,034,036,DEFAULT,CHECKBOX ,ShortenLiterals,"" ,1` MyDialog06=`004,050,164,DEFAULT,PUSHBUTTON,DEFAULT ,"&OK" ,1` MyDialog07=`048,066,078,DEFAULT,PUSHBUTTON,DEFAULT ,"&Abort" ,0` ; Pre: BinaryReplace(hBB,@TAB,"",@TRUE) BinaryReplace(hBB,@CRLF,@CR,@TRUE) BinaryReplace(hBB,@LF,@CR,@TRUE) BinaryReplace(hBB,@CR,@CRLF,@TRUE) ; Post: BinaryReplace(hBB,@TAB ,"" ,@TRUE) BinaryReplace(hBB,@CRLF,@CR ,@TRUE) BinaryReplace(hBB,@LF ,@CR ,@TRUE) BinaryReplace(hBB,@CR ,@CRLF,@TRUE) ;===========================================================================================================================================
;=========================================================================================================================================== ; Example for DropMaker ;=========================================================================================================================================== ; Pre: iCount = 1 iTokenCount = 7 For iToken=1 To iTokenCount iKeywordCount = ItemCount(sKeywordList%iToken%,",") For iKeyword=2 To iKeywordCount sKeyword = ItemExtract(iKeyword,sKeywordList%iToken%,",") sSearch = StrCat(@LF,"1",@TAB,sKeyword) sReplace = StrCat(@LF,iToken,@TAB,sKeyword) iReplaceCount = BinaryReplace(hBB,sSearch,sReplace,@FALSE) iCount = iCount + iReplaceCount sGlobalNr = 18 Beauty_Message_MaxCount = MaxLines Beauty_Message_Count = iCount GoSub Beauty_Message Next Next ; Added: Drop(Beauty_Message_Count,Beauty_Message_MaxCount,iCount,iKeyword,iKeywordCount,iReplaceCount,iToken,iTokenCount) Drop(sGlobalNr,sKeyword,sReplace,sSearch) ;===========================================================================================================================================
;=========================================================================================================================================== ; Examples for DialogSort ;=========================================================================================================================================== ; Pre: ; Sorted by X-Pos with zeroes supressed. MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Dialog Sorter Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=172 MyDialogHeight=84 MyDialogNumControls=7 MyDialog01=`4,50,164,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog02=`6,6,164,DEFAULT,VARYTEXT,TheFileIn,""` MyDialog03=`30,22,50,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &X-pos",1` MyDialog04=`30,32,50,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &Y-pos",2` MyDialog05=`48,66,78,DEFAULT,PUSHBUTTON,DEFAULT,"&Abort",0` MyDialog06=`104,22,52,DEFAULT,RADIOBUTTON,DialogSortZero,"&Leading Zeroes",1` MyDialog07=`104,34,52,DEFAULT,RADIOBUTTON,DialogSortZero,"&Suppress Zeroes",2` ButtonPushed=Dialog("MyDialog") ; Post: ; Sorted by X-Pos with leading zeroes. MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Dialog Sorter Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=172 MyDialogHeight=84 MyDialogNumControls=7 MyDialog01=`004,050,164,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog02=`006,006,164,DEFAULT,VARYTEXT,TheFileIn,""` MyDialog03=`030,022,050,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &X-pos",1` MyDialog04=`030,032,050,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &Y-pos",2` MyDialog05=`048,066,078,DEFAULT,PUSHBUTTON,DEFAULT,"&Abort",0` MyDialog06=`104,022,052,DEFAULT,RADIOBUTTON,DialogSortZero,"&Leading Zeroes",1` MyDialog07=`104,034,052,DEFAULT,RADIOBUTTON,DialogSortZero,"&Suppress Zeroes",2` ButtonPushed=Dialog("MyDialog") ; Post: ; Sorted by Y-Pos with zeroes supressed. MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Dialog Sorter Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=172 MyDialogHeight=84 MyDialogNumControls=7 MyDialog01=`6,6,164,DEFAULT,VARYTEXT,TheFileIn,""` MyDialog02=`30,22,50,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &X-pos",1` MyDialog03=`104,22,52,DEFAULT,RADIOBUTTON,DialogSortZero,"&Leading Zeroes",1` MyDialog04=`30,32,50,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &Y-pos",2` MyDialog05=`104,34,52,DEFAULT,RADIOBUTTON,DialogSortZero,"&Suppress Zeroes",2` MyDialog06=`4,50,164,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog07=`48,66,78,DEFAULT,PUSHBUTTON,DEFAULT,"&Abort",0` ButtonPushed=Dialog("MyDialog") ; Post: ; Sorted by Y-Pos with leading zeroes. MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`Dialog Sorter Options` MyDialogX=307 MyDialogY=100 MyDialogWidth=172 MyDialogHeight=84 MyDialogNumControls=7 MyDialog01=`006,006,164,DEFAULT,VARYTEXT,TheFileIn,""` MyDialog02=`030,022,050,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &X-pos",1` MyDialog03=`104,022,052,DEFAULT,RADIOBUTTON,DialogSortZero,"&Leading Zeroes",1` MyDialog04=`030,032,050,DEFAULT,RADIOBUTTON,DialogSortDirection,"Sort by &Y-pos",2` MyDialog05=`104,034,052,DEFAULT,RADIOBUTTON,DialogSortZero,"&Suppress Zeroes",2` MyDialog06=`004,050,164,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog07=`048,066,078,DEFAULT,PUSHBUTTON,DEFAULT,"&Abort",0` ButtonPushed=Dialog("MyDialog") ;===========================================================================================================================================
;=========================================================================================================================================== ; Example for CrossReferencer ;=========================================================================================================================================== ; Pre: If ItemLocate("udfcommatopoint", IntControl(77,103,0,0,0), @TAB) Then Goto skip_udfcommatopoint #DefineFunction udfCommaToPoint (num) num=StrClean(num,"0123456789.,E+-","",@FALSE,2) num=StrReplace(num, ".", ":") num=StrReplace(num, ",", ".") num=StrReplace(num, ":", ",") Return (num) #EndFunction :skip_udfcommatopoint If ItemLocate("udfpointtocomma", IntControl(77,103,0,0,0), @TAB) Then Goto skip_udfpointtocomma #DefineFunction udfPointToComma (num) num=StrClean(num,"0123456789.,E+-","",@FALSE,2) num=StrReplace(num, ",", ":") num=StrReplace(num, ".", ",") num=StrReplace(num, ":", ".") Return (num) #EndFunction :skip_udfpointtocomma ;--- test --- DecimalCommaNumber = "1.234.711,22" DecimalPointNumber = "1,234,711.22" Message("Demo udfCommaToPoint (num)",StrCat("from",@CRLF,"decimal comma ",DecimalCommaNumber,@CRLF,"to",@CRLF,"decimal point ",udfCommaToPoint(DecimalCommaNumber))) Message("Demo udfPointToComma (num)",StrCat("from",@CRLF,"decimal point ",DecimalPointNumber,@CRLF,"to",@CRLF,"decimal comma ",udfCommaToPoint(DecimalPointNumber))) Exit ; Added: ; CrossReference with literals. ; ---------------------------------------------------------------------------------------------------- ; #_$_00001 1 "udfcommatopoint" ; #_$_00002 3 "0123456789.,E+-" ; #_$_00003 3 "" ; #_$_00004 4 "." ; #_$_00005 4 ":" ; #_$_00006 5 "," ; #_$_00007 5 "." ; #_$_00008 6 ":" ; #_$_00009 6 "," ; #_$_00010 11 "udfpointtocomma" ; #_$_00011 13 "0123456789.,E+-" ; #_$_00012 13 "" ; #_$_00013 14 "," ; #_$_00014 14 ":" ; #_$_00015 15 "." ; #_$_00016 15 "," ; #_$_00017 16 ":" ; #_$_00018 16 "." ; #_$_00019 23 "1.234.711,22" ; #_$_00020 24 "1,234,711.22" ; #_$_00021 25 "Demo udfCommaToPoint (num)" ; #_$_00022 25 "from" ; #_$_00023 25 "decimal comma " ; #_$_00024 25 "to" ; #_$_00025 25 "decimal point " ; #_$_00026 26 "Demo udfPointToComma (num)" ; #_$_00027 26 "from" ; #_$_00028 26 "decimal point " ; #_$_00029 26 "to" ; #_$_00030 26 "decimal comma " ; #_Comment_Line 22 ; #_Empty_Line 10, 20, 21, 28 ; #DefineFunction 2, 12 ; #EndFunction 8, 18 ; :skip_udfcommatopoint 9 ; :skip_udfpointtocomma 19 ; @CRLF 25, 26 ; @FALSE 3, 13 ; @TAB 1, 11 ; 0 1, 11 ; 103 1, 11 ; 2 3, 13 ; 77 1, 11 ; DecimalCommaNumber 23, 25 ; DecimalPointNumber 24, 26 ; Exit 27 ; Goto 1, 11 ; If 1, 11 ; IntControl 1, 11 ; ItemLocate 1, 11 ; Message 25, 26 ; num 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, ; 16, 17 ; Return 7, 17 ; skip_udfcommatopoint 1 ; skip_udfpointtocomma 11 ; StrCat 25, 26 ; StrClean 3, 13 ; StrReplace 4, 5, 6, 14, 15, 16 ; Then 1, 11 ; udfCommaToPoint 2, 25, 26 ; udfPointToComma 12 ; ; 2003:06:28:12:54:40 Beautifier Tools v0.99v (c)20010401-20030627 Detlev Dalitz ; ---------------------------------------------------------------------------------------------------- ;===========================================================================================================================================
;=========================================================================================================================================== ; Example for Beautifier ;=========================================================================================================================================== ; Pre: z=0 For i=1 To 3 If (i==1) Then x=10 If (i==2) x=20 y=30 EndIf ; comment line If (i==3) If (x==0) Then Break EndIf z=z+1 Next ; Post: ; Left Margin=0 ; Indentation=3 ; Comments not shifted to left margin ; No tabs z=0 For i=1 To 3 If (i==1) Then x=10 If (i==2) x=20 y=30 EndIf ; comment line If (i==3) If (x==0) Then Break EndIf z=z+1 Next ; Post: ; Left Margin=5 ; Indentation=10 ; Comments shifted to left margin ; No tabs z=0 For i=1 To 3 If (i==1) Then x=10 If (i==2) x=20 y=30 EndIf ; comment line If (i==3) If (x==0) Then Break EndIf z=z+1 Next ;===========================================================================================================================================
Page Date 2004-05-18 DD-Software |
|
|
|
MyWbtHelp current version |