Author Topic: Number to Word (VERY limited!)  (Read 3606 times)

0 Members and 1 Guest are viewing this topic.

Offline Prithak

  • Newbie
  • Posts: 56
  • Life itself is a Programming Language!
    • View Profile
    • My Programming Language
Number to Word (VERY limited!)
« on: April 10, 2019, 06:13:44 am »
Hey there,
I've made a number to word converter but it is really limited! supporting only 3 digits! But I think I can increase it to 4. We'll see!
Here's the code:
Code: QB64: [Select]
  1.  
  2. dim one_digit(9) as string
  3. dim two_digit(10 to 19) as string
  4. dim multiples(9) as string
  5. dim three_digit as string
  6.  
  7. for i = 0 to 9
  8.     read one_digit(i)
  9.  
  10. for i = 10 to 19
  11.     read two_digit(i)
  12.  
  13. for i = 0 to 7
  14.     read multiples(i)
  15.  
  16. three_digit = "hundred"
  17.  
  18. there:
  19.  
  20. input "Enter a number (not higher than 3 digits!)"; a$
  21.  
  22. if len(a$) > 3 then
  23.     print "Higher than 3 digits not supported!!!"
  24.     goto there
  25.  
  26. c=len(a$)-1
  27.  
  28. for i = 1 to len(a$)
  29.     b$ = mid$(a$,i,1)
  30.     for j = 1 to c
  31.         b$ = b$ + "0"
  32.     next j
  33.     if c = 2 then
  34.         print one_digit(val(left$(b$,1)));
  35.         print " hundred ";
  36.     end if
  37.     if c = 1 then
  38.         if b$ <> "10" then
  39.             print multiples(val(left$(b$,1)))
  40.         else
  41.             print two_digit(val(right$(a$,2)))
  42.             end
  43.         end if
  44.     end if
  45.     if c = 0 then
  46.         print one_digit(val(b$))
  47.     end if
  48.     c=c-1
  49.  
  50. data "zero","one","two","three","four","five","six","seven","eight","nine"
  51. data "ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen", "eighteen", "nineteen"
  52. data "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"

-Prithak
CLS
IF computer$ = "ON" THEN
me$ = "Happy!"
ELSE
me$ = "Time To Draw!"
END IF
END

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Number to Word (VERY limited!)
« Reply #1 on: April 10, 2019, 10:30:20 am »
Here's one I put together in 2005. The thread is over at the Archived Posts of The QBasic Forum: https://www.tapatalk.com/groups/qbasic/viewtopic.php?f=13959&t=26807&p=130851&hilit=decillion#p130851

Feel free to use anything you need if it helps you build your version.

 - Pete

