Author Topic: A skeleton code for Text Scroller via Drag-and-Drop  (Read 10430 times)

0 Members and 1 Guest are viewing this topic.

Offline Sanmayce

  • Newbie
  • Posts: 63
  • Where is that English Text Sidekick?
    • Sanmayce's home
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #15 on: January 21, 2021, 01:00:35 am »
@NOVARSEG

Thank you for the hint, will try it, currently I am using an old laptop with Windows XP 32bit paired with a buggy ATI videocard (causing text to be blurred if more than ~130 columns are used), next week I will get access to my main laptop with Windows 10 64bit with i5-7200u and 36GB, at the moment my brother is repairing it, it is 4 years old, almost.

Thanks Sanmayce


You will like the fact that QB64 string size is over 2GB

Did you ever use DOS interrupts . Ralf Brown interrupt list etc?

Oh, good to know, I love strings, the thing is, over the years just switched to C and changed the approach to pointers. Will share inhere how the scrolling of 1+GB texts is handled...

As for interrupts, yeah, I wrote some resident keyboard tools, switching fonts and languages, KAZUMA.COM it was called, it featured AFAIR 11 fonts and using the 28 lines. But mostly I used MASM to write all my functions and link them to QB, the main thing was to use XMS memory from QB, also writing 3D windows waiting for the refresh beam to scan again, the time between refreshing was pretty enough to achieve smooth scrolling and drawing. Also, wrote OTANE.BAS - the fastest VESA 1.2 graphical PCX viewer/scroller, it rotated images, AFAIR reaching 44 fps on some 486DX100MHz in 1024x768, forgot already, did attach them anyway:
 
« Last Edit: January 21, 2021, 01:02:18 am by Sanmayce »
He learns not to learn and reverts to what all men pass by.

Offline Sanmayce

  • Newbie
  • Posts: 63
  • Where is that English Text Sidekick?
    • Sanmayce's home
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #16 on: January 22, 2021, 02:53:26 am »
The first INITIAL revision is done, from which I will add more and more features...

Just added few things:
- ICON;
- increased the LIMIT to 500 iterations, as suggested by @NOVARSEG (glad to see the scroll is smoothly going, now);
- sensitive to writing to CONSOLE;
- added the must-have system stats by @SMcNeill from his MEMUSAGE.BAS;

Wanted to have the very first revision attached as a starting point.

My brother finished repairing my main laptop 'Compressionette', sharing three screenshots:

 
Masakari_1.png


 
Masakari_2.png


 
Masakari_3.png


And the source attached: 
* Masakari_source.zip (Filesize: 6.69 MB, Downloads: 150)
« Last Edit: January 22, 2021, 02:56:29 am by Sanmayce »
He learns not to learn and reverts to what all men pass by.

Offline Sanmayce

  • Newbie
  • Posts: 63
  • Where is that English Text Sidekick?
    • Sanmayce's home
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #17 on: January 24, 2021, 01:13:33 pm »
Last night wrote the first meaningful i.e. practical revision, revision 2, featuring:

 

- the loaded file now is viewable i.e. scrollable;
- loading the file alternatively via command prompt;
- TAB2SPC expander;
- Line Wrapper, commented out since currently is not needed;
- now there is a status line;
- should be compilable on Linux;
- Mouse Button 3 - works as if PgDn is pressed;
- LSHIFT+RSHIFT prints in the lowest/status line the time needed to load;
- LCtrl+Home, LCtrl+End  - going to the top/bottom left position;

In the future, I intend to write a streaming revision able to show only the window (dynamically loading only the needed for visualization content) thus saving RAM and TIME, for example current English Wikipedia XML dump is 81+ billion bytes having longest line around 1 million chars, it means that the RAM for browsing this Wikipedia will be less than 60x1MB i.e. 60 lines padded with spaces... For now, let us see how one paragon 500MB file stresses the current ALL-TO-RAM approach:

On my fastest laptop with i5-7200U did try to load the whole Oxford English Dictionary, the performance of LINE INPUT is awful, in next revisions will bypass it altogether by replacing it with my own pointer based function, similar to the 'LineWordreporter.c' (included in the attached package) - wrote it to serve as a quick file reporter.

 
Masakari_source_rev2_on_i5-7200U_1.png


 
Masakari_source_rev2_on_i5-7200U_2.png


 
Masakari_source_rev2_on_i5-7200U_3.png


The benchmark shows, OED took 23,187 seconds or 6+ hours to be loaded via LINE INPUT, unacceptable! Any idea why so?
Holding the Mouse Button 3 for:
19:19:00
19:22:38
or 22*60+38-19*60+00=218 seconds scrolled all the 4 million lines, or 4,071,706/60=67861 pages, which is 67861/218=311 Pages-Per-Second, nice.

There is a Keyboard SUB called 'ReturnCombo' returning in shared variables many to-be-used shortcuts as:
    LSHIFT_RSHIFT
    LCTRL_RCTRL
    LALT_RALT

    LALT_HOME
    LALT_END

    LALT_INS
    LALT_DEL

    LALT_PGUP
    LALT_PGDN

    LALT_Left
    LALT_Right
    LALT_Up
    LALT_Down

    RALT_HOME
    RALT_END

    RALT_INS
    RALT_DEL

    RALT_PGUP
    RALT_PGDN

    RALT_Left
    RALT_Right
    RALT_Up
    RALT_Down

    LSHIFT_HOME
    LSHIFT_END

    LSHIFT_INS
    LSHIFT_DEL

    LSHIFT_PGUP
    LSHIFT_PGDN

    LSHIFT_Left
    LSHIFT_Right
    LSHIFT_Up
    LSHIFT_Down

    RSHIFT_HOME
    RSHIFT_END

    RSHIFT_INS
    RSHIFT_DEL

    RSHIFT_PGUP
    RSHIFT_PGDN

    RSHIFT_Left
    RSHIFT_Right
    RSHIFT_Up
    RSHIFT_Down

    LCTRL_HOME
    LCTRL_END

    LCTRL_INS
    LCTRL_DEL

    LCTRL_PGUP
    LCTRL_PGDN

    LCTRL_Left
    LCTRL_Right
    LCTRL_Up
    LCTRL_Down

    RCTRL_HOME
    RCTRL_END

    RCTRL_INS
    RCTRL_DEL

    RCTRL_PGUP
    RCTRL_PGDN

    RCTRL_Left
    RCTRL_Right
    RCTRL_Up
    RCTRL_Down

    LSHIFT_LCTRL_HOME
    LSHIFT_LCTRL_END

    LSHIFT_LCTRL_INS
    LSHIFT_LCTRL_DEL

    LSHIFT_LCTRL_PGUP
    LSHIFT_LCTRL_PGDN

    LSHIFT_LCTRL_Left
    LSHIFT_LCTRL_Right
    LSHIFT_LCTRL_Up
    LSHIFT_LCTRL_Down

    LSHIFT_BackSpace
    LSHIFT_TAB
    LSHIFT_SPACE
    LSHIFT_ESC
    LSHIFT_ENTER

    RSHIFT_BackSpace
    RSHIFT_TAB
    RSHIFT_SPACE
    RSHIFT_ESC
    RSHIFT_ENTER

    LCTRL_SPACE
    LCTRL_ENTER

    RCTRL_SPACE
    RCTRL_ENTER

