QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Pete on July 22, 2019, 01:35:04 am

Title: QB64 vs same coded C/C++ program
Post by: Pete on July 22, 2019, 01:35:04 am
I still have a little finish work to do, but basically, I finished the QB64 version of the C/C++/Wn API program I put together a few weeks ago, and posted here: https://www.qb64.org/forum/index.php?topic=1417.0

So that code is about double the size of the one I just finished in QB64, yet, when compiled, the C/C++ one is approx. 1.5 MB, while the QB64 one is nearly double that, at 2.5 MB. So why so much bigger? I know Rob worked on limiting libraries that were not needed, so does anyone know why half the source code of my QB64 program would turn out to be twice the exe size of the C/C++ clone?

Here is the QB64 source, for comparison.

Code: QB64: [Select]
  1. 'DIM lb, mx, my, mz, mf, oldmx, oldmy AS INTEGER 'Mouse variables
  2. 'DIM caps AS INTEGER
  3. 'DIM SHARED prompt_column AS INTEGER
  4. 'DIM SHARED startpos AS INTEGER
  5. 'DIM SHARED vertpos AS INTEGER
  6. 'DIM SHARED endpos AS INTEGER
  7. 'DIM SHARED xx AS INTEGER: ' Cursor row.
  8. 'DIM SHARED yy AS INTEGER: ' Cursor column.
  9. 'DIM SHARED yyseparator AS INTEGER
  10. 'DIM ii, j, j2, k, m1, m2 AS INTEGER
  11. 'DIM ins AS INTEGER
  12. 'DIM flag AS INTEGER ' Indicates highlighting in progress.
  13. 'DIM dir AS INTEGER ' direction of the highlighting left (-) or right (+).
  14. 'DIM hmrk, shift, ctrl AS INTEGER ' hmrk is = -1 when void and when in use, indicates the Position in the text array when highlighting begins.
  15. 'DIM entryrow(vmax) AS INTEGER 'Tracks rows where prompts are present.
  16.  
  17. CONST prompt_length = 17 ' Length of longest prompt.
  18. CONST c1f = 0: CONST c1b = 7 ' Color 1. Foreground and background.
  19. CONST c2f = 7: CONST c2b = 1 ' Color 2. Text highlighting
  20. CONST vmax = 4 ' Number of prompts. Must not exceed rows of screen.
  21.  
  22. DIM entry$(vmax) ' AS STRING 'Text entry array.
  23. DIM xntry(MAX_SIZE) AS STRING 'Cut/Copy array.
  24. DIM paste(MAX_SIZE) AS STRING 'Paste array
  25. DIM prompt(vmax) AS STRING 'Prompt array.
  26.  
  27. MAX_SIZE = 36
  28. debug = 0 'Set to zero to turn of, or non-zero to print variables to screen.
  29. prompt_column = 10 'Number of columns to indent prompts.
  30. startpos = prompt_column + prompt_length - 1
  31. vertpos = 5
  32. endpos = startpos + MAX_SIZE
  33. yyseparator = 2 ' # of blank rows - 1 between prompts. Do not set lower than 1.
  34. ins = 7 ' Cursor vertical height.
  35.  
  36. SetConsoleTitle
  37.  
  38. CALL setconsole(c1f, c1b)
  39.  
  40. CALL GetPrompts(startpos, vertpos, vmax, yyseparator, xx, yy, ins, prompt_column, entryrow(), prompt$())
  41.  
  42. CALL HideCursor(ins)
  43.  
  44. WHILE (1)
  45.     CALL GetConsoleInput(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, c1f, c1b, c2f, c2b, prompt_column, entryrow(), prompt$(), entry$())
  46.  
  47. SUB SetConsoleTitle
  48.     title$ = "Pete's Custom Keyboard Input App"
  49.     _TITLE title$
  50.  
  51. SUB setconsole (c1f, c1b)
  52.     PALETTE 7, 63
  53.     COLOR c1f, c1b
  54.     CLS
  55.  
  56. SUB GetPrompts (startpos, vertpos, vmax, yyseparator, xx, yy, ins, prompt_column, entryrow(), prompt$())
  57.     xx = startpos
  58.     yy = vertpos
  59.  
  60.     prompt$(0) = "Name..........: "
  61.     prompt$(1) = "Address.......: "
  62.     prompt$(2) = "City/State/Zip: "
  63.     prompt$(3) = "Phone.........: "
  64.  
  65.     yy = vertpos
  66.  
  67.     FOR ii = 0 TO vmax - 1
  68.         LOCATE yy, prompt_column
  69.         PRINT prompt$(ii);
  70.         entryrow(ii) = yy
  71.         yy = yy + yyseparator
  72.     NEXT
  73.  
  74.     LOCATE vertpos, startpos
  75.     xx = startpos
  76.     yy = vertpos
  77.  
  78. SUB HideCursor (ins)
  79.     LOCATE , , 1, 7, ins
  80.  
  81. SUB copy (startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), xntry$, hmrk, flag, dir)
  82.     IF xx - startpos + 1 < hmrk THEN
  83.         m2 = hmrk
  84.         m1 = xx - startpos + 1
  85.     ELSE
  86.         m1 = hmrk
  87.         m2 = xx - startpos + 1
  88.     END IF
  89.     xntry$ = MID$(entry$((yy - vertpos) / yyseparator), m1, m2 - m1)
  90.  
  91. SUB replace (startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  92.     j = LEN(entry$((yy - vertpos) / yyseparator))
  93.     COLOR c1f, c1b
  94.     IF xx - startpos + 1 < hmrk THEN
  95.         m2 = hmrk
  96.         m1 = xx - startpos
  97.     ELSE
  98.         m1 = hmrk - 1
  99.         m2 = xx - startpos + 1
  100.     END IF
  101.     entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, m1) + MID$(entry$((yy - vertpos) / yyseparator), m2)
  102.     LOCATE yy, startpos
  103.     PRINT entry$((yy - vertpos) / yyseparator);
  104.     PRINT STRING$(j - LEN(entry$((yy - vertpos) / yyseparator)), 32);
  105.     IF xx - startpos + 1 > hmrk THEN
  106.         xx = hmrk - 1 + startpos
  107.     END IF
  108.     LOCATE yy, xx
  109.     hmrk = 0
  110.     flag = 0
  111.     dir = 0
  112.  
  113. SUB GetConsoleInput (startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, c1f, c1b, c2f, c2b, prompt_column, entryrow(), prompt$(), entry$())
  114.     STATIC drag, dir, flag, hmrk, xntry$
  115.  
  116.     DEF SEG = 0
  117.     ii = PEEK(&H417) MOD 16
  118.     SELECT CASE ii
  119.         CASE 1, 2
  120.             shift = -1
  121.         CASE 4
  122.             ctrl = -1
  123.     END SELECT
  124.     DEF SEG
  125.  
  126.     oldyy = yy
  127.  
  128.     IF drag = 0 THEN
  129.  
  130.         IF flag AND shift = 0 AND hmrk = 0 THEN
  131.             flag = 0 ' Disable flag so character value isn't printed after a shift / release event without highlighting.
  132.         END IF
  133.  
  134.         IF hmrk > 0 THEN
  135.             IF shift AND flag THEN
  136.                 flag = 0
  137.             END IF
  138.         END IF
  139.     END IF
  140.  
  141.     CALL mouse(startpos, vmax, xx, yy, vertpos, yyseparator, hmrk, dir, flag, c1f, c1b, c2f, c2b, drag, prompt_column, MAX_SIZE, shift, ch$, entry$(), entryrow())
  142.  
  143.     IF drag = 0 THEN
  144.         IF ch$ = "" THEN ch$ = INKEY$
  145.         IF ch$ <> "" THEN
  146.             IF ctrl THEN
  147.                 SELECT CASE LCASE$(ch$)
  148.                     CASE CHR$(1) ' Select All
  149.                         LOCATE yy, startpos
  150.                         COLOR c2f, c2b
  151.                         PRINT entry$((yy - vertpos) / yyseparator);
  152.                         COLOR c1f, c1b
  153.                         hmrk = 1
  154.                         flag = -1
  155.                         dir = LEN(entry$((yy - vertpos) / yyseparator))
  156.                         xx = startpos + dir
  157.                         LOCATE yy, xx
  158.  
  159.                     CASE CHR$(3) ' Copy
  160.                         IF hmrk THEN
  161.                             CALL copy(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), xntry$, hmrk, flag, dir)
  162.                         END IF
  163.  
  164.                     CASE CHR$(24) ' Cut
  165.                         IF hmrk THEN
  166.                             CALL copy(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), xntry$, hmrk, flag, dir)
  167.                             CALL replace(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  168.                         END IF
  169.  
  170.                     CASE CHR$(22) ' Paste
  171.                         IF xntry$ <> "" THEN
  172.                             IF hmrk THEN
  173.                                 CALL replace(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  174.                             END IF
  175.                             m1 = xx - startpos
  176.                             m2 = m1 + 1
  177.                             IF LEN(xntry$) + LEN(entry$((yy - vertpos) / yyseparator)) - (m2 - m1) <= MAX_SIZE - 1 THEN
  178.                                 entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, m1) + xntry$ + MID$(entry$((yy - vertpos) / yyseparator), m2)
  179.                                 LOCATE yy, startpos
  180.                                 COLOR c1f, c1b
  181.                                 PRINT entry$((yy - vertpos) / yyseparator);
  182.                                 xx = xx + LEN(xntry$)
  183.                                 LOCATE yy, xx
  184.                             ELSE
  185.                                 BEEP ' Contents too large to paste.
  186.                             END IF
  187.                         END IF
  188.                 END SELECT
  189.             ELSE
  190.                 SELECT CASE ch$
  191.                     CASE CHR$(8) ' Backspace
  192.                         ch$ = CHR$(0)
  193.                         IF hmrk > 0 THEN
  194.                             CALL replace(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  195.                         ELSE
  196.                             IF xx > startpos THEN
  197.                                 xx = xx - 1
  198.                                 LOCATE yy, xx
  199.                                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2); " ";
  200.                                 entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, xx - startpos) + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2)
  201.                                 LOCATE yy, xx
  202.                             END IF
  203.                         END IF
  204.                     CASE CHR$(0) + "S" ' Delete
  205.                         IF shift THEN
  206.                             IF hmrk THEN
  207.                                 CALL copy(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), xntry$, hmrk, flag, dir)
  208.                                 CALL replace(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  209.                             END IF
  210.  
  211.                         ELSE
  212.                             ch$ = CHR$(0)
  213.                             IF hmrk > 0 THEN
  214.                                 CALL replace(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  215.                             ELSE
  216.                                 IF LEN(entry$((yy - vertpos) / yyseparator)) > 0 AND xx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) THEN
  217.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2); " ";
  218.                                     entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, xx - startpos) + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2)
  219.                                     LOCATE yy, xx
  220.                                 END IF
  221.                             END IF
  222.                         END IF
  223.  
  224.                     CASE CHR$(0) + "H" ' Arrow up
  225.                         ch$ = CHR$(0)
  226.                         IF yy > vertpos THEN
  227.                             yy = yy - yyseparator
  228.                             xx = startpos
  229.                             LOCATE yy, xx
  230.                         END IF
  231.  
  232.                     CASE CHR$(0) + "P", CHR$(13) ' Arrow down, Enter
  233.                         ch$ = CHR$(0)
  234.                         IF (yy - vertpos) / yyseparator + 1 < vmax THEN
  235.                             yy = yy + yyseparator
  236.                             xx = startpos
  237.                             LOCATE yy, xx
  238.                         END IF
  239.  
  240.                     CASE CHR$(0) + "K" ' Arrow left
  241.                         ch$ = CHR$(0)
  242.                         IF xx > startpos THEN
  243.                             IF shift THEN
  244.                                 IF dir <= 0 THEN
  245.                                     IF dir = 0 THEN
  246.                                         hmrk = xx - startpos + 1
  247.                                         flag = -1
  248.                                     END IF
  249.                                     xx = xx - 1
  250.                                     LOCATE yy, xx
  251.                                     COLOR c2f, c2b
  252.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  253.                                     dir = dir - 1
  254.                                     LOCATE yy, xx
  255.                                 ELSE
  256.                                     xx = xx - 1
  257.                                     LOCATE yy, xx
  258.                                     COLOR c1f, c1b
  259.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  260.                                     dir = dir - 1
  261.                                     IF dir = 0 THEN
  262.                                         hmrk = 0
  263.                                     END IF
  264.                                     LOCATE yy, xx
  265.                                 END IF
  266.  
  267.                             ELSE
  268.                                 xx = xx - 1
  269.                                 LOCATE yy, xx
  270.                             END IF
  271.                         END IF
  272.  
  273.                     CASE CHR$(0) + "M" ' Arrow right
  274.                         ch$ = CHR$(0)
  275.                         IF xx < endpos - 1 AND xx - startpos < LEN(entry$((yy - vertpos) / yyseparator)) THEN
  276.                             IF shift THEN
  277.                                 IF dir >= 0 THEN
  278.                                     IF dir = 0 THEN
  279.                                         hmrk = xx - startpos + 1
  280.                                         flag = -1
  281.                                     END IF
  282.                                     COLOR c2f, c2b
  283.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  284.                                     xx = xx + 1
  285.                                     LOCATE yy, xx
  286.                                     dir = dir + 1
  287.                                     LOCATE yy, xx
  288.                                 ELSE
  289.                                     COLOR c1f, c1b
  290.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  291.                                     xx = xx + 1
  292.                                     dir = dir + 1
  293.                                     IF dir = 0 THEN
  294.                                         hmrk = 0
  295.                                         flag = 0
  296.                                     END IF
  297.                                     LOCATE yy, xx
  298.                                 END IF
  299.                             ELSE
  300.                                 xx = xx + 1
  301.                                 LOCATE yy, xx
  302.                             END IF
  303.                         END IF
  304.  
  305.                     CASE CHR$(0) + "G" ' Home
  306.                         ch$ = CHR$(0)
  307.                         IF xx > startpos THEN
  308.                             IF shift THEN
  309.                                 WHILE xx > startpos
  310.                                     IF dir <= 0 THEN
  311.                                         IF dir = 0 THEN
  312.                                             hmrk = xx - startpos + 1
  313.                                             ' flag is already set.
  314.                                         END IF
  315.                                         xx = xx - 1
  316.                                         LOCATE yy, xx
  317.                                         COLOR c2f, c2b
  318.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  319.                                         dir = dir - 1
  320.                                         LOCATE yy, xx
  321.                                     ELSE
  322.                                         xx = xx - 1
  323.                                         LOCATE yy, xx
  324.                                         COLOR c1f, c1b
  325.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  326.                                         dir = dir - 1
  327.                                         IF dir = 0 THEN
  328.                                             hmrk = 0
  329.                                             flag = 0
  330.                                         END IF
  331.                                         LOCATE yy, xx
  332.                                     END IF
  333.                                 WEND
  334.                             ELSE
  335.                                 xx = startpos
  336.                                 LOCATE yy, xx
  337.                             END IF
  338.                         END IF
  339.  
  340.                     CASE CHR$(0) + "O" ' End
  341.                         ch$ = CHR$(0)
  342.                         IF xx < endpos - 1 THEN
  343.                             IF shift THEN
  344.                                 WHILE xx - startpos < LEN(entry$((yy - vertpos) / yyseparator))
  345.                                     IF dir >= 0 THEN
  346.                                         IF dir = 0 THEN
  347.                                             hmrk = xx - startpos + 1
  348.                                             flag = -1
  349.                                         END IF
  350.                                         COLOR c2f, c2b
  351.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  352.                                         xx = xx + 1
  353.                                         LOCATE yy, xx
  354.                                         dir = dir + 1
  355.                                         LOCATE yy, xx
  356.                                     ELSE
  357.                                         COLOR c1f, c1b
  358.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  359.                                         xx = xx + 1
  360.                                         dir = dir + 1
  361.                                         IF dir = 0 THEN
  362.                                             hmrk = 0
  363.                                         END IF
  364.                                         LOCATE yy, xx
  365.                                     END IF
  366.                                 WEND
  367.                             ELSE
  368.                                 xx = startpos + LEN(entry$((yy - vertpos) / yyseparator))
  369.                                 LOCATE yy, xx
  370.                             END IF
  371.                         END IF
  372.  
  373.                     CASE CHR$(27)
  374.                         ch$ = CHR$(0)
  375.                         SYSTEM
  376.  
  377.                     CASE CHR$(0) + CHR$(82) ' Insert
  378.                         ch$ = CHR$(0)
  379.                         IF ins = 7 THEN ins = 30 ELSE ins = 7
  380.                         HideCursor ins
  381.  
  382.                     CASE CHR$(32) TO CHR$(126)
  383.                         IF hmrk > 0 THEN
  384.                             CALL replace(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, prompt_column, entryrow(), prompt$(), entry$(), hmrk, flag, dir)
  385.                         END IF
  386.                         IF ins = 30 THEN
  387.                             IF xx - startpos < MAX_SIZE - 1 THEN
  388.                                 MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1) = ch$
  389.                                 LOCATE yy, xx
  390.                                 PRINT ch$;
  391.                                 xx = xx + 1
  392.                                 LOCATE yy, xx
  393.                             END IF
  394.                         ELSE
  395.                             IF LEN(entry$((yy - vertpos) / yyseparator)) < MAX_SIZE - 1 THEN
  396.                                 PRINT ch$ + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1);
  397.                                 entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, xx - startpos) + ch$ + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1)
  398.                                 xx = xx + 1
  399.                                 LOCATE yy, xx
  400.                             END IF
  401.                         END IF
  402.                 END SELECT
  403.             END IF
  404.         END IF
  405.  
  406.         IF shift THEN
  407.             IF flag = 0 THEN
  408.                 flag = -1
  409.             END IF
  410.         ELSE
  411.             IF ch$ <> "" THEN
  412.                 IF flag AND shift = 0 AND LCASE$(ch$) <> "x" AND ctrl = 0 AND ch$ <> CHR$(8) AND ch$ <> CHR$(0) + "S" THEN
  413.                     COLOR c1f, c1b
  414.                     LOCATE oldyy, startpos
  415.                     IF ch$ <> CHR$(0) THEN
  416.                         PRINT ch$;
  417.                     END IF
  418.                     PRINT entry$((oldyy - vertpos) / yyseparator);
  419.                     LOCATE yy, xx
  420.                     hmrk = 0
  421.                     flag = 0
  422.                     dir = 0
  423.                 END IF
  424.             END IF
  425.         END IF
  426.         ch$ = ""
  427.     END IF
  428.  
  429. SUB mouse (startpos, vmax, xx, yy, vertpos, yyseparator, hmrk, dir, flag, c1f, c1b, c2f, c2b, drag, prompt_column, MAX_SIZE, shift, ch$, entry$(), entryrow())
  430.     STATIC doubleclick AS INTEGER, lbdn AS INTEGER, z1, oldmx AS INTEGER, oldmy AS INTEGER, mhl AS INTEGER
  431.     DIM mx AS INTEGER, my AS INTEGER, lb AS INTEGER
  432.  
  433.     LOCATE 20, 1
  434.     COLOR c1f, c1b
  435.     PRINT " oldmx"; oldmx; "  oldmy"; oldmy; "  mx"; mx; "  my"; my; "  lb"; lb; "  lbdn"; lbdn; "  dblclk"; doubleclick; "        "
  436.     PRINT " shift"; shift; "  drag"; drag; "  mhl"; mhl; "  hmrk"; hmrk; "  dir"; dir; "       "
  437.     PRINT " mx"; mx - startpos + 1; "  my"; (my - vertpos) / yyseparator; "  xx"; xx - startpos + 1; "  yy"; (yy - vertpos) / yyseparator; "        "
  438.     LOCATE yy, xx
  439.  
  440.  
  441.     mx = _MOUSEX
  442.     my = _MOUSEY
  443.     lb = _MOUSEBUTTON(1)
  444.  
  445.     IF lb AND flag AND drag = 0 THEN ' Allows highlighting caused by mouse click to be removed in parent sub.
  446.         ch$ = CHR$(0)
  447.         shift = 0
  448.         EXIT SUB
  449.     END IF
  450.  
  451.     IF shift AND lb OR mhl THEN
  452.         IF mhl = 0 THEN ' Shift + click highlighting.
  453.             IF my = yy AND mx <> xx AND mx >= startpos AND mx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) THEN
  454.                 mhl = mx - startpos + 1
  455.             END IF
  456.         ELSE ' Terminal point reached, end highlighting.
  457.             IF mhl = xx - startpos + 1 THEN mhl = 0: drag = 0: EXIT SUB
  458.         END IF
  459.     END IF
  460.  
  461.     IF LEN(entry$((yy - vertpos) / yyseparator)) THEN
  462.         IF lbdn AND xx <> mx OR mhl THEN ' Combined drag and shift + click highlighting.
  463.             IF mx >= startpos AND mx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) + 1 THEN
  464.                 IF lb OR mhl THEN
  465.                     IF xx > mx THEN
  466.                         drag = -1
  467.                     ELSE
  468.                         drag = 1
  469.                     END IF
  470.                     GOSUB mousedrag
  471.                     EXIT SUB
  472.                 ELSE
  473.                     drag = 0
  474.                 END IF
  475.             END IF
  476.         END IF
  477.     END IF
  478.  
  479.     IF lb THEN
  480.         LOCATE 2, 1: PRINT "left button down    "
  481.         IF my = yy THEN
  482.             IF mx >= startpos AND mx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) THEN
  483.                 IF drag = 0 AND shift = 0 THEN yy = my ' Prevents changing rows if a drag is in progress.
  484.                 xx = mx
  485.                 LOCATE yy, xx
  486.                 IF lbdn = 0 THEN lbdn = -1: oldmx = mx: oldmy = my
  487.             END IF
  488.         ELSE
  489.             FOR ii = 0 TO vmax - 1
  490.                 IF my = entryrow(ii) THEN
  491.                     EXIT FOR
  492.                 END IF
  493.             NEXT
  494.             IF my = entryrow(ii) AND drag = 0 AND shift = 0 THEN
  495.                 IF mx >= prompt_column AND mx - startpos <= MAX_SIZE THEN
  496.                     IF mx - startpos > 0 AND mx - startpos <= LEN(entry$(ii)) THEN
  497.                         yy = my: xx = mx
  498.                     ELSE
  499.                         yy = my: xx = startpos
  500.                     END IF
  501.                     LOCATE yy, xx
  502.                     IF lbdn = 0 THEN lbdn = -1
  503.                 END IF
  504.             END IF
  505.         END IF
  506.     ELSE
  507.         IF lbdn THEN
  508.             z1 = TIMER
  509.             LOCATE 2, 1: PRINT "left button released"
  510.             doubleclick = doubleclick + 1
  511.             lbdn = 0
  512.             drag = 0
  513.             mhl = 0
  514.         END IF
  515.     END IF
  516.  
  517.     IF doubleclick = 1 THEN
  518.         IF ABS(z1 - TIMER) > .33 THEN doubleclick = 0
  519.     END IF
  520.  
  521.     IF doubleclick = 2 THEN
  522.         ' Any double click events go here...
  523.         doubleclick = 0
  524.     END IF
  525.     LOCATE yy, xx
  526.  
  527.     EXIT SUB
  528.  
  529.     mousedrag:
  530.     SELECT CASE drag
  531.         CASE IS < 0
  532.             IF dir <= 0 THEN ' highlight to left
  533.                 IF dir = 0 THEN
  534.                     hmrk = xx - startpos + 1
  535.                     shift = -2 ' emulated shift key down
  536.                     flag = -1
  537.                 END IF
  538.                 xx = xx - 1
  539.                 LOCATE yy, xx
  540.                 COLOR c2f, c2b
  541.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  542.                 dir = dir - 1
  543.                 LOCATE yy, xx
  544.             ELSE ' unhighlight to left
  545.                 xx = xx - 1
  546.                 dir = dir - 1
  547.                 LOCATE yy, xx
  548.                 COLOR c1f, c1b
  549.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  550.                 IF dir = 0 THEN
  551.                     hmrk = 0
  552.                     flag = 0
  553.                     shift = 0
  554.                 END IF
  555.                 LOCATE yy, xx
  556.             END IF
  557.         CASE IS > 0
  558.             IF dir >= 0 THEN
  559.                 COLOR c2f, c2b
  560.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  561.                 IF dir = 0 THEN
  562.                     hmrk = xx - startpos + 1
  563.                     flag = -1
  564.                     shift = -2 ' emulated shift key down
  565.                 END IF
  566.                 xx = xx + 1
  567.                 dir = dir + 1
  568.                 LOCATE yy, xx
  569.             ELSE
  570.                 COLOR c1f, c1b
  571.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  572.                 xx = xx + 1
  573.                 dir = dir + 1
  574.                 IF dir = 0 THEN
  575.                     hmrk = 0
  576.                     flag = 0
  577.                     shift = 0
  578.                 END IF
  579.                 LOCATE yy, xx
  580.             END IF
  581.     END SELECT
  582.     RETURN
  583.  

