Page Date
2004-05-18
DD-Software
Kapitel zurück / previous Chapter
Main Index
 
Seite zurück / previous page
Backward
Seite vor / next page
Forward
 
Seitenanfang/TopOfPage
Top
Seitenende/EndOfPage
Bottom
MyWbtHelp current version

WinBatch Studio Editor Scripts



Seitenanfang/TopOfPage Seitenende/EndOfPage
Seitenanfang/TopOfPage Seitenende/EndOfPage

WBStudio.LargeFileOpenPanel (WBT utility for a larger file open panel)

;------------------------------------------------------------------------------------------------------------------------------------------
; WBStudioLargeFileOpenPanel.wbt
; Winbatch utility for a larger file open panel.
;------------------------------------------------------------------------------------------------------------------------------------------
; Steffen Fraas, sfraas@zoo.co.uk 20010405
; Modified by Detlev Dalitz.20020130
;------------------------------------------------------------------------------------------------------------------------------------------
; Usage: Create a shortcut to this script on desktop or on taskbar and run the shortcut.
;------------------------------------------------------------------------------------------------------------------------------------------

IntControl(1002,0,0,0,0) ; Hide icon.
RunZoom("WinBatch Studio.exe","") ; Start up Winbatch Studio, change as required.
AddExtender("WWCTL34I.DLL") ; Load extender.

; Save mouse position for later re-positioning.
mousememo = StrCat("MouseMove(",StrReplace(MouseInfo(2)," ",","),',"","")')

While WinExist("WinBatch Studio") ; Whilst winbatching...

   ; Open dialog FileOpen.
   ControlHandle=cWndByWndSpec("WinBatchStudioMainWndClass","WINBATCH STUDIO",6,59648,59393,59419,59422,59420,59421)
   cSetFocus(ControlHandle)  ; Activates Window
   TimeDelay(1)
   SendKey(`^o`) ; Sends Keystrokes.

   If WinExist("Open") ; Wait for open (control-o) request.

      window1=cWndByWndSpec("#32770","WINBATCH STUDIO",13,1091,1137,1088,1120,1121,1090,1152,1089,1136,1040,1,2,1038)
      cSetFocus(window1) ; Activates Window.

      ; move upper left corner
      Winid=cWinIDConvert(window1)
      MouseMove(3,3,Winid,"") ; Point at upper left of open panel.
      MousePlay("-270 -160",Winid,"",@MPLAYLBUTTON,0.1) ; Expand it.

      ; move lower right corner
      window2=cWndbyid(window1,-1)
      Winid=cWinIDConvert(window2)
      MouseMove(3,3,Winid,"") ; Point at lower right of open panel.
      MousePlay("280 420",Winid,"",@MPLAYLBUTTON,0.1) ; Expand it.

      ; choose details
      ControlHandle=cWndbyclass(window1,`ToolbarWindow32`)
      cClickToolbar(Controlhandle,9) ; Clicks a toolbar button.

      ; sort date descending
      window2=cWndbyid(window1,1121)
      window3=cWndbyid(window2,1)
      ControlHandle=cWndbyid(window3,0)
      winid=cWinIDConvert(ControlHandle)
      MouseMove(621,14,winid,"")
      MouseClick(@LCLICK,0) ; TODO - Check on various screen resolutions.

      ; put focus onto listview
      window2=cWndbyid(window1,1121)
      ControlHandle=cWndbyid(window2,1)
      cSetFocus(ControlHandle) ; Activates Window.

      ; Move mouse pointer to previously saved position.
      %mousememo%

   Exit ; Next open panel will be same size as last one. Job done, exit.
EndIf
TimeDelay(1) ; No open request yet.
EndWhile
Exit
;------------------------------------------------------------------------------------------------------------------------------------------




Seitenanfang/TopOfPage Seitenende/EndOfPage
Seitenanfang/TopOfPage Seitenende/EndOfPage

WBStudio.ForEachCollection (Utility to convert control structure from VB to WB)