Code: QB64: [Select]
  1. ' Masakari.bas (DragDropWheelScroller.bas)
  2. ' written in QB64 v1.4 by Kaze, 2021-Jan-24
  3. ' Thanks go to the www.qb64.org/forum members for sharing useful excerpts/etudes
  4. ' Wow, this is nice indeed: http://www.qb64.org/wiki/Windows_Libraries
  5.  
  6. ' Currently are implemented only:
  7. ' Mouse:
  8. '       Button 1 - sets the cursor and the inverse line to the chosen position
  9. '       Button 3 - PgDn
  10. '       Wheel Up - Up
  11. '       Wheel Dn - Dn
  12. ' Keyboard:
  13. '        Up
  14. '        Down
  15. '        Left - still no sideways scroll
  16. '        Right - still no sideways scroll
  17. '        LCtrl+Home - going to the top left position
  18. '        LCtrl+End  - going to the bottom left position
  19. '        Alt+x or Alt+q - quit to the system, without demanding keypress.
  20.  
  21. _TITLE "MASAKARI 128x60, The 'Holy Axe' English Text Sidekick"
  22. $EXEICON:'ColumnChart.ico'
  23. CONST RSHIFTkey& = 100303
  24. CONST LSHIFTkey& = 100304
  25. CONST RCTRLkey& = 100305
  26. CONST LCTRLkey& = 100306
  27. CONST RALTkey& = 100307
  28. CONST LALTkey& = 100308
  29.  
  30. CONST BACKSPCkey& = 8
  31. CONST TABkey& = 9
  32. CONST SPACEkey& = 32
  33. CONST ESCkey& = 27
  34. CONST ENTERkey& = 13
  35.  
  36. CONST HOMEkey& = 18176
  37. CONST ENDkey& = 20224
  38.  
  39. CONST INSkey& = 20992
  40. CONST DELkey& = 21248
  41.  
  42. CONST PGUPkey& = 18688
  43. CONST PGDNkey& = 20736
  44.  
  45. CONST LEFTkey& = 19200
  46. CONST RIGHTkey& = 19712
  47. CONST UPkey& = 18432
  48. CONST DOWNkey& = 20480
  49.  
  50.     $CONSOLE
  51.     _CONSOLE ON
  52.     _CONSOLETITLE "Masakari console window"
  53.     PRINT "Masakari, revision 2, written in QB64 by Kaze"
  54.     PRINT "Usage: Masakari filename|/help"
  55.     SYSTEM
  56.     '_CONSOLE OFF
  57.     '_SCREENSHOW
  58.     $CONSOLE
  59.  
  60. 'DEFLNG A-Z
  61. '_DEFINE A-Z AS _UNSIGNED _INTEGER64
  62.  
  63. $IF WINDOWS THEN
  64.     DECLARE LIBRARY "mem"
  65.         FUNCTION MemInUsePercent~&&
  66.         FUNCTION TotalPhysicalMem~&&
  67.         FUNCTION FreePhysicalMem~&&
  68.         FUNCTION TotalPagingFile~&&
  69.         FUNCTION FreePagingFile~&&
  70.         FUNCTION TotalVirtualMem~&&
  71.         FUNCTION FreeVirtualMem~&&
  72.         FUNCTION FreeExtendedMem~&&
  73.         FUNCTION GetCPULoad#
  74.     END DECLARE
  75.  
  76. XdimCOL = 128
  77. YdimROW = 44 ' ensure old laptops with 768pixels vertical will hold the whole window
  78. IF high& > 1000 THEN YdimROW = 60
  79. handle& = _NEWIMAGE(XdimCOL, YdimROW + 1, 0)
  80. SCREEN handle&
  81. _DEST handle&
  82.  
  83. ' _DEST 0 refers to the present program SCREEN. You can use 0 to refer to the present program
  84. '  SCREEN.
  85.  
  86. '_FONT 16 'wish we could use the old 8x16 bitmap/raster fonts from DOS times...
  87.  
  88. ' Either one must be uncommented:
  89. '_AUTODISPLAY 'no need of refreshing
  90.  
  91. TimeA = TIMER
  92.  
  93. PurpleFlag = 0
  94. 'PurpleFlag = 1
  95.  
  96. NormalFRGr = 3
  97. IF PurpleFlag THEN NormalFRGr = 9
  98. NormalBCKGr = 0
  99. IF PurpleFlag THEN NormalBCKGr = 0
  100.  
  101. InverseFRGr = 0
  102. IF PurpleFlag THEN InverseFRGr = 8
  103. InverseBCKGr = 3
  104. IF PurpleFlag THEN InverseBCKGr = 0
  105.  
  106. COLOR NormalFRGr, NormalBCKGr
  107.  
  108. PRINT "Current working directory path: "; CHR$(34); _CWD$; CHR$(34)
  109. PRINT "User's program calling path: "; CHR$(34); _STARTDIR$; CHR$(34)
  110. PRINT "Command line parameters sent when a program is started: "; CHR$(34); COMMAND$; CHR$(34)
  111. PRINT "_OS$="; _OS$
  112.  
  113. 'Y = CSRLIN 'save the row
  114. 'X = POS(0) 'save the column
  115.  
  116. REDIM FileArray$(1) 'create dynamic array: 3880000 alocates 532MB - bigger values need 570+MB and give "Out Of Memory"
  117. DIM FileArrayWINDOW$(YdimROW)
  118.  
  119. $IF WINDOWS THEN
  120.     _ACCEPTFILEDROP 'enables drag/drop functionality
  121.     IF COMMAND$ = "" THEN PRINT: PRINT "Drag files from a folder and drop them in this window...": PRINT
  122.  
  123. 'pressakey$ = INPUT$(1)
  124.  
  125. a$ = ""
  126. PostfixedToHeader = CSRLIN
  127.  
  128.     LOCATE PostfixedToHeader, 1
  129.  
  130.     $IF WINDOWS THEN
  131.         ' MEMUSAGE by Steve [
  132.         ' GetCPULoad = 0 is idle, 1 is fully used.
  133.         '  Multiply by 100 for a percentage
  134.         PRINT "CPU used:              "; LTRIM$(STR$(INT((GetCPULoad * 10000) / 100))); "%"; SPACE$(18)
  135.         PRINT "Memory used:           "; LTRIM$(STR$(MemInUsePercent)); "%"; SPACE$(18)
  136.         PRINT "Total Physical Memory: ";
  137.         PRINT AddCommas$(TotalPhysicalMem); " bytes"; SPACE$(18)
  138.         PRINT "Free Physical Memory:  ";
  139.         PRINT AddCommas$(FreePhysicalMem); " bytes"; SPACE$(18)
  140.         PRINT "Total Paging File:     ";
  141.         PRINT AddCommas$(TotalPagingFile); " bytes"; SPACE$(18)
  142.         PRINT "Free Paging File:      ";
  143.         PRINT AddCommas$(FreePagingFile); " bytes"; SPACE$(18)
  144.         PRINT "Total Virtual Memory:  ";
  145.         PRINT AddCommas$(TotalVirtualMem); " bytes"; SPACE$(18)
  146.         PRINT "Free Virtual Memory:   ";
  147.         PRINT AddCommas$(FreeVirtualMem); " bytes"; SPACE$(18)
  148.         'PRINT "Free Extended Virtual Memory:"
  149.         'PRINT "  "; FreeExtendedMeml; " bytes"
  150.         ' MEMUSAGE by Steve ]
  151.     $END IF
  152.  
  153.     IF COMMAND$ = "" THEN PRINT: PRINT "May press Alt+X or Alt+Q to eXit/Quit..."
  154.     ReturnCOMBO
  155.     _DISPLAY
  156.  
  157.     $IF WINDOWS THEN
  158.             'FOR i = 1 TO _TOTALDROPPEDFILES
  159.             'a$ = _DROPPEDFILE(i)
  160.             a$ = _DROPPEDFILE(1)
  161.             'NEXT'
  162.             _FINISHDROP 'If _FINISHDROP isn't called here then _TOTALDROPPEDFILES never gets reset.
  163.             'ELSE
  164.             'a$ = "Scroller.$$$"
  165.             'SHELL _HIDE "DIR /B *.* > Scroller.$$$"
  166.         END IF
  167.     $END IF
  168.     IF COMMAND$ <> "" THEN a$ = COMMAND$
  169.  
  170.     'WrapFlag = 0
  171.     'Wwidth% = XdimCOL
  172.     'ul& = 0
  173.     'LongestLine = 0
  174.     'DO WHILE NOT EOF(1)
  175.     '    LINE INPUT #1, l$: ul& = ul& + 1
  176.     '    ExpandTabs l$
  177.     '    IF LEN(l$) > LongestLine THEN LongestLine = LEN(l$)
  178.     '    IF WrapFlag THEN
  179.     '        lX$ = l$
  180.     '        DO WHILE LEN(lX$) > Wwidth%
  181.     '            Glupak% = Wwidth%
  182.     '            DO UNTIL MID$(lX$, Glupak% + 1, 1) = " " AND MID$(lX$, Glupak%, 1) <> " "
  183.     '                Glupak% = Glupak% - 1
  184.     '                IF Glupak% = 0 THEN
  185.     '                    PRINT "Rejecting line(#"; LTRIM$(STR$(ul&)); ", "; LTRIM$(STR$(LEN(l$))); "chars) that cannot be wrapped!"
  186.     '                    _DISPLAY: SYSTEM
  187.     '                    GOTO B4Txpanar
  188.     '                END IF
  189.     '            LOOP
  190.     '            PRINT #3, LEFT$(lX$, Glupak%)
  191.     '            lX$ = STRING$(1, " ") + LTRIM$(MID$(lX$, Glupak% + 1, LEN(lX$) - (Glupak%)))
  192.     '        LOOP
  193.     '        PRINT #3, lX$
  194.     '        B4Txpanar:
  195.     '    END IF
  196.     'LOOP
  197.  
  198.     LongestLine = 0
  199.     IF _FILEEXISTS(a$) THEN
  200.         PRINT: PRINT "Loading..."
  201.         _DISPLAY
  202.         filecount = 0
  203.         OPEN a$ FOR INPUT AS #1
  204.         DO UNTIL EOF(1)
  205.             LINE INPUT #1, l$
  206.             filecount = filecount + 1
  207.         LOOP
  208.         CLOSE #1
  209.         REDIM FileArray$(1 TO filecount)
  210.         filecount = 0
  211.         OPEN a$ FOR INPUT AS #1
  212.         FileSize = LOF(1)
  213.         DO UNTIL EOF(1)
  214.             LINE INPUT #1, l$
  215.             ExpandTabs l$
  216.             FOR j = 1 TO LEN(l$)
  217.                 IF MID$(l$, j, 1) < CHR$(32) THEN MID$(l$, j, 1) = CHR$(32)
  218.             NEXT j
  219.             IF LEN(l$) > LongestLine THEN LongestLine = LEN(l$)
  220.             filecount = filecount + 1
  221.             FileArray$(filecount) = l$
  222.         LOOP
  223.         CLOSE #1
  224.     END IF
  225.     _LIMIT 5
  226.     'IF INKEY$ = CHR$(27) THEN SYSTEM
  227.     'IF keycode& = 27 THEN SYSTEM
  228.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(81) OR _KEYDOWN(113)) THEN SYSTEM
  229.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(88) OR _KEYDOWN(120)) THEN SYSTEM
  230.  
  231.     '                            QB64 _KEYHIT and _KEYDOWN Values
  232.     '
  233.     'Esc  F1    F2    F3    F4    F5    F6    F7    F8    F9    F10   F11   F12   Sys  ScL Pause
  234.     ' 27 15104 15360 15616 15872 16128 16384 16640 16896 17152 17408 34048 34304 +316 +302 +019
  235.     '`~  1!  2@  3#  4$  5%  6^  7&  8*  9(  0) -_ =+ BkSp   Ins   Hme   PUp   NumL   /     *    -
  236.     '126 33  64  35  36  37  94  38  42  40  41 95 43   8   20992 18176 18688 +300   47    42   45
  237.     ' 96 49  50  51  52  53  54  55  56  57  48 45 61
  238.     'Tab Q   W   E   R   T   Y   U   I   O   P  [{  ]}  \|   Del   End   PDn   7Hme  8/?   9PU   +
  239.     ' 9  81  87  69  82  84  89  85  73  79  80 123 125 124 21248 20224 20736 18176 18432 18688 43
  240.     '   113 119 101 114 116 121 117 105 111 112  91  93  92                    55    56    57
  241.     'CapL   A   S   D   F   G   H   J   K   L   ;:  '" Enter                   4/?-   5    6/-?
  242.     '+301   65  83  68  70  71  72  74  75  76  58  34  13                    19200 19456 19712  E
  243.     '       97 115 100 102 103 104 106 107 108  59  39                         52    53    54    n
  244.     'Shift   Z   X   C   V   B   N   M   ,<  .>  /?    Shift       ?           1End  2/?   3PD   t
  245.     '+304   90  88  67  86  66  78  77  60  62  63    +303       18432        20224 20480 20736  e
  246.     '      122 120  99 118  98 110 109  44  46  47                             49    50    51    r
  247.     'Ctrl   Win  Alt     Spacebar      Alt  Win  Menu  Ctrl   ?-   ?   -?      0Ins        .Del
  248.     '+306  +311 +308       32         +307 +312 +319  +305 19200 20480 19712  20992       21248 13
  249.     '                                                                          48          46
  250.     '         Lower value = LCase/NumLock On __________________ + = add 100000
  251.  
  252. LOOP WHILE a$ = ""
  253.  
  254. TimeB = TIMER
  255. PLAY "L8V2a-c-"
  256. CurrentLine = 1
  257. FOR i = 1 TO YdimROW
  258.     LOCATE i, 1: PRINT SPACE$(XdimCOL);
  259. FOR i = 1 TO MIN&(YdimROW, filecount)
  260.     IF LEN(FileArray$(i)) >= XdimCOL THEN
  261.         FileArrayWINDOW$(i) = MID$(FileArray$(i), 1, XdimCOL)
  262.     ELSE
  263.         FileArrayWINDOW$(i) = FileArray$(i) + SPACE$(XdimCOL - LEN(FileArray$(i)))
  264.     END IF
  265.     LOCATE i, 1: PRINT FileArrayWINDOW$(i);
  266.  
  267. ' Here is the layout:
  268. ' The window-frame is 1..crx or 1..128 |  The file-frame is 1..LongestLine
  269. '                     .         .      |                    .
  270. '                     .         .      |                    .
  271. '                     cry       60     |                    filecount
  272. '              FileArrayWINDOW$(60)    |          FileArray(filecount)
  273. ' if File_Frame_x < 128 then PADDING to 128 else File_Frame_x = 1..LongestLine-(128-1)
  274. ' if File_Frame_y < 60 then PADDING to 60 else File_Frame_y = 1..filecount-(60-1)
  275.  
  276. UpdateCLine 1, 1, InverseFRGr, InverseBCKGr, 1
  277. StatuLine$ = SPACE$(XdimCOL)
  278. MID$(StatuLine$, 1, 1) = "["
  279. MID$(StatuLine$, XdimCOL, 1) = "]"
  280.  
  281. Dumbo$ = "File Size: " + AddCommas$(FileSize) + "; Longest Line: " + AddCommas$(LongestLine) + "; Total Lines: " + AddCommas$(filecount)
  282. MID$(StatuLine$, 2, LEN(Dumbo$)) = Dumbo$
  283. LOCATE YdimROW + 1, 1: COLOR 9, 0: PRINT StatuLine$;
  284. UpdateCLL CurrentLine, LEN(Dumbo$) + 1 + 1
  285. CLL_Field = LEN(AddCommas$(LongestLine))
  286. MostRightField = LEN(Dumbo$) + 1 + 1 + (LEN("; Current Line Length: ") + CLL_Field)
  287. UpdateNextToCCL_DONE MostRightField
  288.  
  289. LOCATE 1, 1, 1, 30, 31
  290. crx = POS(0)
  291. cry = CSRLIN
  292. crxOLD = crx
  293. cryOLD = cry
  294. File_Frame_x = 1
  295. File_Frame_y = 1
  296.  
  297.     ReturnCOMBO
  298.     IF LSHIFT_RSHIFT THEN
  299.         PLAY "L4V2f": _KEYCLEAR
  300.         ReportTimeToLoad MostRightField
  301.         _DISPLAY
  302.     END IF
  303.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(81) OR _KEYDOWN(113)) THEN SYSTEM
  304.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(88) OR _KEYDOWN(120)) THEN SYSTEM
  305.     key$ = INKEY$
  306.     'DO: a$ = INKEY$: LOOP UNTIL a$ <> "" ' prevent ASC empty string read error
  307.     IF key$ <> "" THEN
  308.         code% = ASC(key$):
  309.         IF code% THEN ' ASC returns any value greater than 0
  310.             SELECT CASE ASC(key$)
  311.                 CASE 65 TO 97: 'PRINT key$;
  312.                 CASE ASC("a") TO ASC("z"): 'PRINT key$;
  313.                     'CASE 27: COLOR 7, 0: SYSTEM 'END
  314.             END SELECT
  315.         ELSE
  316.             SELECT CASE ASC(key$, 2)
  317.                 CASE 72:
  318.                     IF CurrentLine > 1 THEN CurrentLine = CurrentLine - 1
  319.                     IF cry > 1 THEN
  320.                         cry = cry - 1 'up
  321.                     ELSE 'scrolling is needed
  322.                         IF File_Frame_y > 1 THEN File_Frame_y = File_Frame_y - 1
  323.                         UpdateWindowFrame NormalFRGr, NormalBCKGr
  324.                     END IF
  325.                 CASE 80:
  326.                     IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  327.                     IF cry < YdimROW THEN
  328.                         IF cry < filecount THEN cry = cry + 1 'down
  329.                     ELSE 'scrolling is needed
  330.                         IF File_Frame_y < filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  331.                         UpdateWindowFrame NormalFRGr, NormalBCKGr
  332.                     END IF
  333.                 CASE 75: IF crx > 1 THEN crx = crx - 1 'left
  334.                 CASE 77: IF crx < XdimCOL THEN crx = crx + 1 'right
  335.             END SELECT
  336.         END IF
  337.     END IF
  338.     IF cryOLD <> cry THEN
  339.         UpdateCLine cryOLD, 1, NormalFRGr, NormalBCKGr, cryOLD
  340.         cryOLD = cry
  341.     ELSE 'it 'cry' could be changed by Mouse Wheel too, check it
  342.         AsIfItIsINKEY% = _MOUSEINPUT '      Check the mouse status
  343.         IF _MOUSEWHEEL = 1 THEN ' as if Down
  344.             IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  345.             IF cry < YdimROW THEN
  346.                 IF cry < filecount THEN cry = cry + 1 'down
  347.             ELSE 'scrolling is needed
  348.                 IF File_Frame_y < filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  349.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  350.             END IF
  351.         END IF
  352.         IF _MOUSEWHEEL = -1 THEN ' as if Up
  353.             IF CurrentLine > 1 THEN CurrentLine = CurrentLine - 1
  354.             IF cry > 1 THEN
  355.                 cry = cry - 1 'up
  356.             ELSE 'scrolling is needed
  357.                 IF File_Frame_y > 1 THEN File_Frame_y = File_Frame_y - 1
  358.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  359.             END IF
  360.         END IF
  361.         IF _MOUSEBUTTON(1) THEN
  362.             crxOLD = crx
  363.             cryOLD = cry
  364.             cry = _MOUSEY
  365.             crx = _MOUSEX
  366.             UpdateCLine cryOLD, 1, NormalFRGr, NormalBCKGr, cryOLD
  367.             DO WHILE cryOLD > cry
  368.                 cryOLD = cryOLD - 1
  369.                 IF CurrentLine > 1 THEN CurrentLine = CurrentLine - 1
  370.             LOOP
  371.             DO WHILE cryOLD < cry
  372.                 cryOLD = cryOLD + 1
  373.                 IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  374.             LOOP
  375.         END IF
  376.         IF _MOUSEBUTTON(3) THEN 'PgDn - just add the page height i.e. 'YdimROW' to 'File_Frame_y'
  377.             ' Don't execute PgDn (advancing the 'CurrentLine') if 'File_Frame_y' is not "eligible":
  378.             'IF File_Frame_y < filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  379.             'IF File_Frame_y + 1 <= filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  380.             'CAUTION [
  381.             ' Next three line beep NOT
  382.             'DEFLNG A-Z
  383.             'aaa = 61
  384.             'bbb = -48
  385.             'IF aaa <= bbb THEN BEEP: END
  386.             'Next three line beep
  387.             'aaa~& = 61
  388.             'bbb~& = -48
  389.             'IF aaa~& <= bbb~& THEN BEEP: END
  390.             'Next three line beep NOT
  391.             'aaa& = 61
  392.             'bbb& = -48
  393.             'IF aaa& <= bbb& THEN BEEP: END
  394.             'Next line works even when unsigned!
  395.             'IF File_Frame_y + YdimROW - (filecount - (YdimROW - 1)) <= 0 THEN
  396.             'CAUTION ]
  397.             'Next line doesn't work when unsigned!
  398.             IF File_Frame_y + YdimROW <= filecount - (YdimROW - 1) THEN
  399.                 File_Frame_y = File_Frame_y + YdimROW
  400.                 'IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  401.                 'IF CurrentLine + 1 <= filecount THEN CurrentLine = CurrentLine + 1
  402.                 IF CurrentLine + YdimROW <= filecount THEN CurrentLine = CurrentLine + YdimROW
  403.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  404.             END IF
  405.         END IF
  406.     END IF
  407.     IF cryOLD <> cry THEN
  408.         UpdateCLine cryOLD, 1, NormalFRGr, NormalBCKGr, cryOLD
  409.         cryOLD = cry
  410.     END IF
  411.     IF LCTRL_HOME THEN
  412.         LOCATE 1, 1, 1, 30, 31
  413.         crx = POS(0)
  414.         cry = CSRLIN
  415.         crxOLD = crx
  416.         cryOLD = cry
  417.         File_Frame_x = 1
  418.         File_Frame_y = 1
  419.         CurrentLine = 1
  420.         UpdateWindowFrame NormalFRGr, NormalBCKGr
  421.     END IF
  422.     IF LCTRL_END THEN
  423.         IF filecount >= YdimROW THEN
  424.             IF filecount - (YdimROW - 1) THEN
  425.                 LOCATE YdimROW, 1, 1, 30, 31
  426.                 crx = POS(0)
  427.                 cry = CSRLIN
  428.                 crxOLD = crx
  429.                 cryOLD = cry
  430.                 File_Frame_x = 1
  431.                 File_Frame_y = filecount - (YdimROW - 1)
  432.                 CurrentLine = filecount
  433.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  434.             END IF
  435.         ELSE
  436.             LOCATE filecount, 1, 1, 30, 31
  437.             crx = POS(0)
  438.             cry = CSRLIN
  439.             crxOLD = crx
  440.             cryOLD = cry
  441.             File_Frame_x = 1
  442.             File_Frame_y = 1
  443.             CurrentLine = filecount
  444.             UpdateWindowFrame NormalFRGr, NormalBCKGr
  445.         END IF
  446.     END IF
  447.  
  448.     LOCATE cry, crx, 1, 30, 31
  449.     UpdateCLine cry, 1, InverseFRGr, InverseBCKGr, cry
  450.     UpdateCLL CurrentLine, LEN(Dumbo$) + 1 + 1
  451.     _DISPLAY
  452.     'DO WHILE INKEY$ <> "": LOOP ' have to clear the keyboard buffer
  453.     _LIMIT 500 '_LIMIT 30 'commented because the wheel up/down was not working?!
  454.  
  455.  
  456. SUB ReturnCOMBO
  457.     SHARED LSHIFT_RSHIFT
  458.     SHARED LCTRL_RCTRL
  459.     SHARED LALT_RALT
  460.  
  461.     SHARED LALT_HOME
  462.     SHARED LALT_END
  463.  
  464.     SHARED LALT_INS
  465.     SHARED LALT_DEL
  466.  
  467.     SHARED LALT_PGUP
  468.     SHARED LALT_PGDN
  469.  
  470.     SHARED LALT_Left
  471.     SHARED LALT_Right
  472.     SHARED LALT_Up
  473.     SHARED LALT_Down
  474.  
  475.     SHARED RALT_HOME
  476.     SHARED RALT_END
  477.  
  478.     SHARED RALT_INS
  479.     SHARED RALT_DEL
  480.  
  481.     SHARED RALT_PGUP
  482.     SHARED RALT_PGDN
  483.  
  484.     SHARED RALT_Left
  485.     SHARED RALT_Right
  486.     SHARED RALT_Up
  487.     SHARED RALT_Down
  488.  
  489.     SHARED LSHIFT_HOME
  490.     SHARED LSHIFT_END
  491.  
  492.     SHARED LSHIFT_INS
  493.     SHARED LSHIFT_DEL
  494.  
  495.     SHARED LSHIFT_PGUP
  496.     SHARED LSHIFT_PGDN
  497.  
  498.     SHARED LSHIFT_Left
  499.     SHARED LSHIFT_Right
  500.     SHARED LSHIFT_Up
  501.     SHARED LSHIFT_Down
  502.  
  503.     SHARED RSHIFT_HOME
  504.     SHARED RSHIFT_END
  505.  
  506.     SHARED RSHIFT_INS
  507.     SHARED RSHIFT_DEL
  508.  
  509.     SHARED RSHIFT_PGUP
  510.     SHARED RSHIFT_PGDN
  511.  
  512.     SHARED RSHIFT_Left
  513.     SHARED RSHIFT_Right
  514.     SHARED RSHIFT_Up
  515.     SHARED RSHIFT_Down
  516.  
  517.     SHARED LCTRL_HOME
  518.     SHARED LCTRL_END
  519.  
  520.     SHARED LCTRL_INS
  521.     SHARED LCTRL_DEL
  522.  
  523.     SHARED LCTRL_PGUP
  524.     SHARED LCTRL_PGDN
  525.  
  526.     SHARED LCTRL_Left
  527.     SHARED LCTRL_Right
  528.     SHARED LCTRL_Up
  529.     SHARED LCTRL_Down
  530.  
  531.     SHARED RCTRL_HOME
  532.     SHARED RCTRL_END
  533.  
  534.     SHARED RCTRL_INS
  535.     SHARED RCTRL_DEL
  536.  
  537.     SHARED RCTRL_PGUP
  538.     SHARED RCTRL_PGDN
  539.  
  540.     SHARED RCTRL_Left
  541.     SHARED RCTRL_Right
  542.     SHARED RCTRL_Up
  543.     SHARED RCTRL_Down
  544.  
  545.     SHARED LSHIFT_LCTRL_HOME
  546.     SHARED LSHIFT_LCTRL_END
  547.  
  548.     SHARED LSHIFT_LCTRL_INS
  549.     SHARED LSHIFT_LCTRL_DEL
  550.  
  551.     SHARED LSHIFT_LCTRL_PGUP
  552.     SHARED LSHIFT_LCTRL_PGDN
  553.  
  554.     SHARED LSHIFT_LCTRL_Left
  555.     SHARED LSHIFT_LCTRL_Right
  556.     SHARED LSHIFT_LCTRL_Up
  557.     SHARED LSHIFT_LCTRL_Down
  558.  
  559.     SHARED LSHIFT_BackSpace
  560.     SHARED LSHIFT_TAB
  561.     SHARED LSHIFT_SPACE
  562.     SHARED LSHIFT_ESC
  563.     SHARED LSHIFT_ENTER
  564.  
  565.     SHARED RSHIFT_BackSpace
  566.     SHARED RSHIFT_TAB
  567.     SHARED RSHIFT_SPACE
  568.     SHARED RSHIFT_ESC
  569.     SHARED RSHIFT_ENTER
  570.  
  571.     SHARED LCTRL_SPACE
  572.     SHARED LCTRL_ENTER
  573.  
  574.     SHARED RCTRL_SPACE
  575.     SHARED RCTRL_ENTER
  576.  
  577.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(RSHIFTkey&) THEN LSHIFT_RSHIFT = 1 ELSE LSHIFT_RSHIFT = 0
  578.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(RCTRLkey&) THEN LCTRL_RCTRL = 1 ELSE LCTRL_RCTRL = 0
  579.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(RALTkey&) THEN LALT_RALT = 1 ELSE LALT_RALT = 0
  580.  
  581.     'LALT:
  582.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(HOMEkey&) THEN LALT_HOME = 1 ELSE LALT_HOME = 0
  583.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(ENDkey&) THEN LALT_END = 1 ELSE LALT_END = 0
  584.  
  585.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(INSkey&) THEN LALT_INS = 1 ELSE LALT_INS = 0
  586.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(DELkey&) THEN LALT_DEL = 1 ELSE LALT_DEL = 0
  587.  
  588.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(PGUPkey&) THEN LALT_PGUP = 1 ELSE LALT_PGUP = 0
  589.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(PGDNkey&) THEN LALT_PGDN = 1 ELSE LALT_PGDN = 0
  590.  
  591.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(LEFTkey&) THEN LALT_Left = 1 ELSE LALT_Left = 0
  592.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(RIGHTkey&) THEN LALT_Right = 1 ELSE LALT_Right = 0
  593.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(UPkey&) THEN LALT_Up = 1 ELSE LALT_Up = 0
  594.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(DOWNkey&) THEN LALT_Down = 1 ELSE LALT_Down = 0
  595.  
  596.     'RALT:
  597.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(HOMEkey&) THEN RALT_HOME = 1 ELSE RALT_HOME = 0
  598.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(ENDkey&) THEN RALT_END = 1 ELSE RALT_END = 0
  599.  
  600.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(INSkey&) THEN RALT_INS = 1 ELSE RALT_INS = 0
  601.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(DELkey&) THEN RALT_DEL = 1 ELSE RALT_DEL = 0
  602.  
  603.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(PGUPkey&) THEN RALT_PGUP = 1 ELSE RALT_PGUP = 0
  604.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(PGDNkey&) THEN RALT_PGDN = 1 ELSE RALT_PGDN = 0
  605.  
  606.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(LEFTkey&) THEN PRINT RALT_Left = 1 ELSE RALT_Left = 0
  607.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(RIGHTkey&) THEN RALT_Right = 1 ELSE RALT_Right = 0
  608.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(UPkey&) THEN RALT_Up = 1 ELSE RALT_Up = 0
  609.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(DOWNkey&) THEN RALT_Down = 1 ELSE RALT_Down = 0
  610.  
  611.     'LSHIFT:
  612.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(HOMEkey&) THEN LSHIFT_HOME = 1 ELSE LSHIFT_HOME = 0
  613.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(ENDkey&) THEN LSHIFT_END = 1 ELSE LSHIFT_END = 0
  614.  
  615.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(INSkey&) THEN LSHIFT_INS = 1 ELSE LSHIFT_INS = 0
  616.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(DELkey&) THEN LSHIFT_DEL = 1 ELSE LSHIFT_DEL = 0
  617.  
  618.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(PGUPkey&) THEN LSHIFT_PGUP = 1 ELSE LSHIFT_PGUP = 0
  619.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(PGDNkey&) THEN LSHIFT_PGDN = 1 ELSE LSHIFT_PGDN = 0
  620.  
  621.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LEFTkey&) THEN LSHIFT_Left = 1 ELSE LSHIFT_Left = 0
  622.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(RIGHTkey&) THEN LSHIFT_Right = 1 ELSE LSHIFT_Right = 0
  623.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(UPkey&) THEN LSHIFT_Up = 1 ELSE LSHIFT_Up = 0
  624.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(DOWNkey&) THEN LSHIFT_Down = 1 ELSE LSHIFT_Down = 0
  625.  
  626.     'RSHIFT:
  627.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(HOMEkey&) THEN RSHIFT_HOME = 1 ELSE RSHIFT_HOME = 0
  628.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(ENDkey&) THEN RSHIFT_END = 1 ELSE RSHIFT_END = 0
  629.  
  630.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(INSkey&) THEN RSHIFT_INS = 1 ELSE RSHIFT_INS = 0
  631.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(DELkey&) THEN RSHIFT_DEL = 1 ELSE RSHIFT_DEL = 0
  632.  
  633.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(PGUPkey&) THEN RSHIFT_PGUP = 1 ELSE RSHIFT_PGUP = 0
  634.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(PGDNkey&) THEN RSHIFT_PGDN = 1 ELSE RSHIFT_PGDN = 0
  635.  
  636.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(LEFTkey&) THEN RSHIFT_Left = 1 ELSE RSHIFT_Left = 0
  637.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(RIGHTkey&) THEN RSHIFT_Right = 1 ELSE RSHIFT_Right = 0
  638.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(UPkey&) THEN RSHIFT_Up = 1 ELSE RSHIFT_Up = 0
  639.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(DOWNkey&) THEN RSHIFT_Down = 1 ELSE RSHIFT_Down = 0
  640.  
  641.     'LCTRL:
  642.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(HOMEkey&) THEN LCTRL_HOME = 1 ELSE LCTRL_HOME = 0
  643.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(ENDkey&) THEN LCTRL_END = 1 ELSE LCTRL_END = 0
  644.  
  645.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(INSkey&) THEN LCTRL_INS = 1 ELSE LCTRL_INS = 0
  646.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DELkey&) THEN LCTRL_DEL = 1 ELSE LCTRL_DEL = 0
  647.  
  648.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGUPkey&) THEN LCTRL_PGUP = 1 ELSE LCTRL_PGUP = 0
  649.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGDNkey&) THEN LCTRL_PGDN = 1 ELSE LCTRL_PGDN = 0
  650.  
  651.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(LEFTkey&) THEN LCTRL_Left = 1 ELSE LCTRL_Left = 0
  652.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(RIGHTkey&) THEN LCTRL_Right = 1 ELSE LCTRL_Right = 0
  653.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(UPkey&) THEN LCTRL_Up = 1 ELSE LCTRL_Up = 0
  654.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DOWNkey&) THEN LCTRL_Down = 1 ELSE LCTRL_Down = 0
  655.  
  656.     'RCTRL:
  657.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(HOMEkey&) THEN RCTRL_HOME = 1 ELSE RCTRL_HOME = 0
  658.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(ENDkey&) THEN RCTRL_END = 1 ELSE RCTRL_END = 0
  659.  
  660.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(INSkey&) THEN RCTRL_INS = 1 ELSE RCTRL_INS = 0
  661.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(DELkey&) THEN RCTRL_DEL = 1 ELSE RCTRL_DEL = 0
  662.  
  663.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(PGUPkey&) THEN RCTRL_PGUP = 1 ELSE RCTRL_PGUP = 0
  664.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(PGDNkey&) THEN RCTRL_PGDN = 1 ELSE RCTRL_PGDN = 0
  665.  
  666.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(LEFTkey&) THEN RCTRL_Left = 1 ELSE RCTRL_Left = 0
  667.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(RIGHTkey&) THEN RCTRL_Right = 1 ELSE RCTRL_Right = 0
  668.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(UPkey&) THEN RCTRL_Up = 1 ELSE RCTRL_Up = 0
  669.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(DOWNkey&) THEN RCTRL_Down = 1 ELSE RCTRL_Down = 0
  670.  
  671.     'LSHIFT+LCTRL: NOTICE: LSHIFT+LCTRL+Left triggers 3 variables on - 1] LSHIFT_LCTRL_Left 2] LSHIFT_Left 3] LCTRL_Left
  672.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(HOMEkey&) THEN LSHIFT_LCTRL_HOME = 1 ELSE LSHIFT_LCTRL_HOME = 0
  673.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(ENDkey&) THEN LSHIFT_LCTRL_END = 1 ELSE LSHIFT_LCTRL_END = 0
  674.  
  675.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(INSkey&) THEN LSHIFT_LCTRL_INS = 1 ELSE LSHIFT_LCTRL_INS = 0
  676.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DELkey&) THEN LSHIFT_LCTRL_DEL = 1 ELSE LSHIFT_LCTRL_DEL = 0
  677.  
  678.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGUPkey&) THEN LSHIFT_LCTRL_PGUP = 1 ELSE LSHIFT_LCTRL_PGUP = 0
  679.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGDNkey&) THEN LSHIFT_LCTRL_PGDN = 1 ELSE LSHIFT_LCTRL_PGDN = 0
  680.  
  681.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(LEFTkey&) THEN LSHIFT_LCTRL_Left = 1 ELSE LSHIFT_LCTRL_Left = 0
  682.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(RIGHTkey&) THEN LSHIFT_LCTRL_Right = 1 ELSE LSHIFT_LCTRL_Right = 0
  683.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(UPkey&) THEN LSHIFT_LCTRL_Up = 1 ELSE LSHIFT_LCTRL_Up = 0
  684.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DOWNkey&) THEN LSHIFT_LCTRL_Down = 1 ELSE LSHIFT_LCTRL_Down = 0
  685.  
  686.     'LSHIFT:
  687.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(BACKSPCkey&) THEN LSHIFT_BackSpace = 1 ELSE LSHIFT_BackSpace = 0
  688.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(TABkey&) THEN LSHIFT_TAB = 1 ELSE LSHIFT_TAB = 0
  689.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(SPACEkey&) THEN LSHIFT_SPACE = 1 ELSE LSHIFT_SPACE = 0
  690.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(ESCkey&) THEN LSHIFT_ESC = 1 ELSE LSHIFT_ESC = 0
  691.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(ENTERkey&) THEN LSHIFT_ENTER = 1 ELSE LSHIFT_ENTER = 0
  692.     'RSHIFT:
  693.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(BACKSPCkey&) THEN RSHIFT_BackSpace = 1 ELSE RSHIFT_BackSpace = 0
  694.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(TABkey&) THEN RSHIFT_TAB = 1 ELSE RSHIFT_TAB = 0
  695.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(SPACEkey&) THEN RSHIFT_SPACE = 1 ELSE RSHIFT_SPACE = 0
  696.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(ESCkey&) THEN RSHIFT_ESC = 1 ELSE RSHIFT_ESC = 0
  697.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(ENTERkey&) THEN RSHIFT_ENTER = 1 ELSE RSHIFT_ENTER = 0
  698.  
  699.     'LCTRL:
  700.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(SPACEkey&) THEN LCTRL_SPACE = 1 ELSE LCTRL_SPACE = 0
  701.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(ENTERkey&) THEN LCTRL_ENTER = 1 ELSE LCTRL_ENTER = 0
  702.     'RCTRL:
  703.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(SPACEkey&) THEN RCTRL_SPACE = 1 ELSE RCTRL_SPACE = 0
  704.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(ENTERkey&) THEN RCTRL_ENTER = 1 ELSE RCTRL_ENTER = 0
  705.  
  706.     '_KEYCLEAR
  707.  
  708. SUB ExpandTabs (l$)
  709.     IF INSTR(l$, CHR$(9)) THEN
  710.         TabV% = 8
  711.         b$ = "": f& = 0
  712.         FOR i& = 1 TO LEN(l$)
  713.             IF MID$(l$, i&, 1) = CHR$(9) THEN
  714.                 b$ = b$ + STRING$((f& \ TabV%) * TabV% + TabV% - f&, " ")
  715.                 '  |
  716.                 '  |
  717.                 ' \|/
  718.                 'TabV% - (f% - (f% \ TabV%) * TabV%) =
  719.                 'TabV% - (f% MOD TabV%)
  720.                 f& = (f& \ TabV%) * TabV% + TabV%
  721.             ELSE
  722.                 b$ = b$ + MID$(l$, i&, 1)
  723.                 f& = f& + 1
  724.             END IF
  725.         NEXT
  726.         l$ = b$
  727.     END IF
  728.  
  729. FUNCTION MIN& (YdimROW, filecount)
  730.     IF YdimROW < filecount THEN MIN& = YdimROW ELSE MIN& = filecount
  731.  
  732. FUNCTION AddCommas$ (numeral)
  733.     s$ = LTRIM$(STR$(numeral))
  734.     IF LEN(s$) > 3 THEN
  735.         IF (LEN(s$) MOD 3) THEN x$ = STRING$(3 - (LEN(s$) MOD 3), " ") + s$ ELSE x$ = s$
  736.         s$ = ""
  737.         FOR i = 1 TO LEN(x$) STEP 3
  738.             s$ = s$ + MID$(x$, i, 3) + ","
  739.         NEXT
  740.         s$ = LEFT$(s$, LEN(s$) - 1)
  741.     END IF
  742.     AddCommas$ = LTRIM$(s$)
  743.  
  744. SUB UpdateCLL (l, posit)
  745.     SHARED CLL_Field
  746.     SHARED YdimROW, FileArray$()
  747.     crx = POS(0)
  748.     cry = CSRLIN
  749.     q$ = AddCommas$(LEN(FileArray$(l)))
  750.     LOCATE YdimROW + 1, posit: COLOR 9, 0: PRINT "; Current Line Length: " + q$ + STRING$(CLL_Field - LEN(q$), " ");
  751.     LOCATE cry, crx, 1, 30, 31
  752.  
  753. SUB UpdateNextToCCL_BUSY (posit)
  754.     SHARED YdimROW
  755.     crx = POS(0)
  756.     cry = CSRLIN
  757.     LOCATE YdimROW + 1, posit: COLOR 9, 0: PRINT "; Status: BUSY";
  758.     LOCATE cry, crx, 1, 30, 31
  759.  
  760. SUB UpdateNextToCCL_DONE (posit)
  761.     SHARED YdimROW
  762.     crx = POS(0)
  763.     cry = CSRLIN
  764.     LOCATE YdimROW + 1, posit: COLOR 9, 0: PRINT "; Status: DONE";
  765.     LOCATE cry, crx, 1, 30, 31
  766.  
  767. SUB UpdateCLine (lineToWrite, columnToWrite, FRGR, BACKGR, ln)
  768.     SHARED FileArrayWINDOW$()
  769.     crx = POS(0)
  770.     cry = CSRLIN
  771.     COLOR FRGR, BACKGR
  772.     LOCATE lineToWrite, columnToWrite, 1, 30, 31
  773.     PRINT FileArrayWINDOW$(ln);
  774.     LOCATE cry, crx, 1, 30, 31
  775.  
  776. SUB UpdateWindowFrame (FRGR, BACKGR)
  777.     SHARED YdimROW, filecount, FileArray$(), File_Frame_y, XdimCOL, FileArrayWINDOW$()
  778.     COLOR FRGR, BACKGR
  779.     FOR i = 1 TO MIN&(YdimROW, filecount)
  780.         IF LEN(FileArray$(i + (File_Frame_y - 1))) >= XdimCOL THEN
  781.             FileArrayWINDOW$(i) = MID$(FileArray$(i + (File_Frame_y - 1)), 1, XdimCOL)
  782.         ELSE
  783.             FileArrayWINDOW$(i) = FileArray$(i + (File_Frame_y - 1)) + SPACE$(XdimCOL - LEN(FileArray$(i + (File_Frame_y - 1))))
  784.         END IF
  785.         LOCATE i, 1: PRINT FileArrayWINDOW$(i);
  786.     NEXT
  787.  
  788. SUB ReportTimeToLoad (posit)
  789.     SHARED YdimROW
  790.     SHARED TimeA, TimeB
  791.     crx = POS(0)
  792.     cry = CSRLIN
  793.     LOCATE YdimROW + 1, posit: COLOR 4, 0: PRINT "; Loaded in"; TimeB - TimeA; " seconds.";
  794.     LOCATE cry, crx, 1, 30, 31
  795.  