Edited to correct bug in paste function.

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: Petr on July 22, 2019, 03:36:43 am
Hi Pete. I know very little C ++, but - do you use OpenGL to draw graphics in a C ++ program? Or you use something else for that? And beyond - I'm no longer absolutely sure here, but if QB64 adds libraries for audio and image decompression (next libraries) automatically, even though no commands using this are used, that might explain the difference in size.

But I say again, I just guess, I never really examined it in depth.

And then there's one more thing. QB64 adds C ++ control mechanisms, many control loops that RhoSigma suggested to turn off over $CHECKING: OFF, which probably doesn't contain your code. We discussed this here:
https://www.qb64.org/forum/index.php?topic=1348.msg105790#msg105790
Title: Re: QB64 vs same coded C/C++ program
Post by: Ashish on July 22, 2019, 08:34:41 am
...
So that code is about double the size of the one I just finished in QB64, yet, when compiled, the C/C++ one is approx. 1.5 MB, while the QB64 one is nearly double that, at 2.5 MB.
...
2.5MB? I compiled your code and the size of the executable is 2.0MB on my machine.
Title: Re: QB64 vs same coded C/C++ program
Post by: SMcNeill on July 22, 2019, 08:43:16 am
The biggest issue is that QB64 runs in a OpenGL graphical window.  Even screen 0 programs use OpenGL, unless you program them with $CONSOLE:ONLY, and even the smallest OpenGL program is a couple of MB in size.
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 22, 2019, 11:34:05 am
2.5MB? I compiled your code and the size of the executable is 2.0MB on my machine.

