;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfOctalToDecimal (strOctal) If strOctal != StrClean (strOctal, "01234567", "", @TRUE, 2) Then Return 0 intDec = 0 intLen = StrLen (strOctal) For intI = 1 To intLen intDec = StrSub (strOctal, intI, 1) | (intDec << 3) Next Return intDec ;......................................................................................................................................... ; This UDF "udfOctalToDecimal" accepts an octal number string and converts the octal value into decimal value. ; An octal number string from 0 to 17777777777 gives a positive decimal value from 0 to 2147483647. ; ; (c)Detlev Dalitz.20080807. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. DirChange (DirScript ()) strOct1 = "" intDec1 = udfOctalToDecimal (strOct1) ; 0. strOct2 = "a" intDec2 = udfOctalToDecimal (strOct2) ; 0. strOct3 = "o3" intDec3 = udfOctalToDecimal (strOct3) ; 0. strOct4 = "0" intDec4 = udfOctalToDecimal (strOct4) ; 0. strOct5 = "7" intDec5 = udfOctalToDecimal (strOct5) ; 7. strOct6 = "335" intDec6 = udfOctalToDecimal (strOct6) ; 221. strOct7 = "777" intDec7 = udfOctalToDecimal (strOct7) ; 511. strOct8 = "1000" intDec8 = udfOctalToDecimal (strOct8) ; 512. strOct9 = "17777777777" intDec9 = udfOctalToDecimal (strOct9) ; 2147483647. :CANCEL Exit