« Last Edit: January 24, 2021, 01:24:21 pm by Sanmayce »
He learns not to learn and reverts to what all men pass by.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #18 on: January 24, 2021, 01:24:36 pm »
Change LINE INPUT to work in BINARY mode — it’s tons faster.  Instead of:

OPEN file$ FOR INPUT AS #1

try:

OPEN file$ FOR BINARY AS #1
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #19 on: January 24, 2021, 01:35:51 pm »
Steve is spot on when it comes to using BINARY for speed. Just be sure to keep using your IF _FILEEXISTS condition statement. Unlike OPEN for INPUT, which errors out if the file doesn't exist, Open for BINARY just creates the file. BINARY can also be used to write to the file, but you have to use PUT statements. QB64 added the ability to use LINE INPUT instead of the standard GET statements, so all you have to do is swap out the FOR INPUT to FOR BINARY. Y0u already have the _FILEEXISTS, so you should be good to go.

On a side note, I think I need to move to Bulgaria. Sure, I've only known five, well six people now from that country, but on an intelligence level they are all 10 for 10. Oh don't get me wrong, when it comes to brilliant people, the U.S. is a five-star country too, and one of those stars is half shaded in. Oh, and no comments from the peanut galley that if Pete moves to Bulgaria, then there goes the neighborhood!