Code: QB64: [Select]
  1. REM NUMBERS TO ENGLISH CONVERTER. (C) COPYRIGHT 2005 1STON.COM ALL RIGHTS RESERVED.
  2. REM MAC - I WANT MY $20.00, LOL.
  3. REM CONVERTS NUMBERS TO ENGLISH. USE 36 DIGITS (DECILLION+) POSITIVE OR NEGATIVE.
  4. REM THIS VERSION RUNS STARTING TO ENDING NUMBERS.
  5. REM COUNTS BY 1S, 2S, UP TO 1000 POSITIVE OR NEGATIVE.
  6. REM COMMAS CAN BE USED BUT ARE NOT NECESSARY.
  7.  
  8.  
  9. 101
  10. REDIM NEG(3)
  11. REDIM PROMPT$(10)
  12. PROMPT$(1) = "NUMBERS TO ENGLISH PROGRAM: INPUT A +/- INTEGER TO 36 DIGITS OR NOTHING TO END"
  13. PROMPT$(2) = "PRESS: [" + CHR$(25) + "] SCROLL NUMBERS MANUALLY [ENTER] AUTO SCROLL [ESC] END"
  14. PROMPT$(3) = "PROGRAM PAUSED. PRESS: [SPACE BAR] RESUME [" + CHR$(25) + "] MANUAL SCROLL [ESC] END"
  15. PROMPT$(4) = "PRESS: [R] RERUN PROGRAM [C] CHANGE SETTINGS / RERUN [ESC] END"
  16. PROMPT$(5) = "PRESS: [SPACE BAR] PAUSE [ESC] END <MANUAL SCROLL AVAILABLE WHEN PAUSED>"
  17. PROMPT$(6) = "PROGRAM ABORTED BY USER. PRESS [R] TO RERUN PROGRAM OR [ESC] TO QUIT"
  18. PROMPT$(7) = "INPUT A +/- INTEGER TO 36 DIGITS OR INPUT NOTHING TO WRITE STARTING NUMBER ONLY"
  19. PROMPT$(8) = "ENTER A DISPLAY PREFERENCE OR LEAVE BLANK FOR DEFAULT [A]"
  20. PROMPT$(9) = "ENTER A DISPLAY PREFERENCE OR LEAVE BLANK FOR DEFAULT [L]"
  21. PROMPT$(10) = "INPUT A NUMBER FROM -1000 TO 1000 TO COUNT BY OR LEAVE BLANK FOR [1]"
  22. UC$ = CHR$(SCREEN(1, 1)): AB$ = CHR$(SCREEN(1, 2))
  23.  
  24. PRO = 1: GOSUB MSG
  25.  
  26. VIEW PRINT 1 TO 9: CLS 2
  27. LOCATE 1, 1, 1
  28.     DO
  29.         NUMBERORDER = NUMBERORDER + 1
  30.         SELECT CASE NUMBERORDER
  31.             CASE 1
  32.                 LINE INPUT " INPUT STARTING NUMBER HERE:   "; X$
  33.                 IF X$ = "" THEN SYSTEM
  34.             CASE 2
  35.                 PRO = 7: GOSUB MSG
  36.                 PRINT: LINE INPUT " INPUT ENDING NUMBER HERE:     "; X$
  37.                 IF X$ = "" THEN CNTBY = 1: AB$ = "A": UC$ = "L": LOCATE CSRLIN - 1, 1: PRINT SPACE$(80);: X$ = "SKIP": EXIT DO
  38.             CASE 3
  39.                 PRO = 10: GOSUB MSG
  40.                 PRINT: LINE INPUT " COUNT BY 1s, 2s, UP TO 1000s: "; X$
  41.                 IF X$ = "" THEN X$ = "1": LOCATE CSRLIN - 1, 32: PRINT X$
  42.         END SELECT
  43.  
  44.         REM VALIDATE NUMBER
  45.         XHOLD$ = ""
  46.         IF VAL(X$) < 0 THEN J = 2 ELSE J = 1
  47.         FOR I = J TO LEN(X$)
  48.             IF MID$(X$, I, 1) <> "," THEN XHOLD$ = XHOLD$ + MID$(X$, I, 1)
  49.             IF ASC(MID$(X$, I, 1)) < 48 OR ASC(MID$(X$, I, 1)) > 57 OR LEN(X$) > 2 AND MID$(X$, 1, 1) = "0" THEN
  50.                 IF MID$(X$, I, 1) <> "," THEN XHOLD$ = "": EXIT FOR
  51.             END IF
  52.         NEXT I
  53.  
  54.         REM EVALUATE FOR NEGATIVE NUMBERS
  55.         IF VAL(X$) < 0 THEN X$ = MID$(X$, 2): NEG(NUMBERORDER) = -1 ELSE NEG(NUMBERORDER) = 1
  56.  
  57.         REM EVALUATE FOR SIZE
  58.         IF NUMBERORDER = 3 THEN
  59.             IF ABS(VAL(XHOLD$)) > 1000 THEN XHOLD$ = ""
  60.         ELSE
  61.             IF LEN(XHOLD$) > 36 AND VAL(XHOLD$) > 0 OR LEN(XHOLD$) > 37 AND VAL(X$) < 0 THEN XHOLD$ = ""
  62.         END IF
  63.  
  64.         REM EVALUATE COMMA PLACEMENT
  65.         IF INSTR(X$, ",") <> 0 THEN
  66.             FOR I = LEN(X$) TO 1 STEP -1
  67.                 IF I MOD 4 = 0 THEN
  68.                     IF MID$(X$, LEN(X$) - I + 1, 1) <> "," OR LEFT$(X$, 1) = "," THEN XHOLD$ = "": EXIT FOR
  69.                 ELSE
  70.                     IF MID$(X$, LEN(X$) - I + 1, 1) = "," THEN XHOLD$ = "": EXIT FOR
  71.                 END IF
  72.             NEXT I
  73.         END IF
  74.         X$ = XHOLD$: XHOLD$ = ""
  75.         IF X$ = "0" OR VAL(X$) <> 0 THEN
  76.             EXIT DO
  77.         ELSE
  78.             LOCATE , , 0
  79.             PRINT: PRINT " NUMBER INVALID OR TOO LARGE, REDO FROM START...": PRINT: X$ = "": B$ = INKEY$: SLEEP 2: EXIT DO
  80.         END IF
  81.     LOOP
  82.     IF X$ = "SKIP" THEN EXIT DO
  83.     IF X$ = "" THEN RUN
  84.     IF NUMBERORDER = 1 THEN STARTINGNUMBER$ = X$: STARTINGHOLD$ = XHOLD$ ELSE LOOPTIMES = VAL(X$)
  85.     IF NUMBERORDER = 2 THEN ENDNUMBER$ = X$
  86.     IF NUMBERORDER = 3 THEN CNTBY = VAL(X$): EXIT DO
  87.  
  88. IF X$ <> "SKIP" THEN
  89.     LOCATE CSRLIN - 1, 44: PRINT "DISPLAY A=AMERICAN OR B=BRITISH: ";
  90.     PRO = 8: GOSUB MSG
  91.  
  92.     IF RTRIM$(AB$) = "" THEN
  93.         DO
  94.             AB$ = UCASE$(INKEY$)
  95.             IF AB$ = CHR$(27) THEN SYSTEM
  96.             IF AB$ = CHR$(13) THEN AB$ = "A": REM DEFAULT
  97.         LOOP UNTIL AB$ = "A" OR AB$ = "B"
  98.         PRINT AB$
  99.     ELSE
  100.         PRINT AB$
  101.     END IF
  102.  
  103.     PRINT: PRINT " U=UCASE L=LCASE: ";
  104.     PRO = 8: GOSUB MSG
  105.  
  106.     IF RTRIM$(UC$) = "" THEN
  107.         DO
  108.             UC$ = UCASE$(INKEY$)
  109.             IF UC$ = CHR$(27) THEN SYSTEM
  110.             IF UC$ = CHR$(13) THEN UC$ = "L": REM DEFAULT
  111.         LOOP UNTIL UC$ = "U" OR UC$ = "L"
  112.         PRINT UC$;
  113.     ELSE
  114.         PRINT UC$;
  115.     END IF
  116.  
  117. IF X$ = "SKIP" THEN X$ = "": YYDISPLAY = 5: LOCATE 7, 2 ELSE LOCATE 7, 29: YYDISPLAY = 32
  118. PRINT "#: ";
  119.  
  120. LOCATE 25, 1: PRINT SPACE$(80);
  121. X$ = STARTINGNUMBER$: NUMBERORDER = 0
  122. GOSUB CONVERT1
  123.  
  124. LOCATE , , 0
  125.  
  126.     DO
  127.         B$ = INKEY$
  128.         IF B$ = CHR$(27) THEN GOTO SHUTOFF
  129.         IF B$ = " " THEN IF AUTO <> 0 THEN PAUSE = 1
  130.         EXIT DO
  131.     LOOP
  132.     IF VAL(X$) = 0 THEN
  133.         NUM$ = "ZERO"
  134.         IF UC$ = "L" THEN NUM$ = "Zero"
  135.         GOSUB PRINTNUM
  136.     ELSE
  137.         IF NEG(1) = -1 THEN NUM$ = "NEGATIVE": GOSUB PRINTNUM
  138.     END IF
  139.  
  140.     XHOLD$ = X$
  141.  
  142.     UC = 0: XHOLDC$ = ""
  143.     FOR I = LEN(X$) TO 1 STEP -1
  144.         XHOLDC$ = MID$(X$, I, 1) + XHOLDC$
  145.         IF (LEN(X$) + 1 - I) MOD 3 = 0 AND I <> 1 THEN XHOLDC$ = "," + XHOLDC$
  146.     NEXT I
  147.     XX = CSRLIN: YY = POS(1): VIEW PRINT
  148.     LOCATE 7, YYDISPLAY: PRINT SPACE$(41);: LOCATE 7, YYDISPLAY
  149.     IF NEG(1) = -1 THEN PRINT "-";
  150.     PRINT XHOLDC$;
  151.     VIEW PRINT 9 TO 23
  152.     LOCATE XX, YY
  153.  
  154.     IF LEN(XHOLD$) MOD 3 = 0 THEN
  155.         X$ = MID$(XHOLD$, 1, 3)
  156.     ELSE
  157.         X$ = MID$(XHOLD$, 1, LEN(X$) MOD 3)
  158.     END IF
  159.  
  160.     FOR HH = 1 TO (LEN(XHOLD$) - 1) / 3 + 1
  161.         FOR II = 1 TO LEN(X$)
  162.             SELECT CASE LEN(X$) - II + 1
  163.                 CASE 3
  164.                     RESTORE ONES
  165.                     FOR I = 1 TO VAL(MID$(X$, II, 1))
  166.                         READ NUM$
  167.                     NEXT I
  168.                     GOSUB PRINTNUM
  169.                     IF VAL(MID$(X$, II, 1)) <> 0 THEN
  170.                         IF VAL(MID$(XHOLD$, KK + 2, 2)) <> 0 AND AB$ = "B" THEN NUM$ = "HUNDRED AND" ELSE NUM$ = "HUNDRED"
  171.                         GOSUB PRINTNUM
  172.                     ELSE
  173.                         IF AB$ = "B" THEN
  174.                             IF KK <> 0 AND KK >= LEN(XHOLD$) - 3 THEN IF VAL(MID$(XHOLD$, LEN(XHOLD$) - 1)) <= 99 AND VAL(MID$(XHOLD$, LEN(XHOLD$) - 1)) <> 0 THEN ADDAND = 1
  175.                         END IF
  176.                     END IF
  177.  
  178.                 CASE 1
  179.                     RESTORE ONES
  180.                     FOR I = 1 TO VAL(MID$(X$, II, 1))
  181.                         READ NUM$
  182.                     NEXT I
  183.                     GOSUB PRINTNUM
  184.                 CASE 2
  185.                     IF MID$(X$, II, 1) = "1" THEN
  186.                         RESTORE TEENS
  187.                         FOR I = 1 TO VAL(MID$(X$, II, 2)) - 9
  188.                             READ NUM$
  189.                         NEXT I
  190.                         II = II + 1
  191.                         GOSUB PRINTNUM
  192.                     ELSE
  193.                         RESTORE TENS
  194.                         FOR I = 1 TO VAL(MID$(X$, II, 1))
  195.                             READ NUM$
  196.                         NEXT I
  197.                         IF VAL(MID$(X$, LEN(X$), 1)) <> 0 THEN
  198.                             HYPHEN = 1
  199.                         END IF
  200.                         GOSUB PRINTNUM
  201.                     END IF
  202.             END SELECT
  203.         NEXT II
  204.         KK = KK + LEN(X$)
  205.  
  206.         RESTORE LARGENUMBERS
  207.         IF MID$(XHOLD$, KK, 1) <> "0" OR X$ = "100" OR X$ = "10" OR MID$(X$, 3, 1) = "0" AND VAL(X$) <> 0 THEN
  208.             FOR I = 1 TO (LEN(XHOLD$) - KK) \ 3
  209.                 READ NUM$
  210.             NEXT I
  211.         END IF
  212.         GOSUB PRINTNUM
  213.         COMMA = 1
  214.         X$ = RTRIM$(MID$(XHOLD$, KK + 1, 3))
  215.     NEXT HH
  216.  
  217.     KK = 0: COMMA = 0: COMMASET = 0
  218.     IF LEN(XHOLD$) <= 15 THEN
  219.         IF NEG(1) = -1 THEN
  220.             XHOLD$ = LTRIM$(STR$(VAL(XHOLD$) * NEG(1) + CNTBY * NEG(3)))
  221.             IF VAL(XHOLD$) * NEG(1) + CNTBY * NEG(3) > 0 THEN NEG(1) = 1
  222.             IF VAL(XHOLD$) < 0 THEN NEG(1) = -1: XHOLD$ = MID$(XHOLD$, 2)
  223.         ELSE
  224.             XHOLD$ = LTRIM$(STR$(VAL(XHOLD$) + CNTBY * NEG(3)))
  225.             IF VAL(XHOLD$) < 0 THEN NEG(1) = -1: XHOLD$ = MID$(XHOLD$, 2)
  226.         END IF
  227.     ELSE
  228.         GOSUB CONVERT2
  229.     END IF
  230.  
  231.     X$ = XHOLD$: PRINT
  232.     STARTINGNUMBER$ = XHOLD$
  233.     GOSUB CONVERT1
  234.     IF CNTBY = 0 THEN EXIT DO
  235.     IF NEG(1) = -1 THEN
  236.         IF NEG(3) = -1 THEN
  237.             IF NEG(2) = -1 THEN
  238.                 IF STARTINGNUMBER$ > ENDNUMBER$ THEN EXIT DO: REM TESTED
  239.             ELSE
  240.                 EXIT DO: REM TESTED
  241.             END IF
  242.         ELSE
  243.             IF NEG(2) = -1 THEN
  244.                 IF STARTINGNUMBER$ < ENDNUMBER$ THEN EXIT DO: REM TESTED
  245.             ELSE
  246.                 REM #1 IS (-) ADDING UP TO LARGER NUMBER (INVERT SIGNS)
  247.                 REM NO EXIT
  248.             END IF
  249.         END IF
  250.     ELSE
  251.         IF NEG(3) = -1 THEN
  252.             IF NEG(2) = -1 THEN
  253.                 IF STARTINGNUMBER$ <= "0" THEN EXIT DO: REM TESTED
  254.             ELSE
  255.                 IF STARTINGNUMBER$ < ENDNUMBER$ THEN EXIT DO: REM TESTED
  256.             END IF
  257.         ELSE
  258.             IF NEG(2) = -1 THEN
  259.                 EXIT DO
  260.             ELSE
  261.                 IF STARTINGNUMBER$ > ENDNUMBER$ THEN EXIT DO: REM TESTED
  262.             END IF
  263.  
  264.         END IF
  265.     END IF
  266.  
  267. PRO = 4: GOSUB MSG
  268.  
  269.     B$ = UCASE$(INKEY$)
  270.     IF B$ = CHR$(27) OR B$ = "N" THEN SYSTEM
  271.     IF B$ = "C" OR B$ = "R" THEN EXIT DO
  272. VIEW PRINT: LOCATE 1, 1: PRINT UC$; AB$
  273. IF B$ = "C" THEN RUN ELSE RUN 101
  274.  
  275. PRINTNUM:
  276. IF NUM$ <> "" THEN
  277.     IF ADDAND = 1 THEN COMMA = 0: COMMASET = 0
  278.     IF HYPHEN = 2 THEN HYPHEN = 3
  279.     IF HYPHEN = 1 THEN HOLDNUM$ = "-"
  280.     IF COMMA = 1 THEN
  281.         IF COMMASET = 1 THEN COMMA = 0 ELSE COMMA = 0: HOLDNUM$ = NUM$: NUM$ = ",": COMMASET = 1
  282.     END IF
  283.     HYPHEN = 0
  284.  
  285.     IF NUM$ = "" THEN EXIT DO
  286.     IF UC$ = "L" THEN
  287.         IF HH >= 1 THEN IF UC = 0 THEN NUM$ = UCASE$(MID$(NUM$, 1, 1)) + LCASE$(MID$(NUM$, 2)): UC = 1 ELSE NUM$ = LCASE$(NUM$)
  288.         IF UCASE$(NUM$) = "NEGATIVE" THEN NUM$ = "Negative": UC = 1
  289.     END IF
  290.     J = POS(1) + LEN(NUM$) + 1
  291.     IF J >= 78 AND NUM$ <> "," OR J >= 80 AND NUM$ = "," OR POS(1) = 1 THEN PRINT
  292.     IF NUM$ <> "," THEN
  293.         IF HYPHEN < 2 OR POS(1) = 1 THEN PRINT " ";
  294.         IF COMMASET = 1 THEN COMMASET = 0
  295.         IF ADDAND = 1 THEN NUM$ = "AND " + NUM$: ADDAND = 0: IF UC$ = "L" THEN NUM$ = LCASE$(NUM$)
  296.         PRINT NUM$;: IF NUM$ <> "-" AND HOLDNUM$ = "" THEN HYPHENSET = 0
  297.     ELSE
  298.         PRINT NUM$;
  299.     END IF
  300.     NUM$ = ""
  301.     IF HOLDNUM$ = "" THEN EXIT DO ELSE NUM$ = HOLDNUM$: HOLDNUM$ = ""
  302.     IF NUM$ = "-" THEN HYPHEN = 2
  303. IF HYPHEN = 3 THEN HYPHEN = 0
  304.  
  305. IF PAUSE = 1 AND KK = LEN(XHOLD$) THEN
  306.     PAUSE = 0
  307.  
  308.     PRO = 3: GOSUB MSG
  309.  
  310.     DO
  311.         B$ = INKEY$
  312.         IF B$ = CHR$(0) + "P" THEN AUTO = 0: EXIT DO
  313.         IF B$ = CHR$(27) THEN GOTO SHUTOFF
  314.     LOOP UNTIL B$ = " "
  315.     PRO = 5: GOSUB MSG
  316. IF CSRLIN > 21 AND AUTO = 0 AND KK = LEN(XHOLD$) THEN
  317.     XX = CSRLIN: YY = POS(1)
  318.     IF SCREEN(25, 41) = 32 THEN PRO = 2: GOSUB MSG
  319.     DO
  320.         B$ = INKEY$
  321.         IF B$ = CHR$(27) THEN GOTO SHUTOFF
  322.         IF B$ = CHR$(13) THEN
  323.             PRO = 5: GOSUB MSG
  324.             AUTO = 1
  325.             EXIT DO
  326.         END IF
  327.     LOOP UNTIL B$ = CHR$(0) + "P"
  328.     LOCATE 23, 1: PRINT: PRINT
  329.     LOCATE XX - 2, YY
  330.  
  331. CONVERT1:
  332. IF LEN(STARTINGNUMBER$) > LEN(ENDNUMBER$) THEN
  333.     ENDNUMBER$ = STRING$(LEN(STARTINGNUMBER$) - LEN(ENDNUMBER$), "0") + ENDNUMBER$
  334.     IF LEN(STARTINGNUMBER$) <> LEN(ENDNUMBER$) THEN STARTINGNUMBER$ = STRING$(LEN(ENDNUMBER$) - LEN(STARTINGNUMBER$), "0") + STARTINGNUMBER$
  335. IF NEG(1) = -1 AND NEG(2) = 1 THEN STARTINGNUMBER$ = "": REM MAKE ALWAYS SMALLER
  336.  
  337. CONVERT2:
  338. XHOLD2$ = "0" + XHOLD$
  339. X3$ = LTRIM$(STR$(CNTBY))
  340. IF LEN(X3$) > LEN(XHOLD2$) THEN
  341.     XHOLD2$ = STRING$(LEN(X3$) - LEN(XHOLD2$), "0") + XHOLD2$
  342.     X3$ = STRING$(LEN(XHOLD2$) - LEN(X3$), "0") + X3$
  343.     X3$ = STRING$(LEN(XHOLD2$) - LEN(X3$), "0") + X3$
  344.  
  345. IF X3$ >= XHOLD2$ THEN
  346.     IF NEG(1) = -1 AND NEG(3) = 1 THEN
  347.         SWAP X3$, XHOLD2$: HOLDNEG3 = NEG(3): NEG(3) = -1: NEG(1) = 1
  348.     END IF
  349.     IF X3$ >= XHOLD2$ AND NEG(1) = 1 AND NEG(3) = -1 THEN
  350.         SWAP X3$, XHOLD2$: CHANGESIGN1 = -1
  351.     END IF
  352.  
  353. FOR I = LEN(XHOLD2$) TO 1 STEP -1
  354.     IF NEG(1) = 1 AND NEG(3) = 1 OR NEG(1) = -1 AND NEG(3) = -1 THEN
  355.         IF VAL(MID$(XHOLD2$, I, 1)) + VAL(MID$(X3$, I, 1)) + CARRY >= 10 THEN
  356.             NEWNUM$ = LTRIM$(STR$(VAL(MID$(XHOLD2$, I, 1)) + VAL(MID$(X3$, I, 1)) + CARRY - 10)) + NEWNUM$: CARRY = 1: PASS = 1
  357.         ELSE
  358.             NEWNUM$ = LTRIM$(STR$(VAL(MID$(XHOLD2$, I, 1)) + VAL(MID$(X3$, I, 1)) + CARRY)) + NEWNUM$
  359.         END IF
  360.     ELSE
  361.         REM MINUS
  362.         IF VAL(MID$(XHOLD2$, I, 1)) - VAL(MID$(X3$, I, 1)) - CARRY < 0 THEN
  363.             NEWNUM$ = LTRIM$(STR$(VAL(MID$(XHOLD2$, I, 1)) + 10 - VAL(MID$(X3$, I, 1)) - CARRY)) + NEWNUM$: CARRY = 1: PASS = 1
  364.         ELSE
  365.             NEWNUM$ = LTRIM$(STR$(VAL(MID$(XHOLD2$, I, 1)) - VAL(MID$(X3$, I, 1)) - CARRY)) + NEWNUM$
  366.         END IF
  367.     END IF
  368.  
  369.     IF PASS = 0 THEN CARRY = 0 ELSE PASS = 0
  370. CARRY = 0: PASS = 0
  371.  
  372.     IF MID$(NEWNUM$, 1, 1) = "0" THEN NEWNUM$ = MID$(NEWNUM$, 2) ELSE EXIT DO
  373. XHOLD$ = NEWNUM$
  374. IF HOLDNEG3 <> 0 THEN NEG(3) = HOLDNEG3: HOLDNEG3 = 0
  375. IF CHANGESIGN1 = -1 THEN NEG(1) = -1: CHANGESIGN1 = 0
  376. IF NEWNUM$ = "" THEN NEWNUM$ = "0": NEG(1) = 1
  377. NEWNUM$ = ""
  378.  
  379. MSG:
  380. XX = CSRLIN: YY = POS(1)
  381. LOCATE 25, 1: PRINT SPACE$(80);: LOCATE 25, 41 - LEN(PROMPT$(PRO)) \ 2: PRINT PROMPT$(PRO);
  382. LOCATE XX, YY
  383.  
  384. SHUTOFF:
  385. X$ = INKEY$
  386. PRO = 6: GOSUB MSG
  387.     B$ = UCASE$(INKEY$)
  388.     IF B$ = "R" THEN RUN ELSE IF B$ = CHR$(27) OR B$ = "N" THEN EXIT DO
  389.  
  390. TEENS:
  391. DATA TEN,ELEVEN,TWELVE,THIRTEEN,FOURTEEN,FIFTEEN,SIXTEEN,SEVENTEEN,EIGHTEEN,NINETINE
  392.  
  393. TENS:
  394. DATA TEN,TWENTY,THIRTY,FORTY,FIFTY,SIXTY,SEVENTY,EIGHTY,NINETY
  395.  
  396. ONES:
  397. DATA ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE
  398.  
  399. LARGENUMBERS:
  400. DATA THOUSAND,MILLION,BILLION,TRILLION,QUADRILLION,QUINTILLION,SEXTILLION,SEPTILLION,OCTILLION,NONILLION,DECILLION
  401.  
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/