udfSegSeven
str udfSegSeven (str, int, int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfSegSeven (strNumber, intPadLen, intMode)
strNumber = StrTrim (strNumber)
Switch Min (Max (0, intMode), 1)
Case 0
   If !IsInt (strNumber) Then Return ""
   intNum = Int (strNumber)
   blnIsNeg = intNum < 0
   If blnIsNeg Then intNum = -intNum
   strNumber = "" : intNum
   Break
Case 1
   blnIsNeg = 0
   strNumber = StrUpper (strNumber) ;strHexstring.
   Break
EndSwitch
arrD0 = Arrayize (" _ ,   , _ , _ ,   , _ , _ , _ , _ , _ , _ ,   , _ ,   , _ , _ ", ",")
arrD1 = Arrayize ("| |,  |, _|, _|,|_|,|_ ,|_ ,  |,|_|,|_|,|_|,|_ ,|  , _|,|_ ,|_ ", ",")
arrD2 = Arrayize ("|_|,  |,|_ , _|,  |, _|,|_|,  |,|_|, _|,| |,|_|,|_ ,|_|,|_ ,|  ", ",")
arrA = Arrayize ("   ,   ,   ", ",")
If blnIsNeg Then arrA[1] = " _ "
intNumLen = StrLen (strNumber)
For intP = 1 To intNumLen
   Select intMode
   Case 0
      intD = StrSub (strNumber, intP, 1)
      Break
   Case 1
      intD = Char2Num (StrSub (strNumber, intP, 1)) - 48
      intD = intD - (7 * (intD > 9))
      Break
   EndSelect
   arrA[0] = arrA[0] : arrD0[intD]
   arrA[1] = arrA[1] : arrD1[intD]
   arrA[2] = arrA[2] : arrD2[intD]
Next
intPadLen = intPadLen << 2
strNumber = (StrFixLeft (arrA[0], " ", intPadLen) : @CRLF : StrFixLeft (arrA[1], " ", intPadLen) : @CRLF : StrFixLeft (arrA[2], " ", intPadLen))
Return strNumber
;..........................................................................................................................................
; This UDF "udfSegSeven" returns a string with number formatted as seven segment number.
;
; Parameters:
;
; intMode = 0 ... Number is Integer.
; intMode = 1 ... Number is Hexstring.
; intPadLen ..... Left pad length.
;
; Detlev Dalitz.20020219.20100205.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

BoxesUp ("700,100,960,240", @NORMAL)
BoxTextFont (1, "Fixedsys", 200, 99, 49)
BoxColor (1, "0,0,0", 0)
BoxTextColor (1, "0,221,0")

strStopText = "Press [Shift]+[Ctrl] to stop"

:Test1
intN = 0
BoxDataTag (1, 1)
While !IsKeyDown (@CTRL & @SHIFT)
   strHex = Num2Char ((intN & 15) + 48 + 7 * ((intN & 15) > 9))
   BoxDataClear (1, 1)
   BoxText (strStopText : @CRLF : udfSegSeven (strHex, 1, 1))
   intN = intN + 1
   If intN > 15 Then intN = 0
   TimeDelay (.5)
EndWhile
BoxText ("Stop 1")
TimeDelay (2)


:Test2
intN = -1000
BoxDataTag (1, 1)
While !IsKeyDown (@CTRL & @SHIFT)
   BoxDataClear (1, 1)
   BoxText (strStopText : @CRLF : udfSegSeven (intN, 5, 0))
   intN = intN + 1
EndWhile
BoxText ("Stop 2")
TimeDelay (2)


:Test3
intN = 0
intTicks1 = GetTickCount ()
BoxDataTag (1, 1)
While !IsKeyDown (@CTRL & @SHIFT)
   intTicks2 = GetTickCount ()
   If intTicks2 > (intTicks1 + 1000)
      BoxDataClear (1, 1)
      BoxText (strStopText : @CRLF : udfSegSeven (intN, 6, 0) : " sec")
      intTicks1 = intTicks2
   EndIf
   intN = intN + 1
   TimeDelay (.9)
EndWhile
BoxText ("Stop 3")
TimeDelay (2)

BoxShut ()
Exit
;------------------------------------------------------------------------------------------------------------------------------------------