Nice coding there Tex,

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Sanmayce

  • Newbie
  • Posts: 63
  • Where is that English Text Sidekick?
    • Sanmayce's home
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #20 on: January 24, 2021, 04:36:38 pm »
 

Thank you @SMcNeill  and @Pete , didn't know that LINE INPUT works in BINARY mode.

Now we know that for OED, "tons faster" is roughly 4.1x or 23,187 seconds / 5,571 seconds, see the screenshot.

The attached revision 2+ now differs only in these two lines:

Code: QB64: [Select]
  1. '        OPEN a$ FOR INPUT AS #1
  2.         OPEN a$ FOR BINARY AS #1 ' As suggested by SMcNeill and Pete in https://www.qb64.org/forum/index.php?topic=3518.msg128631#msg128631
  3. ...
  4. '        OPEN a$ FOR INPUT AS #1
  5.         OPEN a$ FOR BINARY AS #1 ' As suggested by SMcNeill and Pete in https://www.qb64.org/forum/index.php?topic=3518.msg128631#msg128631
  6.  

Steve is spot on when it comes to using BINARY for speed. Just be sure to keep using your IF _FILEEXISTS condition statement. Unlike OPEN for INPUT, which errors out if the file doesn't exist, Open for BINARY just creates the file. BINARY can also be used to write to the file, but you have to use PUT statements. QB64 added the ability to use LINE INPUT instead of the standard GET statements, so all you have to do is swap out the FOR INPUT to FOR BINARY. Y0u already have the _FILEEXISTS, so you should be good to go.

Pete, your wording is as it should, much appreciated, the flow, the explanation, just, Mutsi!
Please both with Steve stick around as I intend in next weeks to add slowly more features helping the user with text stats/windows...
Dummy me, looking in my old archives I saved only files as 3D.ASM drawing the windows with shadows, but lost the .BAS files, have to rewrite from .ASM to .BAS, ugh.

 
Masakari_source_rev2+_on_i5-7200U_5.png


Also, the idea is this tool to work on Linux, remotely my brother did run for me QB64 for Linux, the video shows r.2+ scrolling the 15MB long 'Arabian Nights' file on one old laptop with 1366x768 resolution, notice how the window fits in:



YouTube butchered the scroll after rendering it, so the original .MKV is on my Internet Drive:
https://drive.google.com/file/d/1RvMejR3cb_IWBSr3Jw94c4cIBd8oKa8Y/view?usp=sharing

In the attached r.2+ package, there is MASAKARI_64bit.elf (468,660 bytes) - the *nix executable (static, stripped, compressed with upx).
Latest Fedora 33 was used, very glad that QB64 is *nix friendly.

My cameraman (my brother) did fine job filming it, I am impressed with the quality of capturing, no tearing, no frame dropping, so glad that my Text Sidekick will work on Linux as well.

As for Bulgarians, I beg to differ, most of my countrymen are disgrace to the Bulgarian spirit, and that is to put it mildly. To me, "intelligence" means little, many smartasses are out there, the kind-and-appreciative mindset is what I seek and love in humans.
To me, Bulgaria is a wonderful part of the Earth, however soullessness is rampant here, the soulful people are minority, as everywhere I guess... nah, except Nihon.
He learns not to learn and reverts to what all men pass by.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #21 on: January 24, 2021, 04:56:33 pm »
I'm a bit of both. I have the kind part going, as in I'm kind of a smartass.

Glad you made use of BINARY, but ouch on having to go from ASM to BASIC. I coded a C/C++ WP routine I wrote back into BASIC once. It was just about like rewriting the whole thing, too.

We'll stay in touch,

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
    • Steve’s QB64 Archive Forum
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #22 on: January 24, 2021, 05:55:12 pm »
If you want the absolute fastest way to input a file (and it sounds like you would, with such a large file), read and then parse it.  I’m not at home with my PC until tomorrow, but your basic pseudocode is:

OPEN file$ FOR BINARY AS #1
text$ = SPACE$(LOF(1))
GET #1, 1, text$ ‘read the whole file at once
CLOSE

DO
    parse text$ for CRLF characters (usually CHR$(10) and CHR$(13), in some combination)*
LOOP until all of text$ is parsed

I’ve posted countless examples of this process on the forums before, so a search should find one with a little digging.

Overall time speeds will be quite a bit faster than reading over and over from the drive, but exact improvements depend on drive speed vs memory speed.  (For example, a SSD would see less improvement than a 5200RPM drive)

With extremely large files, I’d definitely suggest the read-and-parse method to load the whole file.



*Windows usually has CHR$(13) + CHR$(10) line endings.  Linux/Newer Mac (above version 9) use CHR$(10).  Legacy Mac (before version 9) use CHR$(13).

I’d check the file for which of those the file contains, and then parse for it as your line delimiter.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #23 on: January 24, 2021, 06:09:35 pm »
Another trick:

Code: [Select]
REDIM FileArray$(1 TO 100000)


    LongestLine = 0
    IF _FILEEXISTS(a$) THEN
        PRINT: PRINT "Loading..."
        _DISPLAY
        filecount = 0
        OPEN a$ FOR BINARY AS #1
        DO UNTIL EOF(1)
            LINE INPUT #1, l$
            filecount = filecount + 1


            IF UBOUND(FileArray$) < filecount THEN REDIM _PRESERVE FileArray$(1 TO UBOUND(FileArray$) + 100000)
            LINE INPUT #1, FileArray$(filecount)
            IF LEN(FileArray$(filecount))) > LongestLine THEN LongestLine = LEN(FileArray$(filecount))

        LOOP
        CLOSE #1
        REDIM FileArray$(1 TO filecount)

You are now reading and assigning your file to your array in a single pass, rather than having to read it once (to count lines), and then read it a second time (to assign it to your array).

Half the disk reads, twice the speed.
« Last Edit: January 26, 2021, 05:32:51 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Sanmayce

  • Newbie
  • Posts: 63
  • Where is that English Text Sidekick?
    • Sanmayce's home
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #24 on: January 26, 2021, 12:46:36 am »
 

In this revision 3+, some changes were made, as:

- removing the flashing window when command line option as "/help" or "-h" are used;
- removing the PLAY statement, it has some dependencies on Linux;
- fixing the path during loading the file, I guess _CWD$ and _STARTDIR$ have to be swapped;

