home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / baswiz19.zip / BW$BAS.ZIP / BCDSET.BAS < prev    next >
BASIC Source File  |  1993-01-29  |  1KB  |  38 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |        BASWIZ  Copyright (c) 1990-1993  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   |                      The BASIC Wizard's Library                      |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9.    DECLARE SUB BCDGetSize (LeftDigits AS INTEGER, RightDigits AS INTEGER)
  10.  
  11.    DEFINT A-Z
  12.  
  13. FUNCTION BCDSet$ (NumSt$)
  14.    BCDGetSize LeftD, RightD
  15.    St$ = LTRIM$(NumSt$)
  16.    FOR tmp = 1 TO LEN(St$)
  17.       ch = ASC(MID$(St$, tmp, 1))
  18.       IF ch >= 48 AND ch <= 57 THEN MID$(St$, tmp, 1) = CHR$(ch - 48)
  19.    NEXT
  20.    IF LEFT$(St$, 1) = "-" THEN
  21.       Sign$ = "-"
  22.       St$ = MID$(St$, 2)
  23.    ELSE
  24.       Sign$ = " "
  25.    END IF
  26.    tmp = INSTR(St$, ".")
  27.    IF tmp THEN
  28.       L$ = LEFT$(St$, tmp - 1)
  29.       R$ = MID$(St$, tmp + 1)
  30.    ELSE
  31.       L$ = St$
  32.       R$ = ""
  33.    END IF
  34.    L$ = RIGHT$(STRING$(LeftD, 0) + L$, LeftD)
  35.    R$ = LEFT$(R$ + STRING$(RightD, 0), RightD)
  36.    BCDSet$ = Sign$ + L$ + R$
  37. END FUNCTION
  38.