Are you using Windows? If not, maybe that's the reason. If so, that's strange, as the code above compiles to 2.494 KB.

@Steve. I think you nailed it again, Emu. The one I wrote in C/C+ uses the Windows console window. Well cool, that also means that the C/C++ code emited is probably pretty well optimized. Thanks for the reply.

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: bplus on July 22, 2019, 12:26:12 pm
Are you using Windows? If not, maybe that's the reason. If so, that's strange, as the code above compiles to 2.494 KB.

@Steve. I think you nailed it again, Emu. The one I wrote in C/C+ uses the Windows console window. Well cool, that also means that the C/C++ code emited is probably pretty well optimized. Thanks for the reply.

Pete


LOL someone else eyes are going bad too!
  [ This attachment cannot be displayed inline in 'Print Page' view ]  


But even common sense says, no regular QB64 program compiles to less than 2MB.
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 22, 2019, 12:56:19 pm
LOL, sorry. Typo. I hit the "." key instead of the "," key. Without my glasses, they all look alike. Sorry if that's too racist for anyone. Actually, come to think of it, the capital "A" key looks like a comma without my reading glasses, too.

2,494 KB

Anyway, thanks for compiling it, Mark. You got exactly what I did. I'm still curious why Ashish got less, unless he's not on Windows or he's using an older version of QB64, but till, I can't see why an older version would be that different.

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: bplus on July 22, 2019, 01:33:01 pm
Oh dang, I thought it was a debate about MB or KB, I see now Ashish gets .5 MB less than us.