@SMcNeill Thanks, your suggestions got me thinking how to solve the whole "load crisis" in one sweep, didn't have enough time to play with it, in next days I hope will end the crisis by removing usage of strings altogether, I intend to use you malloc-like approach
Code: QB64: [Select]
  1. text$ = SPACE$(LOF(1))

and manually find lines' endings. Also your MACOS comment about CR endings prompted for parsing in a way to handle all the CRLF, LF, CR texts, maybe will replace every LF with CR unless it is paired in CRLF, in that case just skipping it. Thus we would have a modified text file having only CR as a ending.

In order to have tons faster loading, loading in 5000+ seconds should be dropped to 5 seconds, a ton being a thousand, you know. Will deal with this in next days, for now another thing interests me, making the simplistic-and-universal "File Load Menu List", universal, thanks to a tool I wrote (forked from the awesome WATCOM C) many years ago which works exactly the same with Windows and Linux, it is called Yoshi.exe or Youshi.elf, the .C source is also included in the attached to this post package. Basically, it lists all the files in current folder recursively, that is, giving us (optionally with full paths) a list ready to be used in Masakari, thus in next revisions I will make the loading of a file (both on Windows and Linux) the same and a CAKEWALK - just running some script (here m.bat) and scrolling within the filelist, pressing Enter and then loading this file in the very same window. This is my conception for dealing with problems - writing a dedicated module in .C and running it from a GUI, or outside before entering the GUI. In the incoming revisions many problems were solved already in superfast fashion, so Masakari will only invoke them.

 
Masakari_r3+.png