;----------------------------------------------------------------------------------------------------------------------
; Interactive Utility for use in WinBatch Studio only.
; Converts from Visual Basic Control Structure:
;    "For Each ... In ... ... Next"
; to WinBatch Control Structure:
;    "hEnum = ObjectCollectionOpen(objecthandle) ... While ... EndWhile"
;----------------------------------------------------------------------------------------------------------------------
; For easy use just insert two lines into WSPOPUP.MNU, e.g.:
; _WBStudioForEachCollection \ {F7}
;     Call("W:\WBT\UDF\WBStudioForEachCollection.wbt","")
;
; Modify menu entry, filename, folderpath and hotkey to your needs.
;
; For undoing of replacements use standard hotkey Ctrl-Z
; or the symbol resp. item from WinBatch Studio menu.
;
; Search starts at current cursor position in forward direction.
;----------------------------------------------------------------------------------------------------------------------
; Detlev Dalitz.20020706.20020717
;----------------------------------------------------------------------------------------------------------------------

iCount = 0
iCurrentLine = wGetLineNo()
iCurrentCol  = wGetColNo()

wfPattern   = "for +each +(.+) +in +(.+)"
wfForward   = @TRUE
wfMatchCase = @FALSE
wfRegExp    = @TRUE
wfWrap      = @FALSE
wfResult    = wFind(wfPattern,wfForward,wfMatchCase,wfRegExp,wfWrap)

If !wfResult Then Goto CANCEL

Pause("WBStudioForEachCollection","Create WIL 'ObjectCollectionOpen' Loop?")

ParseData (wGetWord()) ; we need param3 and param5 as var names

iStartLine = ItemExtract(1,wSelInfo(),@TAB)
iStartCol  = ItemExtract(2,wSelInfo(),@TAB)
iIndent    = iStartCol + 3

wHome()
wStartSel()
wEnd()
wEndSel()
sLineHead = wGetWord()
wDelete()

wfPattern   = " *next *"
wfForward   = @TRUE
wfMatchCase = @FALSE
wfRegExp    = @TRUE
wfWrap      = @FALSE
wfResult    = wFind(wfPattern,wfForward,wfMatchCase,wfRegExp,wfWrap)

wHome()
wStartSel()
wEnd()
wEndSel()
sLineFoot = wGetWord()
wDelete()

wEnd()
wStartSel()
wHome()
wGotoLine(iStartLine)
wEndSel()
wCut()

wGotoCol(iStartCol)
wInsString(";")
wInsLine(StrTrim(sLineHead))
wGotoCol(iStartCol)
wInsLine('hEnum_%param3% = ObjectCollectionOpen(%param5%)')
wInsLine('While 1')
wGotoCol(iIndent)
wInsLine('%param3% = ObjectCollectionNext(hEnum_%param3%)')
wInsLine('If !%param3% Then Break')
iLineBody = wGetLineNo()
wNewLine()
wGotoCol(iIndent)
wInsLine('ObjectClose(%param3%)')
wGotoCol(iStartCol)
wInsLine('EndWhile')
wInsLine('ObjectCollectionClose(hEnum_%param3%)')
wInsLine('Drop(%param3%,hEnum_%param3%)')
wGotoCol(iStartCol)
wInsString(";")
wInsString(StrTrim(sLineFoot))
wGotoLine(iLineBody)
wHome()
wPaste()
iCount = 1

:CANCEL
wClearSel()
wGotoLine(iCurrentLine)
wGotoCol(iCurrentCol)
Message("WBStudioForEachCollection",StrCat("Replaced items: ",iCount))

Drop(iCount,iCurrentCol,iCurrentLine,iIndent,iLineBody,iStartCol,iStartLine)
Drop(sLineHead,sLineFoot,wfForward,wfMatchCase,wfPattern,wfRegExp,wfResult,wfWrap)
DropWild("param*")

If (IntControl(77,80,0,0,0) > 0) Then Return
Exit
;----------------------------------------------------------------------------------------------------------------------



; --- test area ---

; Visual Basic control structure

    If Files.Count <> 0 Then
         For Each File In Files
            S = S & GenerateFileInformation(File)
         Next
    End If


; WinBatch control structure

    If Files.Count <> 0 Then
         ;For Each File In Files
         hEnum_File = ObjectCollectionOpen(Files)
         While 1
            File = ObjectCollectionNext(hEnum_File)
            If !File Then Break

            S = S & GenerateFileInformation(File)

            ObjectClose(File)
         EndWhile
         ObjectCollectionClose(hEnum_File)
         Drop(File,hEnum_File)
         ;Next
    End If
;----------------------------------------------------------------------------------------------------------------------




Seitenanfang/TopOfPage Seitenende/EndOfPage
Seitenanfang/TopOfPage Seitenende/EndOfPage

WBStudio.HexToDec (Utility to convert Hex numbers to Decimal numbers)