How do you do that Ashish? Are you using special settings from jack or rhoSigma?

Title: Re: QB64 vs same coded C/C++ program
Post by: SMcNeill on July 22, 2019, 03:33:39 pm
Oh dang, I thought it was a debate about MB or KB, I see now Ashish gets .5 MB less than us.

How do you do that Ashish? Are you using special settings from jack or rhoSigma?

It may be the difference in 64-bit vs 32-bit compilation versions.
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 22, 2019, 04:03:35 pm
V1.3 is 64-bit, right? I downloaded a 64-bit one you recommended many moons ago, which was, at that time, not part of the official 32-bit release. I liked it, so I kept and used it, until I recently replaced it with the newer version 1.3. That's what I compile those one with, and Mark got the exact same size on his Windows system. Yes, maybe Ashish is using an older 32-bit system, but if so, I wonder why a 64-bit one would require another half meg?

If this was the old days I'd just assume he ran out of disk space, and only 2 of the 2.5 MB code got copied!

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: SMcNeill on July 22, 2019, 10:47:37 pm
V1.3 is 64-bit, right? I downloaded a 64-bit one you recommended many moons ago, which was, at that time, not part of the official 32-bit release. I liked it, so I kept and used it, until I recently replaced it with the newer version 1.3. That's what I compile those one with, and Mark got the exact same size on his Windows system. Yes, maybe Ashish is using an older 32-bit system, but if so, I wonder why a 64-bit one would require another half meg?

If this was the old days I'd just assume he ran out of disk space, and only 2 of the 2.5 MB code got copied!

Pete

V1.3 offers both a 32-bit version and a 64-bit version.  You can download both, if you want, and compile both 32/64 bit programs, and each will be a different size.
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 23, 2019, 12:22:11 am
I just checked. I definitely have the zip file for the 64-bit version 1.3. I think I'll wait to see what Ashish has. My guess is you are correct, and he is running the 32-bit version.

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: Petr on July 23, 2019, 02:43:00 am
Size 1.619.968 bytes if is compiled under QB ver 0.978,
       1.842.176 bytes if is compiled under QB ver 1.1
       2.333.184 bytes if is compiled under QB ver 1.2
       2.553.344 bytes if is compiled under QB ver 1.3

This all with 64 bit Windows 7.

The program is nice, the only thing I miss there is visibility of the cursor. He shows up there briefly after a mouse click, but then he is no longer visible. I like the possibility of editing already written text.
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 23, 2019, 03:38:35 am
Hi Petr,

You can REM out or get rid of these print lines, which obscure the cursor and are present just for testing...

    LOCATE 20, 1
    COLOR c1f, c1b
    PRINT " oldmx"; oldmx; "  oldmy"; oldmy; "  mx"; mx; "  my"; my; "  lb"; lb; "  lbdn"; lbdn; "  dblclk"; doubleclick; "        "
    PRINT " shift"; shift; "  drag"; drag; "  mhl"; mhl; "  hmrk"; hmrk; "  dir"; dir; "       "
    PRINT " mx"; mx - startpos + 1; "  my"; (my - vertpos) / yyseparator; "  xx"; xx - startpos + 1; "  yy"; (yy - vertpos) / yyseparator; "        "
    LOCATE yy, xx