Code: QB64: [Select]
  1. ' Masakari.bas (DragDropWheelScroller.bas)
  2. ' written in QB64 v1.4 by Kaze, 2021-Jan-25
  3. ' Thanks go to the www.qb64.org/forum members for sharing useful excerpts/etudes
  4. ' Wow, this is nice indeed: http://www.qb64.org/wiki/Windows_Libraries
  5.  
  6. ' Currently are implemented only:
  7. ' Mouse:
  8. '       Button 1 - sets the cursor and the inverse line to the chosen position
  9. '       Button 3 - PgDn
  10. '       Wheel Up - Up
  11. '       Wheel Dn - Dn
  12. ' Keyboard:
  13. '        Up
  14. '        Down
  15. '        Left - still no sideways scroll
  16. '        Right - still no sideways scroll
  17. '        LCtrl+Home - going to the top left position
  18. '        LCtrl+End  - going to the bottom left position
  19. '        Alt+x or Alt+q - quit to the system, without demanding keypress.
  20.  
  21. _TITLE "MASAKARI 128x60, The 'Holy Axe' English Text Sidekick"
  22. $EXEICON:'ColumnChart.ico'
  23. CONST RSHIFTkey& = 100303
  24. CONST LSHIFTkey& = 100304
  25. CONST RCTRLkey& = 100305
  26. CONST LCTRLkey& = 100306
  27. CONST RALTkey& = 100307
  28. CONST LALTkey& = 100308
  29.  
  30. CONST BACKSPCkey& = 8
  31. CONST TABkey& = 9
  32. CONST SPACEkey& = 32
  33. CONST ESCkey& = 27
  34. CONST ENTERkey& = 13
  35.  
  36. CONST HOMEkey& = 18176
  37. CONST ENDkey& = 20224
  38.  
  39. CONST INSkey& = 20992
  40. CONST DELkey& = 21248
  41.  
  42. CONST PGUPkey& = 18688
  43. CONST PGDNkey& = 20736
  44.  
  45. CONST LEFTkey& = 19200
  46. CONST RIGHTkey& = 19712
  47. CONST UPkey& = 18432
  48. CONST DOWNkey& = 20480
  49.  
  50.     $CONSOLE
  51.     _CONSOLE ON
  52.     _CONSOLETITLE "Masakari console window"
  53.     PRINT "Masakari, revision 3+, written in QB64 by Kaze"
  54.     $IF WINDOWS THEN
  55.         PRINT "Usage: Masakari filename|/help"
  56.     $ELSE
  57.         PRINT "Usage: Masakari filename|-h"
  58.     $END IF
  59.     SYSTEM
  60.     '_CONSOLE OFF
  61.     '_SCREENSHOW
  62.     _SCREENSHOW ' Why so?!
  63.     $CONSOLE
  64.  
  65. 'DEFLNG A-Z
  66. '_DEFINE A-Z AS _UNSIGNED _INTEGER64
  67.  
  68. $IF WINDOWS THEN
  69.     DECLARE LIBRARY "mem"
  70.         FUNCTION MemInUsePercent~&&
  71.         FUNCTION TotalPhysicalMem~&&
  72.         FUNCTION FreePhysicalMem~&&
  73.         FUNCTION TotalPagingFile~&&
  74.         FUNCTION FreePagingFile~&&
  75.         FUNCTION TotalVirtualMem~&&
  76.         FUNCTION FreeVirtualMem~&&
  77.         FUNCTION FreeExtendedMem~&&
  78.         FUNCTION GetCPULoad#
  79.     END DECLARE
  80.  
  81. XdimCOL = 128
  82. YdimROW = 40 ' ensure old laptops with 768pixels vertical will hold the whole window
  83. IF high& > 1000 THEN YdimROW = 60
  84. handle& = _NEWIMAGE(XdimCOL, YdimROW + 1, 0)
  85. SCREEN handle&
  86. _DEST handle&
  87.  
  88. ' _DEST 0 refers to the present program SCREEN. You can use 0 to refer to the present program
  89. '  SCREEN.
  90.  
  91. '_FONT 16 'wish we could use the old 8x16 bitmap/raster fonts from DOS times...
  92.  
  93. ' Either one must be uncommented:
  94. '_AUTODISPLAY 'no need of refreshing
  95.  
  96. PurpleFlag = 0
  97. 'PurpleFlag = 1
  98.  
  99. NormalFRGr = 3
  100. IF PurpleFlag THEN NormalFRGr = 9
  101. NormalBCKGr = 0
  102. IF PurpleFlag THEN NormalBCKGr = 0
  103.  
  104. InverseFRGr = 0
  105. IF PurpleFlag THEN InverseFRGr = 8
  106. InverseBCKGr = 3
  107. IF PurpleFlag THEN InverseBCKGr = 0
  108.  
  109. COLOR NormalFRGr, NormalBCKGr
  110.  
  111. 'Ugh, they are reversed?!
  112. 'PRINT "Current working directory path: "; CHR$(34); _CWD$; CHR$(34)
  113. 'PRINT "User's program calling path: "; CHR$(34); _STARTDIR$; CHR$(34)
  114. PRINT "Current working directory path: "; CHR$(34); _STARTDIR$; CHR$(34)
  115. PRINT "User's program calling path: "; CHR$(34); _CWD$; CHR$(34)
  116. PRINT "Command line parameters sent when a program is started: "; CHR$(34); COMMAND$; CHR$(34)
  117. PRINT "_OS$="; _OS$
  118.  
  119. 'Y = CSRLIN 'save the row
  120. 'X = POS(0) 'save the column
  121.  
  122. REDIM FileArray$(1) 'create dynamic array: 3880000 alocates 532MB - bigger values need 570+MB and give "Out Of Memory"
  123. DIM FileArrayWINDOW$(YdimROW)
  124.  
  125. $IF WINDOWS THEN
  126.     _ACCEPTFILEDROP 'enables drag/drop functionality
  127.     IF COMMAND$ = "" THEN PRINT: PRINT "Drag files from a folder and drop them in this window...": PRINT
  128.  
  129. 'pressakey$ = INPUT$(1)
  130.  
  131. a$ = ""
  132. PostfixedToHeader = CSRLIN
  133.  
  134.     LOCATE PostfixedToHeader, 1
  135.  
  136.     $IF WINDOWS THEN
  137.         ' MEMUSAGE by Steve [
  138.         ' GetCPULoad = 0 is idle, 1 is fully used.
  139.         '  Multiply by 100 for a percentage
  140.         PRINT "CPU used:              "; LTRIM$(STR$(INT((GetCPULoad * 10000) / 100))); "%"; SPACE$(18)
  141.         PRINT "Memory used:           "; LTRIM$(STR$(MemInUsePercent)); "%"; SPACE$(18)
  142.         PRINT "Total Physical Memory: ";
  143.         PRINT AddCommas$(TotalPhysicalMem); " bytes"; SPACE$(18)
  144.         PRINT "Free Physical Memory:  ";
  145.         PRINT AddCommas$(FreePhysicalMem); " bytes"; SPACE$(18)
  146.         PRINT "Total Paging File:     ";
  147.         PRINT AddCommas$(TotalPagingFile); " bytes"; SPACE$(18)
  148.         PRINT "Free Paging File:      ";
  149.         PRINT AddCommas$(FreePagingFile); " bytes"; SPACE$(18)
  150.         PRINT "Total Virtual Memory:  ";
  151.         PRINT AddCommas$(TotalVirtualMem); " bytes"; SPACE$(18)
  152.         PRINT "Free Virtual Memory:   ";
  153.         PRINT AddCommas$(FreeVirtualMem); " bytes"; SPACE$(18)
  154.         'PRINT "Free Extended Virtual Memory:"
  155.         'PRINT "  "; FreeExtendedMeml; " bytes"
  156.         ' MEMUSAGE by Steve ]
  157.     $END IF
  158.  
  159.     IF COMMAND$ = "" THEN PRINT: PRINT "May press Alt+X or Alt+Q to eXit/Quit..."
  160.     ReturnCOMBO
  161.     _DISPLAY
  162.  
  163.     $IF WINDOWS THEN
  164.             'FOR i = 1 TO _TOTALDROPPEDFILES
  165.             'a$ = _DROPPEDFILE(i)
  166.             a$ = _DROPPEDFILE(1)
  167.             'NEXT'
  168.             _FINISHDROP 'If _FINISHDROP isn't called here then _TOTALDROPPEDFILES never gets reset.
  169.             'ELSE
  170.             'a$ = "Scroller.$$$"
  171.             'SHELL _HIDE "DIR /B *.* > Scroller.$$$"
  172.         END IF
  173.     $END IF
  174.     $IF WINDOWS THEN
  175.         IF COMMAND$ <> "" THEN a$ = _STARTDIR$ + "\" + COMMAND$
  176.     $ELSE
  177.         IF COMMAND$ <> "" THEN a$ = _STARTDIR$ + "/" + COMMAND$
  178.     $END IF
  179.  
  180.     'WrapFlag = 0
  181.     'Wwidth% = XdimCOL
  182.     'ul& = 0
  183.     'LongestLine = 0
  184.     'DO WHILE NOT EOF(1)
  185.     '    LINE INPUT #1, l$: ul& = ul& + 1
  186.     '    ExpandTabs l$
  187.     '    IF LEN(l$) > LongestLine THEN LongestLine = LEN(l$)
  188.     '    IF WrapFlag THEN
  189.     '        lX$ = l$
  190.     '        DO WHILE LEN(lX$) > Wwidth%
  191.     '            Glupak% = Wwidth%
  192.     '            DO UNTIL MID$(lX$, Glupak% + 1, 1) = " " AND MID$(lX$, Glupak%, 1) <> " "
  193.     '                Glupak% = Glupak% - 1
  194.     '                IF Glupak% = 0 THEN
  195.     '                    PRINT "Rejecting line(#"; LTRIM$(STR$(ul&)); ", "; LTRIM$(STR$(LEN(l$))); "chars) that cannot be wrapped!"
  196.     '                    _DISPLAY: SYSTEM
  197.     '                    GOTO B4Txpanar
  198.     '                END IF
  199.     '            LOOP
  200.     '            PRINT #3, LEFT$(lX$, Glupak%)
  201.     '            lX$ = STRING$(1, " ") + LTRIM$(MID$(lX$, Glupak% + 1, LEN(lX$) - (Glupak%)))
  202.     '        LOOP
  203.     '        PRINT #3, lX$
  204.     '        B4Txpanar:
  205.     '    END IF
  206.     'LOOP
  207.  
  208. TimeA = TIMER
  209.  
  210.     LongestLine = 0
  211.     IF _FILEEXISTS(a$) THEN
  212.         PRINT: PRINT "Loading..."
  213.         _DISPLAY
  214.         filecount = 0
  215.         '        OPEN a$ FOR INPUT AS #1
  216.         OPEN a$ FOR BINARY AS #1 ' As suggested by SMcNeill and Pete in https://www.qb64.org/forum/index.php?topic=3518.msg128631#msg128631
  217.         DO UNTIL EOF(1)
  218.             LINE INPUT #1, l$
  219.             filecount = filecount + 1
  220.         LOOP
  221.         CLOSE #1
  222.         REDIM FileArray$(1 TO filecount)
  223.         filecount = 0
  224.         '        OPEN a$ FOR INPUT AS #1
  225.         OPEN a$ FOR BINARY AS #1 ' As suggested by SMcNeill and Pete in https://www.qb64.org/forum/index.php?topic=3518.msg128631#msg128631
  226.         FileSize = LOF(1)
  227.         DO UNTIL EOF(1)
  228.             LINE INPUT #1, l$
  229.             ExpandTabs l$
  230.             FOR j = 1 TO LEN(l$)
  231.                 IF MID$(l$, j, 1) < CHR$(32) THEN MID$(l$, j, 1) = CHR$(32)
  232.             NEXT j
  233.             IF LEN(l$) > LongestLine THEN LongestLine = LEN(l$)
  234.             filecount = filecount + 1
  235.             FileArray$(filecount) = l$
  236.         LOOP
  237.         CLOSE #1
  238.     END IF
  239.     _LIMIT 5
  240.     'IF INKEY$ = CHR$(27) THEN SYSTEM
  241.     'IF keycode& = 27 THEN SYSTEM
  242.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(81) OR _KEYDOWN(113)) THEN SYSTEM
  243.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(88) OR _KEYDOWN(120)) THEN SYSTEM
  244.  
  245.     '                            QB64 _KEYHIT and _KEYDOWN Values
  246.     '
  247.     'Esc  F1    F2    F3    F4    F5    F6    F7    F8    F9    F10   F11   F12   Sys  ScL Pause
  248.     ' 27 15104 15360 15616 15872 16128 16384 16640 16896 17152 17408 34048 34304 +316 +302 +019
  249.     '`~  1!  2@  3#  4$  5%  6^  7&  8*  9(  0) -_ =+ BkSp   Ins   Hme   PUp   NumL   /     *    -
  250.     '126 33  64  35  36  37  94  38  42  40  41 95 43   8   20992 18176 18688 +300   47    42   45
  251.     ' 96 49  50  51  52  53  54  55  56  57  48 45 61
  252.     'Tab Q   W   E   R   T   Y   U   I   O   P  [{  ]}  \|   Del   End   PDn   7Hme  8/?   9PU   +
  253.     ' 9  81  87  69  82  84  89  85  73  79  80 123 125 124 21248 20224 20736 18176 18432 18688 43
  254.     '   113 119 101 114 116 121 117 105 111 112  91  93  92                    55    56    57
  255.     'CapL   A   S   D   F   G   H   J   K   L   ;:  '" Enter                   4/?-   5    6/-?
  256.     '+301   65  83  68  70  71  72  74  75  76  58  34  13                    19200 19456 19712  E
  257.     '       97 115 100 102 103 104 106 107 108  59  39                         52    53    54    n
  258.     'Shift   Z   X   C   V   B   N   M   ,<  .>  /?    Shift       ?           1End  2/?   3PD   t
  259.     '+304   90  88  67  86  66  78  77  60  62  63    +303       18432        20224 20480 20736  e
  260.     '      122 120  99 118  98 110 109  44  46  47                             49    50    51    r
  261.     'Ctrl   Win  Alt     Spacebar      Alt  Win  Menu  Ctrl   ?-   ?   -?      0Ins        .Del
  262.     '+306  +311 +308       32         +307 +312 +319  +305 19200 20480 19712  20992       21248 13
  263.     '                                                                          48          46
  264.     '         Lower value = LCase/NumLock On __________________ + = add 100000
  265.  
  266. LOOP WHILE a$ = ""
  267.  
  268. TimeB = TIMER
  269. 'PLAY "L8V2a-c-" 'removed in order to get rid of audio dependency
  270. CurrentLine = 1
  271. FOR i = 1 TO YdimROW
  272.     LOCATE i, 1: PRINT SPACE$(XdimCOL);
  273. FOR i = 1 TO MIN&(YdimROW, filecount)
  274.     IF LEN(FileArray$(i)) >= XdimCOL THEN
  275.         FileArrayWINDOW$(i) = MID$(FileArray$(i), 1, XdimCOL)
  276.     ELSE
  277.         FileArrayWINDOW$(i) = FileArray$(i) + SPACE$(XdimCOL - LEN(FileArray$(i)))
  278.     END IF
  279.     LOCATE i, 1: PRINT FileArrayWINDOW$(i);
  280.  
  281. ' Here is the layout:
  282. ' The window-frame is 1..crx or 1..128 |  The file-frame is 1..LongestLine
  283. '                     .         .      |                    .
  284. '                     .         .      |                    .
  285. '                     cry       60     |                    filecount
  286. '              FileArrayWINDOW$(60)    |          FileArray(filecount)
  287. ' if File_Frame_x < 128 then PADDING to 128 else File_Frame_x = 1..LongestLine-(128-1)
  288. ' if File_Frame_y < 60 then PADDING to 60 else File_Frame_y = 1..filecount-(60-1)
  289.  
  290. UpdateCLine 1, 1, InverseFRGr, InverseBCKGr, 1
  291. StatuLine$ = SPACE$(XdimCOL)
  292. MID$(StatuLine$, 1, 1) = "["
  293. MID$(StatuLine$, XdimCOL, 1) = "]"
  294.  
  295. Dumbo$ = "File Size: " + AddCommas$(FileSize) + "; Longest Line: " + AddCommas$(LongestLine) + "; Total Lines: " + AddCommas$(filecount)
  296. MID$(StatuLine$, 2, LEN(Dumbo$)) = Dumbo$
  297. LOCATE YdimROW + 1, 1: COLOR 9, 0: PRINT StatuLine$;
  298. UpdateCLL CurrentLine, LEN(Dumbo$) + 1 + 1
  299. CLL_Field = LEN(AddCommas$(LongestLine))
  300. MostRightField = LEN(Dumbo$) + 1 + 1 + (LEN("; Current Line Length: ") + CLL_Field)
  301. UpdateNextToCCL_DONE MostRightField
  302.  
  303. LOCATE 1, 1, 1, 30, 31
  304. crx = POS(0)
  305. cry = CSRLIN
  306. crxOLD = crx
  307. cryOLD = cry
  308. File_Frame_x = 1
  309. File_Frame_y = 1
  310.  
  311.     ReturnCOMBO
  312.     IF LSHIFT_RSHIFT THEN
  313.         'PLAY "L4V2f" 'removed in order to get rid of audio dependency
  314.         _KEYCLEAR
  315.         ReportTimeToLoad MostRightField
  316.         _DISPLAY
  317.     END IF
  318.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(81) OR _KEYDOWN(113)) THEN SYSTEM
  319.     IF (_KEYDOWN(LALTkey&) OR _KEYDOWN(RALTkey&)) AND (_KEYDOWN(88) OR _KEYDOWN(120)) THEN SYSTEM
  320.     key$ = INKEY$
  321.     'DO: a$ = INKEY$: LOOP UNTIL a$ <> "" ' prevent ASC empty string read error
  322.     IF key$ <> "" THEN
  323.         code% = ASC(key$):
  324.         IF code% THEN ' ASC returns any value greater than 0
  325.             SELECT CASE ASC(key$)
  326.                 CASE 65 TO 97: 'PRINT key$;
  327.                 CASE ASC("a") TO ASC("z"): 'PRINT key$;
  328.                     'CASE 27: COLOR 7, 0: SYSTEM 'END
  329.             END SELECT
  330.         ELSE
  331.             SELECT CASE ASC(key$, 2)
  332.                 CASE 72:
  333.                     IF CurrentLine > 1 THEN CurrentLine = CurrentLine - 1
  334.                     IF cry > 1 THEN
  335.                         cry = cry - 1 'up
  336.                     ELSE 'scrolling is needed
  337.                         IF File_Frame_y > 1 THEN File_Frame_y = File_Frame_y - 1
  338.                         UpdateWindowFrame NormalFRGr, NormalBCKGr
  339.                     END IF
  340.                 CASE 80:
  341.                     IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  342.                     IF cry < YdimROW THEN
  343.                         IF cry < filecount THEN cry = cry + 1 'down
  344.                     ELSE 'scrolling is needed
  345.                         IF File_Frame_y < filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  346.                         UpdateWindowFrame NormalFRGr, NormalBCKGr
  347.                     END IF
  348.                 CASE 75: IF crx > 1 THEN crx = crx - 1 'left
  349.                 CASE 77: IF crx < XdimCOL THEN crx = crx + 1 'right
  350.             END SELECT
  351.         END IF
  352.     END IF
  353.     IF cryOLD <> cry THEN
  354.         UpdateCLine cryOLD, 1, NormalFRGr, NormalBCKGr, cryOLD
  355.         cryOLD = cry
  356.     ELSE 'it 'cry' could be changed by Mouse Wheel too, check it
  357.         AsIfItIsINKEY% = _MOUSEINPUT '      Check the mouse status
  358.         IF _MOUSEWHEEL = 1 THEN ' as if Down
  359.             IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  360.             IF cry < YdimROW THEN
  361.                 IF cry < filecount THEN cry = cry + 1 'down
  362.             ELSE 'scrolling is needed
  363.                 IF File_Frame_y < filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  364.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  365.             END IF
  366.         END IF
  367.         IF _MOUSEWHEEL = -1 THEN ' as if Up
  368.             IF CurrentLine > 1 THEN CurrentLine = CurrentLine - 1
  369.             IF cry > 1 THEN
  370.                 cry = cry - 1 'up
  371.             ELSE 'scrolling is needed
  372.                 IF File_Frame_y > 1 THEN File_Frame_y = File_Frame_y - 1
  373.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  374.             END IF
  375.         END IF
  376.         IF _MOUSEBUTTON(1) THEN
  377.             crxOLD = crx
  378.             cryOLD = cry
  379.             cry = _MOUSEY
  380.             crx = _MOUSEX
  381.             UpdateCLine cryOLD, 1, NormalFRGr, NormalBCKGr, cryOLD
  382.             DO WHILE cryOLD > cry
  383.                 cryOLD = cryOLD - 1
  384.                 IF CurrentLine > 1 THEN CurrentLine = CurrentLine - 1
  385.             LOOP
  386.             DO WHILE cryOLD < cry
  387.                 cryOLD = cryOLD + 1
  388.                 IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  389.             LOOP
  390.         END IF
  391.         IF _MOUSEBUTTON(3) THEN 'PgDn - just add the page height i.e. 'YdimROW' to 'File_Frame_y'
  392.             ' Don't execute PgDn (advancing the 'CurrentLine') if 'File_Frame_y' is not "eligible":
  393.             'IF File_Frame_y < filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  394.             'IF File_Frame_y + 1 <= filecount - (YdimROW - 1) THEN File_Frame_y = File_Frame_y + 1
  395.             'CAUTION [
  396.             ' Next three line beep NOT
  397.             'DEFLNG A-Z
  398.             'aaa = 61
  399.             'bbb = -48
  400.             'IF aaa <= bbb THEN BEEP: END
  401.             'Next three line beep
  402.             'aaa~& = 61
  403.             'bbb~& = -48
  404.             'IF aaa~& <= bbb~& THEN BEEP: END
  405.             'Next three line beep NOT
  406.             'aaa& = 61
  407.             'bbb& = -48
  408.             'IF aaa& <= bbb& THEN BEEP: END
  409.             'Next line works even when unsigned!
  410.             'IF File_Frame_y + YdimROW - (filecount - (YdimROW - 1)) <= 0 THEN
  411.             'CAUTION ]
  412.             'Next line doesn't work when unsigned!
  413.             IF File_Frame_y + YdimROW <= filecount - (YdimROW - 1) THEN
  414.                 File_Frame_y = File_Frame_y + YdimROW
  415.                 'IF CurrentLine < filecount THEN CurrentLine = CurrentLine + 1
  416.                 'IF CurrentLine + 1 <= filecount THEN CurrentLine = CurrentLine + 1
  417.                 IF CurrentLine + YdimROW <= filecount THEN CurrentLine = CurrentLine + YdimROW
  418.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  419.             END IF
  420.         END IF
  421.     END IF
  422.     IF cryOLD <> cry THEN
  423.         UpdateCLine cryOLD, 1, NormalFRGr, NormalBCKGr, cryOLD
  424.         cryOLD = cry
  425.     END IF
  426.     IF LCTRL_HOME THEN
  427.         LOCATE 1, 1, 1, 30, 31
  428.         crx = POS(0)
  429.         cry = CSRLIN
  430.         crxOLD = crx
  431.         cryOLD = cry
  432.         File_Frame_x = 1
  433.         File_Frame_y = 1
  434.         CurrentLine = 1
  435.         UpdateWindowFrame NormalFRGr, NormalBCKGr
  436.     END IF
  437.     IF LCTRL_END THEN
  438.         IF filecount >= YdimROW THEN
  439.             IF filecount - (YdimROW - 1) THEN
  440.                 LOCATE YdimROW, 1, 1, 30, 31
  441.                 crx = POS(0)
  442.                 cry = CSRLIN
  443.                 crxOLD = crx
  444.                 cryOLD = cry
  445.                 File_Frame_x = 1
  446.                 File_Frame_y = filecount - (YdimROW - 1)
  447.                 CurrentLine = filecount
  448.                 UpdateWindowFrame NormalFRGr, NormalBCKGr
  449.             END IF
  450.         ELSE
  451.             LOCATE filecount, 1, 1, 30, 31
  452.             crx = POS(0)
  453.             cry = CSRLIN
  454.             crxOLD = crx
  455.             cryOLD = cry
  456.             File_Frame_x = 1
  457.             File_Frame_y = 1
  458.             CurrentLine = filecount
  459.             UpdateWindowFrame NormalFRGr, NormalBCKGr
  460.         END IF
  461.     END IF
  462.  
  463.     LOCATE cry, crx, 1, 30, 31
  464.     UpdateCLine cry, 1, InverseFRGr, InverseBCKGr, cry
  465.     UpdateCLL CurrentLine, LEN(Dumbo$) + 1 + 1
  466.     _DISPLAY
  467.     'DO WHILE INKEY$ <> "": LOOP ' have to clear the keyboard buffer
  468.     _LIMIT 500 '_LIMIT 30 'commented because the wheel up/down was not working?!
  469.  
  470.  
  471.  
  472. '_TITLE "Mouse Feedback"
  473. 'DO
  474. '    DO WHILE _MOUSEINPUT '      Check the mouse status
  475. '        PRINT _MOUSEX, _MOUSEY, _MOUSEBUTTON(1); _MOUSEBUTTON(2); _MOUSEBUTTON(3), _MOUSEWHEEL
  476. '    LOOP
  477. 'LOOP UNTIL INKEY$ <> ""
  478.  
  479. 'Syntax:
  480. 'infoExists%% = _MOUSEINPUT
  481.  
  482. 'Description:
  483. '- Returns -1 if new mouse information is available, otherwise it returns 0.
  484. '- Must be called before reading any of the other mouse functions. The function will not miss any
  485. '  mouse input even during an INPUT entry.
  486. '- Use in a loop to monitor the mouse buttons, scroll wheel and coordinate positions.
  487. '-  To clear all previous mouse data, use _MOUSEINPUT in a loop until it returns 0.
  488.  
  489.  
  490.  
  491. ' _FONT (function) creates a new alphablended font handle from a designated image handle
  492. ' _FONT (statement) sets the current _LOADFONT function font handle to be used by PRINT or
  493. '  _PRINTSTRING.
  494. ' _FONTHEIGHT (function) returns the font height of a font handle created by _LOADFONT.
  495. ' _FONTWIDTH (function) returns the font width of a MONOSPACE font handle created by _LOADFONT.
  496. ' _FREEFONT (statement) frees a font handle value from memory
  497. ' _LOADFONT (function) loads a TrueType font (.TTF) file of a specific size and style and returns
  498. '  a font handle value.
  499.  
  500. ' _DISPLAY (statement) turns off automatic display while only displaying the screen changes when
  501. '  called.
  502.  
  503. ' SHELL (QB64 function) executes a DOS command or calls another program. Returns codes sent by END
  504. '  or SYSTEM.
  505. ' _SHELLHIDE (function) hides a DOS command or call to another program. Returns codes sent by END
  506. '  or SYSTEM.
  507.  
  508.  
  509. ' _CWD$ (function) returns the current working directory path as a STRING.
  510. ' _DONTWAIT (SHELL action) allows the program to continue without waiting for the other program to
  511. '  close.
  512. ' _FILEEXISTS (function) returns -1 if the file name string parameter exists. Zero if it does not.
  513. ' _HIDE (SHELL action) hides the DOS screen output during a shell.
  514.  
  515. ' _SHELLHIDE (function) executes a DOS command or calls another program. Returns codes sent by END
  516. '  or SYSTEM.
  517. ' _STARTDIR$ (function) returns the user's program calling path as a STRING.
  518.  
  519.  
  520.  
  521. 'The _MEMNEW function allocates new memory and returns a _MEM memory block referring to it.
  522.  
  523. 'Syntax:
  524. '     memoryBlock = _MEMNEW(byteSize)
  525.  
  526. '- The byteSize parameter is the desired byte size of the memory block based on the variable type
  527. '  it will hold.
  528.  
  529. 'Description:
  530. '- The memoryBlock value created holds the elements .OFFSET, .SIZE, .TYPE and .ELEMENTSIZE.
  531. '- _MEMNEW does not clear the data previously in the memory block it allocates, for speed purposes.
  532. '- To clear previous data from a new memory block, use _MEMFILL with a byte value of 0.
  533. '- When a new memory block is created the memory .TYPE value will be 0.
  534. '- If the read only memory block .SIZE is 0, the memory block was not created.
  535. '- All values created by memory functions must be freed using _MEMFREE with a valid _MEM variable.
  536.  
  537. 'Code Examples:
  538. 'Example: Shows how SINGLE numerical values can be passed, but non-fixed STRING lengths cannot get
  539. 'the value.
  540.  
  541. 'DIM m AS _MEM
  542. 'DIM f AS STRING * 5
  543. 'm = _MEMNEW(5) 'create new memory block of 5 bytes
  544. 'a = 12345.6
  545. '_MEMPUT m, m.OFFSET, a 'put single value
  546. '_MEMGET m, m.OFFSET, b 'get single value
  547. 'PRINT "b = "; b
  548. 'c$ = "Doggy"
  549. '_MEMPUT m, m.OFFSET, c$ 'put 5 byte string value
  550. '_MEMGET m, m.OFFSET, d$ 'get unfixed length string value
  551. '_MEMGET m, m.OFFSET, f  'get 5 byte string value
  552. 'e$ = _MEMGET(m, m.OFFSET, STRING * 5) 'get 5 byte string value
  553. 'PRINT "d$ = "; d$; LEN(d$) 'prints empty string
  554. 'PRINT "e$ = "; e$; LEN(e$)
  555. 'PRINT "f = "; f; LEN(f)
  556.  
  557.  
  558.  
  559. ''OPENICON.BAS
  560. ''============
  561. ''Maximizes a minimized program using WinAPI.
  562. ''By Dav, DEC/2020
  563.  
  564. 'DECLARE DYNAMIC LIBRARY "user32"
  565. '    FUNCTION OpenIcon& (BYVAL hwnd AS LONG)
  566. 'END DECLARE
  567.  
  568. 'PRINT
  569. 'PRINT "Minimize this program at it will pop back up in 2 secs."
  570.  
  571. 'DO
  572. '    IF _SCREENICON THEN
  573. '        SLEEP 2: x& = OpenIcon&(_WINDOWHANDLE)
  574. '    END IF
  575. 'LOOP
  576.  
  577. ' http://www.qb64.org/wiki/CONSOLETITLE
  578. 'Example: Hiding the main program window while displaying the console window with a title.
  579.  
  580. SUB ReturnCOMBO
  581.     SHARED LSHIFT_RSHIFT
  582.     SHARED LCTRL_RCTRL
  583.     SHARED LALT_RALT
  584.  
  585.     SHARED LALT_HOME
  586.     SHARED LALT_END
  587.  
  588.     SHARED LALT_INS
  589.     SHARED LALT_DEL
  590.  
  591.     SHARED LALT_PGUP
  592.     SHARED LALT_PGDN
  593.  
  594.     SHARED LALT_Left
  595.     SHARED LALT_Right
  596.     SHARED LALT_Up
  597.     SHARED LALT_Down
  598.  
  599.     SHARED RALT_HOME
  600.     SHARED RALT_END
  601.  
  602.     SHARED RALT_INS
  603.     SHARED RALT_DEL
  604.  
  605.     SHARED RALT_PGUP
  606.     SHARED RALT_PGDN
  607.  
  608.     SHARED RALT_Left
  609.     SHARED RALT_Right
  610.     SHARED RALT_Up
  611.     SHARED RALT_Down
  612.  
  613.     SHARED LSHIFT_HOME
  614.     SHARED LSHIFT_END
  615.  
  616.     SHARED LSHIFT_INS
  617.     SHARED LSHIFT_DEL
  618.  
  619.     SHARED LSHIFT_PGUP
  620.     SHARED LSHIFT_PGDN
  621.  
  622.     SHARED LSHIFT_Left
  623.     SHARED LSHIFT_Right
  624.     SHARED LSHIFT_Up
  625.     SHARED LSHIFT_Down
  626.  
  627.     SHARED RSHIFT_HOME
  628.     SHARED RSHIFT_END
  629.  
  630.     SHARED RSHIFT_INS
  631.     SHARED RSHIFT_DEL
  632.  
  633.     SHARED RSHIFT_PGUP
  634.     SHARED RSHIFT_PGDN
  635.  
  636.     SHARED RSHIFT_Left
  637.     SHARED RSHIFT_Right
  638.     SHARED RSHIFT_Up
  639.     SHARED RSHIFT_Down
  640.  
  641.     SHARED LCTRL_HOME
  642.     SHARED LCTRL_END
  643.  
  644.     SHARED LCTRL_INS
  645.     SHARED LCTRL_DEL
  646.  
  647.     SHARED LCTRL_PGUP
  648.     SHARED LCTRL_PGDN
  649.  
  650.     SHARED LCTRL_Left
  651.     SHARED LCTRL_Right
  652.     SHARED LCTRL_Up
  653.     SHARED LCTRL_Down
  654.  
  655.     SHARED RCTRL_HOME
  656.     SHARED RCTRL_END
  657.  
  658.     SHARED RCTRL_INS
  659.     SHARED RCTRL_DEL
  660.  
  661.     SHARED RCTRL_PGUP
  662.     SHARED RCTRL_PGDN
  663.  
  664.     SHARED RCTRL_Left
  665.     SHARED RCTRL_Right
  666.     SHARED RCTRL_Up
  667.     SHARED RCTRL_Down
  668.  
  669.     SHARED LSHIFT_LCTRL_HOME
  670.     SHARED LSHIFT_LCTRL_END
  671.  
  672.     SHARED LSHIFT_LCTRL_INS
  673.     SHARED LSHIFT_LCTRL_DEL
  674.  
  675.     SHARED LSHIFT_LCTRL_PGUP
  676.     SHARED LSHIFT_LCTRL_PGDN
  677.  
  678.     SHARED LSHIFT_LCTRL_Left
  679.     SHARED LSHIFT_LCTRL_Right
  680.     SHARED LSHIFT_LCTRL_Up
  681.     SHARED LSHIFT_LCTRL_Down
  682.  
  683.     SHARED LSHIFT_BackSpace
  684.     SHARED LSHIFT_TAB
  685.     SHARED LSHIFT_SPACE
  686.     SHARED LSHIFT_ESC
  687.     SHARED LSHIFT_ENTER
  688.  
  689.     SHARED RSHIFT_BackSpace
  690.     SHARED RSHIFT_TAB
  691.     SHARED RSHIFT_SPACE
  692.     SHARED RSHIFT_ESC
  693.     SHARED RSHIFT_ENTER
  694.  
  695.     SHARED LCTRL_SPACE
  696.     SHARED LCTRL_ENTER
  697.  
  698.     SHARED RCTRL_SPACE
  699.     SHARED RCTRL_ENTER
  700.  
  701.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(RSHIFTkey&) THEN LSHIFT_RSHIFT = 1 ELSE LSHIFT_RSHIFT = 0
  702.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(RCTRLkey&) THEN LCTRL_RCTRL = 1 ELSE LCTRL_RCTRL = 0
  703.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(RALTkey&) THEN LALT_RALT = 1 ELSE LALT_RALT = 0
  704.  
  705.     'LALT:
  706.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(HOMEkey&) THEN LALT_HOME = 1 ELSE LALT_HOME = 0
  707.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(ENDkey&) THEN LALT_END = 1 ELSE LALT_END = 0
  708.  
  709.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(INSkey&) THEN LALT_INS = 1 ELSE LALT_INS = 0
  710.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(DELkey&) THEN LALT_DEL = 1 ELSE LALT_DEL = 0
  711.  
  712.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(PGUPkey&) THEN LALT_PGUP = 1 ELSE LALT_PGUP = 0
  713.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(PGDNkey&) THEN LALT_PGDN = 1 ELSE LALT_PGDN = 0
  714.  
  715.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(LEFTkey&) THEN LALT_Left = 1 ELSE LALT_Left = 0
  716.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(RIGHTkey&) THEN LALT_Right = 1 ELSE LALT_Right = 0
  717.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(UPkey&) THEN LALT_Up = 1 ELSE LALT_Up = 0
  718.     IF _KEYDOWN(LALTkey&) AND _KEYDOWN(DOWNkey&) THEN LALT_Down = 1 ELSE LALT_Down = 0
  719.  
  720.     'RALT:
  721.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(HOMEkey&) THEN RALT_HOME = 1 ELSE RALT_HOME = 0
  722.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(ENDkey&) THEN RALT_END = 1 ELSE RALT_END = 0
  723.  
  724.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(INSkey&) THEN RALT_INS = 1 ELSE RALT_INS = 0
  725.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(DELkey&) THEN RALT_DEL = 1 ELSE RALT_DEL = 0
  726.  
  727.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(PGUPkey&) THEN RALT_PGUP = 1 ELSE RALT_PGUP = 0
  728.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(PGDNkey&) THEN RALT_PGDN = 1 ELSE RALT_PGDN = 0
  729.  
  730.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(LEFTkey&) THEN PRINT RALT_Left = 1 ELSE RALT_Left = 0
  731.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(RIGHTkey&) THEN RALT_Right = 1 ELSE RALT_Right = 0
  732.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(UPkey&) THEN RALT_Up = 1 ELSE RALT_Up = 0
  733.     IF _KEYDOWN(RALTkey&) AND _KEYDOWN(DOWNkey&) THEN RALT_Down = 1 ELSE RALT_Down = 0
  734.  
  735.     'LSHIFT:
  736.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(HOMEkey&) THEN LSHIFT_HOME = 1 ELSE LSHIFT_HOME = 0
  737.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(ENDkey&) THEN LSHIFT_END = 1 ELSE LSHIFT_END = 0
  738.  
  739.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(INSkey&) THEN LSHIFT_INS = 1 ELSE LSHIFT_INS = 0
  740.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(DELkey&) THEN LSHIFT_DEL = 1 ELSE LSHIFT_DEL = 0
  741.  
  742.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(PGUPkey&) THEN LSHIFT_PGUP = 1 ELSE LSHIFT_PGUP = 0
  743.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(PGDNkey&) THEN LSHIFT_PGDN = 1 ELSE LSHIFT_PGDN = 0
  744.  
  745.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LEFTkey&) THEN LSHIFT_Left = 1 ELSE LSHIFT_Left = 0
  746.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(RIGHTkey&) THEN LSHIFT_Right = 1 ELSE LSHIFT_Right = 0
  747.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(UPkey&) THEN LSHIFT_Up = 1 ELSE LSHIFT_Up = 0
  748.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(DOWNkey&) THEN LSHIFT_Down = 1 ELSE LSHIFT_Down = 0
  749.  
  750.     'RSHIFT:
  751.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(HOMEkey&) THEN RSHIFT_HOME = 1 ELSE RSHIFT_HOME = 0
  752.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(ENDkey&) THEN RSHIFT_END = 1 ELSE RSHIFT_END = 0
  753.  
  754.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(INSkey&) THEN RSHIFT_INS = 1 ELSE RSHIFT_INS = 0
  755.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(DELkey&) THEN RSHIFT_DEL = 1 ELSE RSHIFT_DEL = 0
  756.  
  757.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(PGUPkey&) THEN RSHIFT_PGUP = 1 ELSE RSHIFT_PGUP = 0
  758.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(PGDNkey&) THEN RSHIFT_PGDN = 1 ELSE RSHIFT_PGDN = 0
  759.  
  760.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(LEFTkey&) THEN RSHIFT_Left = 1 ELSE RSHIFT_Left = 0
  761.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(RIGHTkey&) THEN RSHIFT_Right = 1 ELSE RSHIFT_Right = 0
  762.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(UPkey&) THEN RSHIFT_Up = 1 ELSE RSHIFT_Up = 0
  763.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(DOWNkey&) THEN RSHIFT_Down = 1 ELSE RSHIFT_Down = 0
  764.  
  765.     'LCTRL:
  766.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(HOMEkey&) THEN LCTRL_HOME = 1 ELSE LCTRL_HOME = 0
  767.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(ENDkey&) THEN LCTRL_END = 1 ELSE LCTRL_END = 0
  768.  
  769.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(INSkey&) THEN LCTRL_INS = 1 ELSE LCTRL_INS = 0
  770.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DELkey&) THEN LCTRL_DEL = 1 ELSE LCTRL_DEL = 0
  771.  
  772.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGUPkey&) THEN LCTRL_PGUP = 1 ELSE LCTRL_PGUP = 0
  773.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGDNkey&) THEN LCTRL_PGDN = 1 ELSE LCTRL_PGDN = 0
  774.  
  775.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(LEFTkey&) THEN LCTRL_Left = 1 ELSE LCTRL_Left = 0
  776.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(RIGHTkey&) THEN LCTRL_Right = 1 ELSE LCTRL_Right = 0
  777.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(UPkey&) THEN LCTRL_Up = 1 ELSE LCTRL_Up = 0
  778.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DOWNkey&) THEN LCTRL_Down = 1 ELSE LCTRL_Down = 0
  779.  
  780.     'RCTRL:
  781.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(HOMEkey&) THEN RCTRL_HOME = 1 ELSE RCTRL_HOME = 0
  782.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(ENDkey&) THEN RCTRL_END = 1 ELSE RCTRL_END = 0
  783.  
  784.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(INSkey&) THEN RCTRL_INS = 1 ELSE RCTRL_INS = 0
  785.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(DELkey&) THEN RCTRL_DEL = 1 ELSE RCTRL_DEL = 0
  786.  
  787.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(PGUPkey&) THEN RCTRL_PGUP = 1 ELSE RCTRL_PGUP = 0
  788.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(PGDNkey&) THEN RCTRL_PGDN = 1 ELSE RCTRL_PGDN = 0
  789.  
  790.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(LEFTkey&) THEN RCTRL_Left = 1 ELSE RCTRL_Left = 0
  791.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(RIGHTkey&) THEN RCTRL_Right = 1 ELSE RCTRL_Right = 0
  792.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(UPkey&) THEN RCTRL_Up = 1 ELSE RCTRL_Up = 0
  793.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(DOWNkey&) THEN RCTRL_Down = 1 ELSE RCTRL_Down = 0
  794.  
  795.     'LSHIFT+LCTRL: NOTICE: LSHIFT+LCTRL+Left triggers 3 variables on - 1] LSHIFT_LCTRL_Left 2] LSHIFT_Left 3] LCTRL_Left
  796.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(HOMEkey&) THEN LSHIFT_LCTRL_HOME = 1 ELSE LSHIFT_LCTRL_HOME = 0
  797.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(ENDkey&) THEN LSHIFT_LCTRL_END = 1 ELSE LSHIFT_LCTRL_END = 0
  798.  
  799.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(INSkey&) THEN LSHIFT_LCTRL_INS = 1 ELSE LSHIFT_LCTRL_INS = 0
  800.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DELkey&) THEN LSHIFT_LCTRL_DEL = 1 ELSE LSHIFT_LCTRL_DEL = 0
  801.  
  802.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGUPkey&) THEN LSHIFT_LCTRL_PGUP = 1 ELSE LSHIFT_LCTRL_PGUP = 0
  803.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(PGDNkey&) THEN LSHIFT_LCTRL_PGDN = 1 ELSE LSHIFT_LCTRL_PGDN = 0
  804.  
  805.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(LEFTkey&) THEN LSHIFT_LCTRL_Left = 1 ELSE LSHIFT_LCTRL_Left = 0
  806.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(RIGHTkey&) THEN LSHIFT_LCTRL_Right = 1 ELSE LSHIFT_LCTRL_Right = 0
  807.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(UPkey&) THEN LSHIFT_LCTRL_Up = 1 ELSE LSHIFT_LCTRL_Up = 0
  808.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(LCTRLkey&) AND _KEYDOWN(DOWNkey&) THEN LSHIFT_LCTRL_Down = 1 ELSE LSHIFT_LCTRL_Down = 0
  809.  
  810.     'LSHIFT:
  811.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(BACKSPCkey&) THEN LSHIFT_BackSpace = 1 ELSE LSHIFT_BackSpace = 0
  812.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(TABkey&) THEN LSHIFT_TAB = 1 ELSE LSHIFT_TAB = 0
  813.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(SPACEkey&) THEN LSHIFT_SPACE = 1 ELSE LSHIFT_SPACE = 0
  814.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(ESCkey&) THEN LSHIFT_ESC = 1 ELSE LSHIFT_ESC = 0
  815.     IF _KEYDOWN(LSHIFTkey&) AND _KEYDOWN(ENTERkey&) THEN LSHIFT_ENTER = 1 ELSE LSHIFT_ENTER = 0
  816.     'RSHIFT:
  817.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(BACKSPCkey&) THEN RSHIFT_BackSpace = 1 ELSE RSHIFT_BackSpace = 0
  818.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(TABkey&) THEN RSHIFT_TAB = 1 ELSE RSHIFT_TAB = 0
  819.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(SPACEkey&) THEN RSHIFT_SPACE = 1 ELSE RSHIFT_SPACE = 0
  820.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(ESCkey&) THEN RSHIFT_ESC = 1 ELSE RSHIFT_ESC = 0
  821.     IF _KEYDOWN(RSHIFTkey&) AND _KEYDOWN(ENTERkey&) THEN RSHIFT_ENTER = 1 ELSE RSHIFT_ENTER = 0
  822.  
  823.     'LCTRL:
  824.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(SPACEkey&) THEN LCTRL_SPACE = 1 ELSE LCTRL_SPACE = 0
  825.     IF _KEYDOWN(LCTRLkey&) AND _KEYDOWN(ENTERkey&) THEN LCTRL_ENTER = 1 ELSE LCTRL_ENTER = 0
  826.     'RCTRL:
  827.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(SPACEkey&) THEN RCTRL_SPACE = 1 ELSE RCTRL_SPACE = 0
  828.     IF _KEYDOWN(RCTRLkey&) AND _KEYDOWN(ENTERkey&) THEN RCTRL_ENTER = 1 ELSE RCTRL_ENTER = 0
  829.  
  830.     '_KEYCLEAR
  831.  
  832. SUB ExpandTabs (l$)
  833.     IF INSTR(l$, CHR$(9)) THEN
  834.         TabV% = 8
  835.         b$ = "": f& = 0
  836.         FOR i& = 1 TO LEN(l$)
  837.             IF MID$(l$, i&, 1) = CHR$(9) THEN
  838.                 b$ = b$ + STRING$((f& \ TabV%) * TabV% + TabV% - f&, " ")
  839.                 '  |
  840.                 '  |
  841.                 ' \|/
  842.                 'TabV% - (f% - (f% \ TabV%) * TabV%) =
  843.                 'TabV% - (f% MOD TabV%)
  844.                 f& = (f& \ TabV%) * TabV% + TabV%
  845.             ELSE
  846.                 b$ = b$ + MID$(l$, i&, 1)
  847.                 f& = f& + 1
  848.             END IF
  849.         NEXT
  850.         l$ = b$
  851.     END IF
  852.  
  853. FUNCTION MIN& (YdimROW, filecount)
  854.     IF YdimROW < filecount THEN MIN& = YdimROW ELSE MIN& = filecount
  855.  
  856. FUNCTION AddCommas$ (numeral)
  857.     s$ = LTRIM$(STR$(numeral))
  858.     IF LEN(s$) > 3 THEN
  859.         IF (LEN(s$) MOD 3) THEN x$ = STRING$(3 - (LEN(s$) MOD 3), " ") + s$ ELSE x$ = s$
  860.         s$ = ""
  861.         FOR i = 1 TO LEN(x$) STEP 3
  862.             s$ = s$ + MID$(x$, i, 3) + ","
  863.         NEXT
  864.         s$ = LEFT$(s$, LEN(s$) - 1)
  865.     END IF
  866.     AddCommas$ = LTRIM$(s$)
  867.  
  868. SUB UpdateCLL (l, posit)
  869.     SHARED CLL_Field
  870.     SHARED YdimROW, FileArray$()
  871.     crx = POS(0)
  872.     cry = CSRLIN
  873.     q$ = AddCommas$(LEN(FileArray$(l)))
  874.     LOCATE YdimROW + 1, posit: COLOR 9, 0: PRINT "; Current Line Length: " + q$ + STRING$(CLL_Field - LEN(q$), " ");
  875.     LOCATE cry, crx, 1, 30, 31
  876.  
  877. SUB UpdateNextToCCL_BUSY (posit)
  878.     SHARED YdimROW
  879.     crx = POS(0)
  880.     cry = CSRLIN
  881.     LOCATE YdimROW + 1, posit: COLOR 9, 0: PRINT "; Status: BUSY";
  882.     LOCATE cry, crx, 1, 30, 31
  883.  
  884. SUB UpdateNextToCCL_DONE (posit)
  885.     SHARED YdimROW
  886.     crx = POS(0)
  887.     cry = CSRLIN
  888.     LOCATE YdimROW + 1, posit: COLOR 9, 0: PRINT "; Status: DONE";
  889.     LOCATE cry, crx, 1, 30, 31
  890.  
  891. SUB UpdateCLine (lineToWrite, columnToWrite, FRGR, BACKGR, ln)
  892.     SHARED FileArrayWINDOW$()
  893.     crx = POS(0)
  894.     cry = CSRLIN
  895.     COLOR FRGR, BACKGR
  896.     LOCATE lineToWrite, columnToWrite, 1, 30, 31
  897.     PRINT FileArrayWINDOW$(ln);
  898.     LOCATE cry, crx, 1, 30, 31
  899.  
  900. SUB UpdateWindowFrame (FRGR, BACKGR)
  901.     SHARED YdimROW, filecount, FileArray$(), File_Frame_y, XdimCOL, FileArrayWINDOW$()
  902.     COLOR FRGR, BACKGR
  903.     FOR i = 1 TO MIN&(YdimROW, filecount)
  904.         IF LEN(FileArray$(i + (File_Frame_y - 1))) >= XdimCOL THEN
  905.             FileArrayWINDOW$(i) = MID$(FileArray$(i + (File_Frame_y - 1)), 1, XdimCOL)
  906.         ELSE
  907.             FileArrayWINDOW$(i) = FileArray$(i + (File_Frame_y - 1)) + SPACE$(XdimCOL - LEN(FileArray$(i + (File_Frame_y - 1))))
  908.         END IF
  909.         LOCATE i, 1: PRINT FileArrayWINDOW$(i);
  910.     NEXT
  911.  
  912. SUB ReportTimeToLoad (posit)
  913.     SHARED YdimROW
  914.     SHARED TimeA, TimeB
  915.     crx = POS(0)
  916.     cry = CSRLIN
  917.     LOCATE YdimROW + 1, posit: COLOR 4, 0: PRINT "; Loaded in"; TimeB - TimeA; "seconds.";
  918.     LOCATE cry, crx, 1, 30, 31
  919.  
  920. '@rem This is 'MyCompile.bat', should be placed and run from qb64\:
  921.  
  922. '@rem 'recompile_win.bat' found at E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\temp:
  923. '@rem @echo off
  924. '@rem cd %0\..\
  925. '@rem echo Recompiling...
  926. '@rem cd ../c
  927. '@rem c_compiler\bin\g++ -mconsole -s -Wfatal-errors -w -Wall qbx.cpp  libqb\os\win\libqb_1_4_0000000001000.o  ..\..\.\internal\temp\icon.o -D DEPENDENCY_NO_SOCKETS -D DEPENDENCY_NO_PRINTER -D DEPENDENCY_ICON -D DEPENDENCY_NO_SCREENIMAGE   parts\core\os\win\src.a -lopengl32 -lglu32   -mwindows -static-libgcc -static-libstdc++ -D GLEW_STATIC -D FREEGLUT_STATIC     -lwinmm -lgdi32 -o "..\..\MASAKARI.exe"
  928. '@rem pause
  929.  
  930. 'rem We need to copy 3 files to qb64\internal\c
  931. 'rem dynamic name-and-content (name changes should get the one generated after QB64 -c MASAKARI.BAS from qb64\internal\c\libqb\os\win): libqb_1_4_0000000001000.o
  932. 'rem static name-and-content (take it from qb64\internal\temp): icon.o
  933. 'rem static name-and-content (take it from qb64\internal\c\parts\core\os\win): src.a
  934.  
  935. 'rem Should go to E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\c
  936. 'rem Assuming we are in the "home folder" i.e. qb64:
  937. 'cd internal\c
  938. 'g++ -mconsole -s -Wfatal-errors -w -Wall qbx.cpp  libqb_1_4_0000000001000.o  icon.o -D DEPENDENCY_NO_SOCKETS -D DEPENDENCY_NO_PRINTER -D DEPENDENCY_ICON -D DEPENDENCY_NO_SCREENIMAGE   src.a -lopengl32 -lglu32   -mwindows -static-libgcc -static-libstdc++ -D GLEW_STATIC -D FREEGLUT_STATIC     -lwinmm -lgdi32 -o "MASAKARI_mycompile.exe"
  939.  
  940. '@rem The output of above:
  941. '@rem
  942. '@rem E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64>MyCompile.bat
  943. '@rem
  944. '@rem E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64>cd internal\c
  945. '@rem
  946. '@rem E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\c>g++ -mconsole -s -Wfatal-errors -w -Wall qbx.cpp  libqb_1_4_0000000001000.o  icon.o -D DEPENDENCY_NO_SOCKETS -D DEPENDENCY_NO_PRINTER -D DEPENDENCY_ICON -D DEPENDENCY_NO_SCREENIMAGE   src.a -lopengl32 -lglu32   -mwindows -static-libgcc -static-libstdc++ -D GLEW_STATIC -D FREEGLUT_STATIC     -lwinmm -lgdi32 -o "MASAKARI_mycompile.exe"
  947. '@rem
  948. '@rem E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\c>dir masa*
  949. '@rem  Volume in drive E is Sanmayce_111GB
  950. '@rem  Volume Serial Number is 1410-10F9
  951. '@rem
  952. '@rem  Directory of E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\c
  953. '@rem
  954. '@rem 01/26/2021  06:11 AM         3,248,640 MASAKARI_mycompile.exe
  955. '@rem                1 File(s)      3,248,640 bytes
  956. '@rem                0 Dir(s)  36,627,079,168 bytes free
  957. '@rem
  958. '@rem
  959. '@rem E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\c>c:\WINDOWS\system32\fc MASAKARI_mycompile.exe ..\..\MASAKARI_original.exe /b
  960. '@rem Comparing files MASAKARI_mycompile.exe and ..\..\MASAKARI_ORIGINAL.EXE
  961. '@rem 00000088: 53 18
  962. '@rem 00000089: 96 93
  963. '@rem 000000D8: F9 BE
  964. '@rem 000000D9: A3 A0
  965. '@rem
  966. '@rem E:\_KAZE_Smxrt_Benchmarks\QB64_kit_v1.4_2.48 GB\qb64\internal\c>
  967.  