;----------------------------------------------------------------------------------------------------------------------
; Interactive Converter for Hex Numbers to Decimal Numbers.
; Hex Numbers must follow
; - the Visual Basic format '&H3&', '&H3D0', '"&H3&"' (enclosed in double quotes)
; - the C format  '0x0000', '0x00000000L'.
; For use in WinBatchStudio Editor only.
;----------------------------------------------------------------------------------------------------------------------
; For easy use just insert two lines into WSPOPUP.MNU, e.g.:
; _WBStudioHexToDec \ {F7}
;     Call("W:\WBT\UDF\WBStudioHexToDec.wbt","")
;
; Modify menu entry, filename, folderpath and hotkey to your needs.
;
; For undoing of replacements use standard hotkey Ctrl-Z
; or the symbol resp. item from WinBatch Studio menu.
;
; Search loop starts at current cursor position in forward direction.
;
; Detlev Dalitz.20020627.20020630.20020706.20020711.20020715
;----------------------------------------------------------------------------------------------------------------------

#DefineFunction udfHexToDec (hexstr)
HexChars = "0123456789ABCDEF"
hexstr = StrUpper(StrTrim(hexstr))
hexlen = StrLen(hexstr)
dec = 0
For x=1 To hexlen
   dec = (dec<<4)+StrIndex(HexChars,StrSub(hexstr,x,1),0,@FWDSCAN)-1
Next
Return (dec)
; Note: Returned negative numbers are ok.
#EndFunction


iCount = 0
If (RtStatus()<>10) Then Goto CANCEL ; In Studio or not?

p1 = '("*&[hH][0-9a-fA-F]+&*"*)' ; Visual Basic
p2 = '(0[xX][0-9a-fA-F]+[lL]*)'  ; C
p = StrCat(p1,"|",p2)

wFind("[ ""'`]",0,0,1,0)
While 1
   ; wFind (SearchText, Forward, MatchCase, Regex, Wrap)
   If !wFind(p,1,0,1,0) Then Break

   ; Get selection information.
   SelInfo = wSelInfo()
   ;SelStartLine = ItemExtract(1,SelInfo,@TAB)
   SelStartCol  = ItemExtract(2,SelInfo,@TAB)
   ;SelStopLine  = ItemExtract(3,SelInfo,@TAB)
   SelStopCol   = ItemExtract(4,SelInfo,@TAB)

   ; Check if number is comment formatted e.g. "; &H3D0"
   ; If so then skip and continue the search loop.
   wEdGoToCol(SelStartCol-1)
   If (wGetChar() == " ")
      wEdLeft()
      If (wGetChar() == ";")
         wEdGoToCol(SelStopCol)
         Continue
      EndIf
   EndIf

   ; Get the selection.
   wEdGoToCol(SelStartCol)
   wEdStartSel()
   wEdGoToCol(SelStopCol)
   wEdEndSel()
   sGet = wEdGetWord()

   ; Compute the selection and replace it.
   sPut = StrUpper(sGet)
   sPut = StrClean(sPut,"0123456789ABCDEF","",@TRUE,2)
   sPut = udfHexToDec(sPut)
   iPutLength = StrLen(sPut)
   wEdInsString(sPut)

   ; Append original number as comment at end of current line.
   wEdEnd()
   wEdInsString(" ; ")
   wEdInsString(sGet)

   ; Reposition the cursor.
   wEdGoToCol(SelStartCol+iPutLength)

   ; Make the cursor visible.
   wEdClearSel()

   ; Increment counter.
   iCount = iCount  + 1

   ; Ask for more.
   Pause("WBStudioHexToDec","Search and Replace again?")

EndWhile


:CANCEL
If (iCount > 0) Then Message("WBStudioHexToDec",StrCat("Replaced items: ",iCount))

If (IntControl(77,80,0,0,0) > 0) Then Return
Exit

;----------------------------------------------------------------------------------------------------------------------



; --- test  area ---

"&H80000000"
"&H3D0" "&H3D0"
"&H3&"
&H80000000  &H3D0  &H3D0  &H3&

0x80000000
0x3d0      0x3d0
0x3
0x80000000L  0x3D0   0x3D0   0x3

;----------------------------------------------------------------------------------------------------------------------
;*EOF*





Page Date
2004-05-18
DD-Software
Kapitel zurück / previous Chapter
Main Index
 
Seite zurück / previous page
Backward
Seite vor / next page
Forward
 
Seitenanfang/TopOfPage
Top
Seitenende/EndOfPage
Bottom
MyWbtHelp current version