--------------------

The code still needs some work. I'm currently trying to make it into a library, but a few of the variables are being stubborn.

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: Ashish on July 23, 2019, 08:41:16 am
I am using QB64 x32 V1.3 .
Title: Re: QB64 vs same coded C/C++ program
Post by: Ryster on July 23, 2019, 10:10:23 am
So out of curiosity, i compiled the code on my computer, result: 1847296 (1.76 MB)
Title: Re: QB64 vs same coded C/C++ program
Post by: Petr on July 23, 2019, 12:05:55 pm
Thank for reply, Pete, i think, with library is none problem if you add all to row 35 as .BI file and all from row 48 to end as .BM file. 

I would just recommend using long specific names of variables and fields so that their names indicate that they belong to this library and do not interfere with variables that could be the same in other code while keeping the current names.  I do that so, and it always help me, if write some library.
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 23, 2019, 05:37:56 pm
@Ashish: That's what Steve thought, it's the difference between your 32-bit and my 64 bit version. Thanks for getting back to us.

@Ryster: What version are you using, 32-bit or 64 bt, and what's the version number? Also, are you using Windows or another OS?

@Petr: Thanks for posting all those tests with various versions on your Windows 7. It's about a MB in range between all of those systems. Apparently, the newer versions and the 64-bit ones need to link more libraries, larger libraries, or some additional support information to the finished exe. Also, below is my beginnings into making what I initially posted int a usable library. Yes, I had that same thought about changing the variable names. I usually make programs with global variables, so this library, as currently written, would bite me in the ascii! Anyway, I may start another thread for this, as I'm curious if I could get away with fewer parameters to pass if I made my library variables into TYPES? Oh, and you can try this program, and turn on or off the variable displays. With the variable dispay off, you can see the cursor just fine.
------------------------------------------------------------

Here is the updated code, with some bug fixes and what I hope is the correct variable passing between subs. It compiled on my win 10 64-bit system running QB64 64-bit V1.3 @ 2,487 KB. Again, approx 2.5 MB.