He learns not to learn and reverts to what all men pass by.

Offline Dav

  • Forum Resident
  • Posts: 792
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #25 on: January 26, 2021, 09:07:03 am »
Very thoughtfully written. Even takes into account displaying well on old laptops like mine.

Nice work.

- Dav

Offline Sanmayce

  • Newbie
  • Posts: 63
  • Where is that English Text Sidekick?
    • Sanmayce's home
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #26 on: January 26, 2021, 10:44:07 am »
Thank you @Dav ,
gradually will refine it, many things are to be tested, my goal is Linux and Windows variants to be identical.

Hope, after some weeks to share one functional tool, at least covering some must-have features, in the near future I envision merging all my C tools under the Masakari hood.
He learns not to learn and reverts to what all men pass by.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #27 on: January 26, 2021, 10:48:23 am »
Very thoughtfully written. Even takes into account displaying well on old laptops like mine.

Nice work.

- Dav

That, and I like his coding, too. I hope he sticks around after this project is completed. He was a good choice in this year's draft pick. And to think, we only had to trade Clippy for him!

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
    • Steve’s QB64 Archive Forum
Re: A skeleton code for Text Scroller via Drag-and-Drop
« Reply #28 on: January 26, 2021, 06:05:12 pm »
In order to have tons faster loading, loading in 5000+ seconds should be dropped to 5 seconds, a ton being a thousand, you know.

Here's some code for you to play around with:

Code: QB64: [Select]