Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: hex to decimal winbatch studio
; ----------------------------------------------------------------------------- ; Interactive Converter for Hex Numbers to Decimal Numbers. ; Hex Numbers must follow the Visual Basic convention e.g. "&H3&" or "&H3D0" ; For use in WinBatchStudio Editor only. ; ----------------------------------------------------------------------------- ; For easy use just insert two lines into WSPOPUP.MNU, e.g.: ; _WBStudioHexToDec \ {F7} ; Call("W:\WBT\UDF\udfWBStudioHexToDec.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. ; ; Detlev Dalitz.20020627 ; ----------------------------------------------------------------------------- #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: negative numbers are ok. #EndFunction If (rtStatus()==10) ; in Studio? wFind("[ ""'`]",0,0,1,0) While 1 ; wFind (SearchText, Forward, MatchCase, Regex, Wrap) If !wFind("&H[0-9a-fA-F]+&*",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" wEdGotoCol(SelStartCol-1) If (wGetChar() == " ") wEdLeft() If (wGetChar() == ";") wEdGotoCol(SelStopCol) Continue EndIF EndIf ; select the hex number wEdGotoCol(SelStartCol) wStartSel() wEdGotoCol(SelStopCol) wEndSel() ; get the selection, compute, and replace it sget = wEdGetWord() sput = StrUpper(sget) sput = StrClean(sput,"0123456789ABCDEF","",@true,2) sput = udfHexToDec(sput) ilensput = StrLen(sput) wEdInsString(sput) ; append original number as comment at end of current line wEdEnd() wEdInsString(" ; ") wEdInsString(sget) ; reposition the cursor wEdGotoCol(SelStartCol+ilensput) ; make the cursor visible wEdClearSel() ; ask for more pause("WBStudioHexToDec","Search and Replace again?") EndWhile EndIf :cancel If (IntControl(77,80,0,0,0) > 0) then return Exit
Article ID: W15348
File Created: 2002:09:05:13:51:26
Last Updated: 2002:09:05:13:51:26