Code: QB64: [Select]
  1. main:
  2. ' The next two lines can be removed to use this library with other programs.
  3. LINE INPUT "Input 1 for debug mode with variable display, any other to turn debug off. "; a$
  4. IF a$ = "1" THEN DIM SHARED debug: debug = -1
  5.  
  6. ' Place the routine that will use this library above and/or inside this loop...
  7. WHILE (1)
  8.     CALL UserInput
  9.  
  10. '=============================CONSOLE INPUT LIBRARY===========================
  11.  
  12. SUB UserInput
  13.     STATIC UserInputSetup AS INTEGER
  14.     STATIC MAX_SIZE AS INTEGER, prompt_column AS INTEGER, startpos AS INTEGER, vertpos AS INTEGER, endpos AS INTEGER, yyseparator AS INTEGER, ins AS INTEGER
  15.     STATIC entry$(), xntry$(), prompt$(), entryrow() AS INTEGER
  16.     STATIC xx AS INTEGER, yy AS INTEGER
  17.  
  18.     IF UserInputSetup = 0 THEN
  19.  
  20.         CONST prompt_length = 17 'Length of the longest prompt.
  21.         CONST vmax = 4 'Number of prompts. Must not exceed rows of screen.
  22.         CONST c1f = 0: CONST c1b = 7 'Default foreground and background text/screen colors.
  23.         CONST c2f = 7: CONST c2b = 1 'Text highlighting color.
  24.  
  25.         DIM entry$(vmax) 'Text entry array.
  26.         DIM prompt$(vmax) 'Prompt array.
  27.         DIM entryrow(vmax) AS INTEGER 'Tracks row location of each prompt.
  28.  
  29.         MAX_SIZE = 36
  30.         prompt_column = 10 'Number of columns to indent prompts.
  31.         startpos = prompt_column + prompt_length - 1
  32.         vertpos = 5
  33.         endpos = startpos + MAX_SIZE
  34.         yyseparator = 2 'Number of blank rows, less 1, between prompts. Do not set lower than 1.
  35.         ins = 7 'Cursor vertical height for default insert text mode.
  36.  
  37.         CALL SetTitle
  38.  
  39.         CALL SetConsole(c1f, c1b)
  40.  
  41.         CALL GetPrompts(startpos, vertpos, vmax, yyseparator, xx, yy, prompt_column, entryrow(), prompt$())
  42.  
  43.         CALL SetCursor(ins)
  44.  
  45.         UserInputSetup = -1
  46.     END IF
  47.  
  48.     CALL GetConsoleInput(startpos, endpos, vertpos, vmax, yyseparator, xx, yy, ins, MAX_SIZE, c1f, c1b, c2f, c2b, prompt_column, entryrow(), entry$())
  49.  
  50.  
  51. SUB SetTitle
  52.     title$ = "Pete's Custom Keyboard Input App"
  53.     _TITLE title$
  54.  
  55. SUB SetConsole (c1f AS INTEGER, c1b AS INTEGER)
  56.     PALETTE 7, 63
  57.     COLOR c1f, c1b
  58.     CLS
  59.  
  60. SUB GetPrompts (startpos AS INTEGER, vertpos AS INTEGER, vmax AS INTEGER, yyseparator AS INTEGER, xx AS INTEGER, yy AS INTEGER, prompt_column AS INTEGER, entryrow() AS INTEGER, prompt$())
  61.     DIM ii AS INTEGER
  62.  
  63.     xx = startpos
  64.     yy = vertpos
  65.  
  66.     prompt$(0) = "Name..........: "
  67.     prompt$(1) = "Address.......: "
  68.     prompt$(2) = "City/State/Zip: "
  69.     prompt$(3) = "Phone.........: "
  70.  
  71.     yy = vertpos
  72.  
  73.     FOR ii = 0 TO vmax - 1
  74.         LOCATE yy, prompt_column
  75.         PRINT prompt$(ii);
  76.         entryrow(ii) = yy
  77.         yy = yy + yyseparator
  78.     NEXT
  79.  
  80.     LOCATE vertpos, startpos
  81.     xx = startpos
  82.     yy = vertpos
  83.  
  84. SUB SetCursor (ins AS INTEGER)
  85.     LOCATE , , 1, 7, ins
  86.  
  87. SUB copy (startpos AS INTEGER, vertpos AS INTEGER, yyseparator AS INTEGER, xx AS INTEGER, yy AS INTEGER, hmrk AS INTEGER, entry$(), xntry$)
  88.     DIM m1 AS INTEGER, m2 AS INTEGER
  89.  
  90.     IF xx - startpos + 1 < hmrk THEN
  91.         m2 = hmrk
  92.         m1 = xx - startpos + 1
  93.     ELSE
  94.         m1 = hmrk
  95.         m2 = xx - startpos + 1
  96.     END IF
  97.     xntry$ = MID$(entry$((yy - vertpos) / yyseparator), m1, m2 - m1)
  98.  
  99. SUB replace (startpos AS INTEGER, vertpos AS INTEGER, yyseparator AS INTEGER, xx AS INTEGER, yy AS INTEGER, entry$(), hmrk AS INTEGER, highlighton AS INTEGER, dir AS INTEGER, c1f AS INTEGER, c1b AS INTEGER)
  100.     DIM j AS INTEGER, m1 AS INTEGER, m2 AS INTEGER
  101.  
  102.     j = LEN(entry$((yy - vertpos) / yyseparator))
  103.     COLOR c1f, c1b
  104.     IF xx - startpos + 1 < hmrk THEN
  105.         m2 = hmrk
  106.         m1 = xx - startpos
  107.     ELSE
  108.         m1 = hmrk - 1
  109.         m2 = xx - startpos + 1
  110.     END IF
  111.     entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, m1) + MID$(entry$((yy - vertpos) / yyseparator), m2)
  112.     LOCATE yy, startpos
  113.     PRINT entry$((yy - vertpos) / yyseparator);
  114.     PRINT STRING$(j - LEN(entry$((yy - vertpos) / yyseparator)), 32);
  115.     IF xx - startpos + 1 > hmrk THEN
  116.         xx = hmrk - 1 + startpos
  117.     END IF
  118.     LOCATE yy, xx
  119.     hmrk = 0
  120.     highlighton = 0
  121.     dir = 0
  122.  
  123. SUB GetConsoleInput (startpos AS INTEGER, endpos AS INTEGER, vertpos AS INTEGER, vmax AS INTEGER, yyseparator AS INTEGER, xx AS INTEGER, yy AS INTEGER, ins AS INTEGER, MAX_SIZE AS INTEGER, c1f AS INTEGER, c1b AS INTEGER, c2f AS INTEGER, c2b AS INTEGER, prompt_column AS INTEGER, entryrow() AS INTEGER, entry$())
  124.     STATIC drag AS INTEGER, dir AS INTEGER, highlighton AS INTEGER, hmrk AS INTEGER, xntry$, shift AS INTEGER
  125.     DIM ii AS INTEGER, oldyy AS INTEGER
  126.     DIM xntry$(MAX_SIZE) 'Cut/Copy array.
  127.  
  128.     IF ctrl THEN ctrl = 0
  129.     IF shift < 0 THEN shift = 0
  130.     DEF SEG = 0
  131.     ii = PEEK(&H417) MOD 16
  132.     SELECT CASE ii
  133.         CASE 1, 2
  134.             shift = -1
  135.         CASE 4
  136.             ctrl = -1
  137.     END SELECT
  138.     DEF SEG
  139.  
  140.     oldyy = yy
  141.  
  142.     IF drag = 0 THEN
  143.         IF highlighton AND shift = 0 AND hmrk = 0 THEN
  144.             highlighton = 0 ' Disable highlighton so character value isn't printed after a shift / release event without highlighting.
  145.         END IF
  146.     END IF
  147.  
  148.     CALL mouse(startpos, vmax, xx, yy, vertpos, yyseparator, hmrk, dir, highlighton, c1f, c1b, c2f, c2b, drag, prompt_column, MAX_SIZE, shift, ch$, entry$(), entryrow())
  149.  
  150.     IF drag = 0 THEN
  151.         IF ch$ = "" THEN ch$ = INKEY$
  152.         IF ch$ <> "" THEN
  153.             IF ctrl THEN
  154.                 SELECT CASE LCASE$(ch$)
  155.                     CASE CHR$(1) ' Select All
  156.                         LOCATE yy, startpos
  157.                         COLOR c2f, c2b
  158.                         PRINT entry$((yy - vertpos) / yyseparator);
  159.                         COLOR c1f, c1b
  160.                         hmrk = 1
  161.                         highlighton = -1
  162.                         dir = LEN(entry$((yy - vertpos) / yyseparator))
  163.                         xx = startpos + dir
  164.                         LOCATE yy, xx
  165.  
  166.                     CASE CHR$(3) ' Copy
  167.                         IF hmrk THEN
  168.                             CALL copy(startpos, vertpos, yyseparator, xx, yy, hmrk, entry$(), xntry$)
  169.                         END IF
  170.  
  171.                     CASE CHR$(24) ' Cut
  172.                         IF hmrk THEN
  173.                             CALL copy(startpos, vertpos, yyseparator, xx, yy, hmrk, entry$(), xntry$)
  174.                             CALL replace(startpos, vertpos, yyseparator, xx, yy, entry$(), hmrk, highlighton, dir, c1f, c1b)
  175.                         END IF
  176.  
  177.                     CASE CHR$(22) ' Paste
  178.                         IF xntry$ <> "" THEN
  179.                             IF hmrk THEN
  180.                                 CALL replace(startpos, vertpos, yyseparator, xx, yy, entry$(), hmrk, highlighton, dir, c1f, c1b)
  181.                             END IF
  182.                             m1 = xx - startpos
  183.                             m2 = m1 + 1
  184.                             IF LEN(xntry$) + LEN(entry$((yy - vertpos) / yyseparator)) - (m2 - m1) <= MAX_SIZE - 1 THEN
  185.                                 entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, m1) + xntry$ + MID$(entry$((yy - vertpos) / yyseparator), m2)
  186.                                 LOCATE yy, startpos
  187.                                 COLOR c1f, c1b
  188.                                 PRINT entry$((yy - vertpos) / yyseparator);
  189.                                 xx = xx + LEN(xntry$)
  190.                                 LOCATE yy, xx
  191.                             ELSE
  192.                                 BEEP ' Contents too large to paste.
  193.                             END IF
  194.                         END IF
  195.                 END SELECT
  196.             ELSE
  197.                 SELECT CASE ch$
  198.                     CASE CHR$(8) ' Backspace
  199.                         ch$ = CHR$(0)
  200.                         IF hmrk > 0 THEN
  201.                             CALL replace(startpos, vertpos, yyseparator, xx, yy, entry$(), hmrk, highlighton, dir, c1f, c1b)
  202.                         ELSE
  203.                             IF xx > startpos THEN
  204.                                 xx = xx - 1
  205.                                 LOCATE yy, xx
  206.                                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2); " ";
  207.                                 entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, xx - startpos) + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2)
  208.                                 LOCATE yy, xx
  209.                             END IF
  210.                         END IF
  211.                     CASE CHR$(0) + "S" ' Delete
  212.                         IF shift THEN
  213.                             IF hmrk THEN
  214.                                 CALL copy(startpos, vertpos, yyseparator, xx, yy, hmrk, entry$(), xntry$)
  215.                                 CALL replace(startpos, vertpos, yyseparator, xx, yy, entry$(), hmrk, highlighton, dir, c1f, c1b)
  216.                             END IF
  217.                         ELSE
  218.                             ch$ = CHR$(0)
  219.                             IF hmrk > 0 THEN
  220.                                 CALL replace(startpos, vertpos, yyseparator, xx, yy, entry$(), hmrk, highlighton, dir, c1f, c1b)
  221.                             ELSE
  222.                                 IF LEN(entry$((yy - vertpos) / yyseparator)) > 0 AND xx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) THEN
  223.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2); " ";
  224.                                     entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, xx - startpos) + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 2)
  225.                                     LOCATE yy, xx
  226.                                 END IF
  227.                             END IF
  228.                         END IF
  229.  
  230.                     CASE CHR$(0) + "H" ' Arrow up
  231.                         ch$ = CHR$(0)
  232.                         IF yy > vertpos THEN
  233.                             yy = yy - yyseparator
  234.                             xx = startpos
  235.                             LOCATE yy, xx
  236.                         END IF
  237.  
  238.                     CASE CHR$(0) + "P", CHR$(13) ' Arrow down, Enter
  239.                         ch$ = CHR$(0)
  240.                         IF (yy - vertpos) / yyseparator + 1 < vmax THEN
  241.                             yy = yy + yyseparator
  242.                             xx = startpos
  243.                             LOCATE yy, xx
  244.                         END IF
  245.  
  246.                     CASE CHR$(0) + "K" ' Arrow left
  247.                         ch$ = CHR$(0)
  248.                         IF xx > startpos THEN
  249.                             IF shift THEN
  250.                                 IF dir <= 0 THEN
  251.                                     IF dir = 0 THEN
  252.                                         hmrk = xx - startpos + 1
  253.                                         highlighton = -1
  254.                                     END IF
  255.                                     xx = xx - 1
  256.                                     LOCATE yy, xx
  257.                                     COLOR c2f, c2b
  258.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  259.                                     dir = dir - 1
  260.                                     LOCATE yy, xx
  261.                                 ELSE
  262.                                     xx = xx - 1
  263.                                     LOCATE yy, xx
  264.                                     COLOR c1f, c1b
  265.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  266.                                     dir = dir - 1
  267.                                     IF dir = 0 THEN
  268.                                         hmrk = 0
  269.                                     END IF
  270.                                     LOCATE yy, xx
  271.                                 END IF
  272.  
  273.                             ELSE
  274.                                 xx = xx - 1
  275.                                 LOCATE yy, xx
  276.                             END IF
  277.                         END IF
  278.  
  279.                     CASE CHR$(0) + "M" ' Arrow right
  280.                         ch$ = CHR$(0)
  281.                         IF xx < endpos - 1 AND xx - startpos < LEN(entry$((yy - vertpos) / yyseparator)) THEN
  282.                             IF shift THEN
  283.                                 IF dir >= 0 THEN
  284.                                     IF dir = 0 THEN
  285.                                         hmrk = xx - startpos + 1
  286.                                         highlighton = -1
  287.                                     END IF
  288.                                     COLOR c2f, c2b
  289.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  290.                                     xx = xx + 1
  291.                                     LOCATE yy, xx
  292.                                     dir = dir + 1
  293.                                     LOCATE yy, xx
  294.                                 ELSE
  295.                                     COLOR c1f, c1b
  296.                                     PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  297.                                     xx = xx + 1
  298.                                     dir = dir + 1
  299.                                     IF dir = 0 THEN
  300.                                         hmrk = 0
  301.                                         highlighton = 0
  302.                                     END IF
  303.                                     LOCATE yy, xx
  304.                                 END IF
  305.                             ELSE
  306.                                 xx = xx + 1
  307.                                 LOCATE yy, xx
  308.                             END IF
  309.                         END IF
  310.  
  311.                     CASE CHR$(0) + "G" ' Home
  312.                         ch$ = CHR$(0)
  313.                         IF xx > startpos THEN
  314.                             IF shift THEN
  315.                                 WHILE xx > startpos
  316.                                     IF dir <= 0 THEN
  317.                                         IF dir = 0 THEN
  318.                                             hmrk = xx - startpos + 1
  319.                                             ' highlighton is already set.
  320.                                         END IF
  321.                                         xx = xx - 1
  322.                                         LOCATE yy, xx
  323.                                         COLOR c2f, c2b
  324.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  325.                                         dir = dir - 1
  326.                                         LOCATE yy, xx
  327.                                     ELSE
  328.                                         xx = xx - 1
  329.                                         LOCATE yy, xx
  330.                                         COLOR c1f, c1b
  331.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  332.                                         dir = dir - 1
  333.                                         IF dir = 0 THEN
  334.                                             hmrk = 0
  335.                                             highlighton = 0
  336.                                         END IF
  337.                                         LOCATE yy, xx
  338.                                     END IF
  339.                                 WEND
  340.                             ELSE
  341.                                 xx = startpos
  342.                                 LOCATE yy, xx
  343.                             END IF
  344.                         END IF
  345.  
  346.                     CASE CHR$(0) + "O" ' End
  347.                         ch$ = CHR$(0)
  348.                         IF xx < endpos - 1 THEN
  349.                             IF shift THEN
  350.                                 WHILE xx - startpos < LEN(entry$((yy - vertpos) / yyseparator))
  351.                                     IF dir >= 0 THEN
  352.                                         IF dir = 0 THEN
  353.                                             hmrk = xx - startpos + 1
  354.                                             highlighton = -1
  355.                                         END IF
  356.                                         COLOR c2f, c2b
  357.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  358.                                         xx = xx + 1
  359.                                         LOCATE yy, xx
  360.                                         dir = dir + 1
  361.                                         LOCATE yy, xx
  362.                                     ELSE
  363.                                         COLOR c1f, c1b
  364.                                         PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1);
  365.                                         xx = xx + 1
  366.                                         dir = dir + 1
  367.                                         IF dir = 0 THEN
  368.                                             hmrk = 0
  369.                                         END IF
  370.                                         LOCATE yy, xx
  371.                                     END IF
  372.                                 WEND
  373.                             ELSE
  374.                                 xx = startpos + LEN(entry$((yy - vertpos) / yyseparator))
  375.                                 LOCATE yy, xx
  376.                             END IF
  377.                         END IF
  378.  
  379.                     CASE CHR$(27)
  380.                         ch$ = CHR$(0)
  381.                         SYSTEM
  382.  
  383.                     CASE CHR$(0) + CHR$(82) ' Insert
  384.                         ch$ = CHR$(0)
  385.                         IF ins = 7 THEN ins = 30 ELSE ins = 7
  386.                         SetCursor ins
  387.  
  388.                     CASE CHR$(32) TO CHR$(126)
  389.                         IF hmrk > 0 THEN
  390.                             CALL replace(startpos, vertpos, yyseparator, xx, yy, entry$(), hmrk, highlighton, dir, c1f, c1b)
  391.                         END IF
  392.                         IF ins = 30 THEN
  393.                             IF xx - startpos < MAX_SIZE - 1 THEN
  394.                                 MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1) = ch$
  395.                                 LOCATE yy, xx
  396.                                 PRINT ch$;
  397.                                 xx = xx + 1
  398.                                 LOCATE yy, xx
  399.                             END IF
  400.                         ELSE
  401.                             IF LEN(entry$((yy - vertpos) / yyseparator)) < MAX_SIZE - 1 THEN
  402.                                 PRINT ch$ + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1);
  403.                                 entry$((yy - vertpos) / yyseparator) = MID$(entry$((yy - vertpos) / yyseparator), 1, xx - startpos) + ch$ + MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1)
  404.                                 xx = xx + 1
  405.                                 LOCATE yy, xx
  406.                             END IF
  407.                         END IF
  408.                 END SELECT
  409.             END IF
  410.         END IF
  411.  
  412.         IF shift THEN
  413.             IF highlighton = 0 AND dir <> 0 THEN
  414.                 highlighton = -1 ' When dir <> 0 the first character has been highlighted.
  415.             END IF
  416.         ELSE
  417.             IF ch$ <> "" THEN
  418.                 IF highlighton AND shift = 0 AND LCASE$(ch$) <> "x" AND ctrl = 0 AND ch$ <> CHR$(8) AND ch$ <> CHR$(0) + "S" THEN
  419.                     ' ROutine to remove highlighting from text.
  420.                     COLOR c1f, c1b
  421.                     LOCATE oldyy, startpos
  422.                     IF ch$ <> CHR$(0) THEN
  423.                         PRINT ch$;
  424.                     END IF
  425.                     PRINT entry$((oldyy - vertpos) / yyseparator);
  426.                     LOCATE yy, xx
  427.                     hmrk = 0
  428.                     highlighton = 0
  429.                     dir = 0
  430.                 END IF
  431.             END IF
  432.         END IF
  433.         ch$ = ""
  434.     END IF
  435.  
  436. SUB mouse (startpos AS INTEGER, vmax AS INTEGER, xx AS INTEGER, yy AS INTEGER, vertpos AS INTEGER, yyseparator AS INTEGER, hmrk AS INTEGER, dir AS INTEGER, highlighton AS INTEGER, c1f AS INTEGER, c1b AS INTEGER, c2f AS INTEGER, c2b AS INTEGER, drag AS INTEGER, prompt_column AS INTEGER, MAX_SIZE AS INTEGER, shift AS INTEGER, ch$, entry$(), entryrow() AS INTEGER)
  437.     STATIC doubleclick AS INTEGER, lb AS INTEGER, lbdn AS INTEGER, z1, oldmx AS INTEGER, oldmy AS INTEGER, mhl AS INTEGER
  438.     STATIC mx AS INTEGER, my AS INTEGER
  439.     DIM ii AS INTEGER
  440.  
  441.     IF debug THEN
  442.         LOCATE 20, 1
  443.         COLOR c1f, c1b
  444.         PRINT " oldmx"; oldmx; "  oldmy"; oldmy; "  mx"; mx; "  my"; my; "  xx"; xx; "  yy"; yy; "  lb"; lb; "  lbdn"; lbdn; "      "
  445.         PRINT " shift"; shift; "  drag"; drag; "  mhl"; mhl; "  hmrk"; hmrk; "  dir"; dir; "  dblclk"; doubleclick; "  startpos"; startpos; "        "
  446.         PRINT " mx"; mx - startpos + 1; "  my"; (my - vertpos) / yyseparator; "  xx"; xx - startpos + 1; "  yy"; (yy - vertpos) / yyseparator; "        "
  447.         PRINT " highlighton"; highlighton; "     ";
  448.         LOCATE yy, xx
  449.     END IF
  450.  
  451.     mx = _MOUSEX
  452.     my = _MOUSEY
  453.     lb = _MOUSEBUTTON(1)
  454.  
  455.     IF lb AND highlighton AND shift = 0 AND drag = 0 AND mhl = 0 THEN ' Allows highlighting caused by mouse click to be removed in parent sub.
  456.         ch$ = CHR$(0)
  457.         EXIT SUB
  458.     END IF
  459.  
  460.     IF shift AND lb AND drag = 0 OR mhl THEN
  461.         IF mhl = 0 THEN ' Shift + click highlighting.
  462.             IF my = yy AND mx <> xx AND mx >= startpos AND mx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) THEN
  463.                 mhl = mx - startpos + 1
  464.             END IF
  465.         ELSE ' Terminal point reached, end highlighting.
  466.             IF mhl = xx - startpos + 1 THEN mhl = 0: drag = 0: EXIT SUB
  467.         END IF
  468.     END IF
  469.  
  470.     IF LEN(entry$((yy - vertpos) / yyseparator)) THEN
  471.         IF lbdn AND xx <> mx AND shift = 0 OR mhl THEN ' Combined drag and shift + click highlighting.
  472.             IF my = yy THEN ' Restrict to active text line.
  473.                 IF lb OR mhl THEN
  474.                     IF xx > mx THEN
  475.                         drag = -1
  476.                     ELSE
  477.                         drag = 1
  478.                     END IF
  479.                     GOSUB mousedrag
  480.                     EXIT SUB
  481.                 ELSE
  482.                     drag = 0
  483.                 END IF
  484.             END IF
  485.         END IF
  486.     END IF
  487.  
  488.     IF lb THEN
  489.         IF debug THEN COLOR c1f, c1b: LOCATE 2, 1: PRINT "left button down    "
  490.         IF lbdn = 0 THEN lbdn = -1
  491.         IF my = yy THEN
  492.             IF mx >= startpos AND mx - startpos <= LEN(entry$((yy - vertpos) / yyseparator)) THEN
  493.                 IF drag = 0 AND shift = 0 THEN yy = my ' Prevents changing rows if a drag is in progress.
  494.                 xx = mx
  495.                 LOCATE yy, xx
  496.                 oldmx = mx: oldmy = my
  497.             END IF
  498.         ELSEIF shift = 0 THEN
  499.             FOR ii = 0 TO vmax - 1
  500.                 IF my = entryrow(ii) THEN EXIT FOR
  501.             NEXT
  502.  
  503.             IF my = entryrow(ii) AND drag = 0 THEN
  504.                 IF mx >= prompt_column AND mx - startpos <= MAX_SIZE THEN
  505.                     IF mx - startpos > 0 AND mx - startpos <= LEN(entry$(ii)) THEN
  506.                         yy = my: xx = mx
  507.                     ELSE
  508.                         yy = my: xx = startpos
  509.                     END IF
  510.                     LOCATE yy, xx
  511.                 END IF
  512.             END IF
  513.         END IF
  514.     ELSE
  515.         IF lbdn THEN
  516.             z1 = TIMER
  517.             IF debug THEN COLOR c1f, c1b: LOCATE 2, 1: PRINT "left button released"
  518.             doubleclick = doubleclick + 1
  519.             lbdn = 0
  520.             drag = 0
  521.         END IF
  522.     END IF
  523.  
  524.     IF doubleclick = 1 THEN
  525.         IF ABS(z1 - TIMER) > .33 THEN doubleclick = 0
  526.     END IF
  527.  
  528.     IF doubleclick = 2 THEN
  529.         ' Any double click events go here...
  530.         IF debug THEN LOCATE 2, 1: PRINT "double click         ";
  531.         doubleclick = 0
  532.     END IF
  533.     LOCATE yy, xx
  534.  
  535.     EXIT SUB
  536.  
  537.     mousedrag:
  538.     SELECT CASE drag
  539.         CASE IS < 0
  540.             IF dir <= 0 THEN ' highlight to left
  541.                 IF dir = 0 THEN
  542.                     hmrk = xx - startpos + 1
  543.                     ' Do not emulate shift here. shift remains 0.
  544.                     highlighton = -1
  545.                 END IF
  546.                 xx = xx - 1
  547.                 LOCATE yy, xx
  548.                 COLOR c2f, c2b
  549.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  550.                 dir = dir - 1
  551.                 LOCATE yy, xx
  552.             ELSE ' unhighlight to left
  553.                 xx = xx - 1
  554.                 dir = dir - 1
  555.                 LOCATE yy, xx
  556.                 COLOR c1f, c1b
  557.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  558.                 IF dir = 0 THEN
  559.                     hmrk = 0
  560.                     highlighton = 0
  561.                     shift = 0
  562.                 END IF
  563.                 LOCATE yy, xx
  564.             END IF
  565.         CASE IS > 0
  566.             IF dir >= 0 THEN
  567.                 COLOR c2f, c2b
  568.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  569.                 IF dir = 0 THEN
  570.                     hmrk = xx - startpos + 1
  571.                     highlighton = -1
  572.                     ' Do not emulate shift here. shift remains 0.
  573.                 END IF
  574.                 xx = xx + 1
  575.                 dir = dir + 1
  576.                 LOCATE yy, xx
  577.             ELSE
  578.                 COLOR c1f, c1b
  579.                 PRINT MID$(entry$((yy - vertpos) / yyseparator), xx - startpos + 1, 1)
  580.                 xx = xx + 1
  581.                 dir = dir + 1
  582.                 IF dir = 0 THEN
  583.                     hmrk = 0
  584.                     highlighton = 0
  585.                     shift = 0
  586.                 END IF
  587.                 LOCATE yy, xx
  588.             END IF
  589.     END SELECT
  590.     RETURN
  591.  

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: Ryster on July 24, 2019, 09:44:03 am
The result of the compilation: 1847296 (1.76 MB)
Windows 10 - 1903, 64-bit. >>> QB64 1.2 - 32-bit.
Title: Re: QB64 vs same coded C/C++ program
Post by: Pete on July 24, 2019, 12:04:49 pm
Thank you. It seems there is a pattern emerging that 64-bit versions of QB64 compile to larger exe files than the 32-bit versions, and that the higher versions (more recent versions) likewise, compile larger exe files.

Pete
Title: Re: QB64 vs same coded C/C++ program
Post by: SMcNeill on July 24, 2019, 03:12:23 pm
Thank you. It seems there is a pattern emerging that 64-bit versions of QB64 compile to larger exe files than the 32-bit versions, and that the higher versions (more recent versions) likewise, compile larger exe files.

Pete

Remember: V1.3 swapped out to the latest MinGW compiler.  Prior versions used an old version of mingw which probably dated back to the Stone Age when LET was still in use by primitive programmers.
Title: Re: QB64 vs same coded C/C++ program
Post by: Ryster on July 24, 2019, 03:43:15 pm
SMcNeill.
It's nice to see that now you've come to the conclusion that previous versions were from the age of the splitting spit. As I wrote once, that the previous versions are unusable (at least in my case) that a lot of epithets rushed on my head, and that was what Clippy was leading. The only version that can meet my code is version 1.3 of December 2018 and I use it every day. Other non-useable ones.