Author Topic: QB64 vs same coded C/C++ program  (Read 4546 times)

0 Members and 1 Guest are viewing this topic.

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
Re: QB64 vs same coded C/C++ program
« Reply #15 on: July 23, 2019, 10:10:23 am »
So out of curiosity, i compiled the code on my computer, result: 1847296 (1.76 MB)

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: QB64 vs same coded C/C++ program
« Reply #16 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.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: QB64 vs same coded C/C++ program
« Reply #17 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
Re: QB64 vs same coded C/C++ program
« Reply #18 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.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: QB64 vs same coded C/C++ program
« Reply #19 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64 vs same coded C/C++ program
« Reply #20 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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
Re: QB64 vs same coded C/C++ program
« Reply #21 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.
« Last Edit: July 24, 2019, 03:47:18 pm by Ryster »