Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pagetelegram

Pages: [1] 2
1
QB64 Discussion / Re: Compiler error due to memory limits
« on: December 18, 2018, 12:44:51 pm »
Here is your compiled program:

http://hand.is/alpha4000lines.zip

Works! used fbc!

2
QB64 Discussion / Re: Compiler error due to memory limits
« on: December 18, 2018, 12:36:17 pm »
Did you ever bother to try compiling using fbc, the FreeBasic compiler?

It will get you just what you want....small binary executable and it does compile your stuff when QB64 does not.

Or are you just trolling qb64 in-capabilities with your alphabet soup?

Someone posting your alphabet soup on this forum did crash the MySQL entry rendering this thread inaccessible, yesterday. :P

Fellippe came to the rescue doing some under the engine MySQL to delete that "malicious" alphabet soup of yours lol in the post reply.

For tinfoil=1 to 4000
shell "echo ? "+chr$(34)+"hat's off to you for crashing MySQL database yesterday with your secret 'burn after reading' program"+chr$(34)+" >> hat.bas"
next tinfoil

3
QB64 Discussion / Re: How do you guys keep track of your files?
« on: December 18, 2018, 09:21:01 am »
Pagetelegram: your mention of curl makes me suspect you might not have the full picture with how git works. git itself is just a local tool, all its internals for a project are kept in a .git folder in your project directory. You manipulate this and your project files with the `git` command (or one of the various gui frontends like sourcetree).

git alo has the ability to synchronise with a 'remote', which is just another git repository on a networked machine. This is what github, bitbucket, gitlab etc. are. You can do all your work locally then push (a git command) to send your work to github. Of course if you make it public this has the benefit of allowing other people to clone the repository and work with it.

Git on windows is... a little awkward to setup. On one hand the gui frontends makethe initial process easier, but I find they obscure the core behaviour of git. On the other hand the command line experience in windows is somewhat lacking. The installer gives the option of installing a cygwin shell which I'd recommend if you've any Unix experience, otherwise you'll just have to tough it out with the cmd version.

The basic "workflow" for a simple project: git init to create a new repository, then git add all your files and git commit. Then when you make a change you just add those files and commit to save them.
Syncing to github is just a git push, which uploads your commits. If you want to take a local backup too, all your committed changes are stored in the .git folder.

Thanks Luke,

I will try the CMD version, hopefully it doesn't require cygwin; hate to add overhead to my system; a huge library unnecessary to load if only using less than 1% of it. And I might write a basic shell program for operating the git command and helping to organize my programs better. Might also include a shell out to any number of editors to create the readme.md file on the spot.

4
Programs / Re: Convert image content to PSET expressions....
« on: December 17, 2018, 10:59:35 pm »
I get memory out of range error, using:

Code: QB64: [Select]
  1.     _MEMGET m, m.OFFSET + writeit, colors  

trying a 400x333 something image.

full program:

Code: QB64: [Select]
  1. DIM fil$(255)
  2. 'DIM m AS _MEM
  3. SHELL _HIDE "dir/b *.jpg > list.txt"
  4. SHELL _HIDE "dir/b *.png >> list.txt"
  5. SHELL _HIDE "dir/b *.bmp >> list.txt"
  6. SHELL _HIDE "dir/b *.gif >> list.txt"
  7. OPEN "list.txt" FOR INPUT AS #1
  8. a = 0
  9.     a = a + 1
  10.     IF NOT (EOF(1)) THEN INPUT #1, fil$(a) ELSE SYSTEM
  11.     list$ = list$ + fil$(a) + "|"
  12. '
  13. ' Originally: COUNTRY.BAS
  14. ' This program asks the user to select his country from a list.
  15. ' The user may press the UP and DOWN arrows or PAGE UP/PAGE DOWN
  16. ' or HOME/END keys to navigate the menu. The user may also start
  17. ' typing the name of his country to find it faster.
  18. '
  19. ' Written by Zsolt Nagy-Perge in October 2018, Pensacola, Fla.
  20. ' <zsolt500n@gmail.com>
  21. '
  22. ' Code adapted in file selector for loadimg.bas by Jason Page
  23. ' December 2018. This program generates a file containing
  24. ' all the pset commands needed to generate any image you put
  25. ' in the program. This is ideal to generate images using for
  26. ' example wwwbasic. This program will only work and compile
  27. ' using QB64. Visit QB64.org to use the free compiler/IDE
  28. ' <pagetelegram@gmail.com>
  29. '
  30. ' QBasic 1.1 source code:
  31. '
  32. DEFINT A-Z
  33. DECLARE SUB CENTER (TEXTCOLOR, ROW, TEXT$)
  34. DECLARE SUB MENU (S, TITLE$, L$, TEXT$)
  35. DECLARE FUNCTION GETWORD$ (L$, N, S)
  36.  
  37. SELECTED = 3
  38. 'list$ = "United States of America|Mexico|Canada|United Kingdom|Australia|Afghanistan|Albania|Algeria|Andorra|Angola|Anguilla|Antigua and Barbuda|Argentina|Armenia|Aruba|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bonaire|Bosnia and Herzegovina|Botswana|Brazil|British Virgin Islands|Brunei|Bulgaria|Burkina Faso|Burundi|Cabo Verde|Cambodia|Cameroon|Cayman Islands|Central African Republic|Chad|Chile|China|Clipperton Island|Colombia|Comoros|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Curacao|Cyprus|Czech Republic|Democratic Republic of the Congo|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Finland|France|French Polynesia|Gabon|Gambia|Georgia|Germany|Ghana|Greece|Greenland|Grenada|Guadeloupe|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Israel|Italy|Jamaica|Japan|Jordan|Kazakhstan|Kenya|Kiribati|Kosovo|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macedonia (FYROM)|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Martinique|Mauritania|Mauritius|Micronesia|Moldova|Monaco|Mongolia|Montenegro|Montserrat|Morocco|Mozambique|Myanmar (Burma)|Namibia|Nauru|Navassa Island|Nepal|Netherlands|New Zealand|Nicaragua|Niger|Nigeria|North Korea|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Poland|Portugal|Puerto Rico|Qatar|Republic of the Congo|Romania|Russia|Rwanda|Saba|Saint Barthelemy|Saint Kitts and Nevis|Saint Lucia|Saint Martin|Saint Pierre and Miquelon|Saint Vincent and the Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Singapore|Sint Eustatius|Sint Maarten|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Korea|South Sudan|Spain|Sri Lanka|Sudan|Suriname|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Timor-Leste|Togo|Tonga|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Turks and Caicos Islands|Tuvalu|Uganda|Ukraine|United Arab Emirates|Uruguay|US Virgin Islands|Uzbekistan|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe"
  39. MENU SELECTED, "Files", list$, "Please select your image file from the list below:"
  40.  
  41. CENTER 15, 10, "You picked :    " + GETWORD$(list$, SELECTED, 124)
  42. fle$ = GETWORD$(list$, SELECTED, 124)
  43.  
  44. SCREEN _NEWIMAGE(640, 480, 32)
  45.  
  46. 'img& = _LOADIMAGE(fle$, 32) 'load the image file to be drawn
  47.  
  48. n = _LOADIMAGE(fle$, 32)
  49. m = _MEMIMAGE(n) 'screen memory of image
  50.  
  51. 'wide% = _WIDTH(img&): deep% = _HEIGHT(img&)
  52. 'TLC$ = "BL" + STR$(wide% \ 2) + "BU" + STR$(deep% \ 2) 'start draw at top left corner
  53. 'RET$ = "BD BL" + STR$(wide%) 'return to left side of image
  54. '_SOURCE img&
  55. '_DEST 0
  56. 'SHELL "echo. > pset.txt"
  57. 'OPEN "pset.txt" FOR OUTPUT AS #2
  58. 'CLS
  59. 'Tmp& = _NEWIMAGE(32, 32, 256)
  60. 'DO
  61. '    x = x + 1
  62. 'IF x > wide% THEN
  63. 'x = 0: y = y + 1
  64. 'END IF
  65. 'DRAW "C" + STR$(POINT(x, y)) + "R1" 'color and DRAW each pixel
  66. '
  67. 'colour~& = POINT(x, y)
  68. 'c% = _RGB(_RED32(colour~&), _GREEN32(colour~&), _BLUE32(colour~&), Tmp&)
  69. 'clr = (c%) 'POINT(x, y) / (16553 * 256 * 16 * 8)
  70. 'x$ = STR$(x)
  71. 'y$ = STR$(y)
  72. 'clr$ = STR$(clr)
  73. 'PRINT #2, "pset(" + x$ + CHR$(44) + y$ + ")" + CHR$(44) + clr$
  74. 'LOCATE 2, 1: PRINT x, y
  75. 'PSET (x, y), clr
  76.  
  77. 'LOOP UNTIL y >= deep%
  78. 'CLOSE #2
  79. 'LOCATE 22, 1
  80. 'PRINT "Saved as pset.txt"
  81. 'SLEEP 1
  82.  
  83. ' Steve Contrib (SMcNeill):
  84.  
  85. 'DIM c AS _UNSIGNED LONG 'color value of the pixels
  86. 'DIM ShortByte AS _UNSIGNED _BYTE, LongData AS _UNSIGNED LONG
  87. 'ShortByte = 0
  88. SHELL _HIDE "echo. > databas.txt"
  89. ''open  a file for saving
  90. 'OPEN "databas.txt" FOR OUTPUT AS #1
  91.  
  92.  
  93. 'DO UNTIL finished
  94. 'count = 1 'count is the count of repetitive times a color appears in a row
  95. '_MEMGET m, m.OFFSET + p * 4, c 'p is the current point
  96. 'IF p >= m.SIZE THEN
  97. '    finished = -1
  98. 'ELSE
  99. '    IF (p + count) * 4 >= m.SIZE THEN
  100. '    finished = -1
  101. 'ELSE
  102. '    DO UNTIL _MEMGET(m, m.OFFSET + (p + count) * 4, _UNSIGNED LONG) <> c
  103. '    count = count + 1
  104. '    IF (p + count) * 4 >= m.SIZE THEN finished = -1: count = count - 1: EXIT DO
  105. 'LOOP
  106. 'END IF
  107. 'END IF
  108. 'p = p + count
  109. 'r = _RED32(c): g = _GREEN32(c): b = _BLUE32(c)
  110. 'PRINT #1, "DATA "; r; ","; g; ","; b; ",";
  111. 'IF count > 255 THEN
  112. '    LongData = count
  113. 'PRINT #1, ShortByte; ","; LongData
  114. 'ELSE
  115. '    ShortByte = count
  116. 'PRINT #1, ShortByte
  117. 'END IF
  118. 'ShortByte = 0 'reset the default count to 0
  119. 'LOOP
  120.  
  121. 'free resources
  122. 'CLOSE #1
  123. '_MEMFREE m
  124. ' Example by Petr
  125.  
  126. image = n '_LOADIMAGE(fle$, 32)
  127. outfile$ = "databas.txt"
  128. chan = FREEFILE
  129. OPEN outfile$ FOR OUTPUT AS #chan 'but binary access is much faster than input / output mode
  130. head$ = "DATA " + STR$(_WIDTH(image)) + "," + STR$(_HEIGHT(image))
  131. PRINT #chan, head$
  132.  
  133.  
  134. m = _MEMIMAGE(image)
  135.  
  136. FOR writeit = 0 TO _WIDTH(image) * _HEIGHT(image) * 4 - 4 STEP 4
  137.     _MEMGET m, m.OFFSET + writeit, colors
  138.     R = _RED32(colors): G = _GREEN32(colors): B = _BLUE32(colors)
  139.     d$ = "DATA " + STR$(R) + "," + STR$(G) + "," + STR$(B)
  140.     PRINT #chan, d$ '
  141. CLOSE #chan
  142.  
  143. LOCATE 23, 1
  144. PRINT "Image saved as database.txt"
  145.  
  146. SUB MENU (S, TITLE$, L$, TEXT$)
  147.  
  148.     C0 = 0 ' Main window background pick:0-7
  149.     C1 = 7 ' Color 2 (FG) pick:0-7
  150.     C2 = 0 ' Color 1 (BG) pick:0-7
  151.     C3 = 15 ' Typing color pick:0-15
  152.     C4 = 12 ' Mistyped item color pick:0-15
  153.     C5 = 9 ' Title color (TITLE$) pick:0-15
  154.     C6 = 14 ' Description color (TEXT$) pick:0-15
  155.  
  156.     ORIGINAL = S
  157.     SCREEN 0
  158.     WIDTH 80, 25
  159.     COLOR C1, C0
  160.     CLS
  161.  
  162.     ' Display title.
  163.     CENTER C5, 2, TITLE$
  164.  
  165.     ' Display description text.
  166.     CENTER C6, 4, TEXT$
  167.  
  168.     REDIM C$(1 TO 250) ' <<< Array size may need to be modified.
  169.  
  170.     ' Split list into string array
  171.     P = 1
  172.     LL = 0 ' Longest line
  173.     FOR I = 1 TO UBOUND(C$)
  174.         F = P
  175.         P = INSTR(P, L$, "|")
  176.         IF P < 1 THEN P = 9999
  177.         C$(I) = MID$(L$, F, P - F)
  178.         IF LL < LEN(C$(I)) THEN LL = LEN(C$(I))
  179.         IF P = 9999 THEN EXIT FOR
  180.         P = P + 1
  181.     NEXT I
  182.  
  183.     ' S   = Selected Item
  184.     ' LL  = Longest line length
  185.     MM = I ' MM  = Number of menu items
  186.     W$ = "" ' W$  = User typed search text
  187.     N = 0 ' N   = User typed search text found?
  188.     F = 0 ' F   = Vertical Display Offset
  189.     M = 8 ' M   = Number of menu items to display on screen
  190.     TOP = 5 ' TOP = Top row where menu starts Y
  191.     ' X   = Start printing menu at pos X
  192.     X = 33 - FIX(LL / 2)
  193.  
  194.  
  195.     ' Displays a menu on the screen, and allows the user to select
  196.     ' one item from the list. L$ should contain the list of menu items
  197.     ' separated by the | character. S will hold the number of the
  198.     ' selected menu item. If S is 5 at the beginning, this means the
  199.     ' 5th item on the list is selected by default. If the user picks
  200.     ' a different menu item and presses Enter, then S will change.
  201.     ' If the user presses ESC, ALT+X or ALT+F4, S will be -1.
  202.     '
  203.  
  204.  
  205.     DO
  206.         ' Print menu items
  207.         FOR I = 1 TO M
  208.             Y = I * 2 + TOP
  209.             IF S = I + F THEN
  210.                 COLOR C2, C1
  211.             ELSE
  212.                 COLOR C1, C2
  213.             END IF
  214.             T$ = C$(I + F)
  215.             LOCATE Y, X: PRINT SPACE$(5); T$; SPACE$(LL - LEN(T$) + 10);
  216.         NEXT I
  217.  
  218.         ' Put lines or spaces among menu items
  219.         FOR I = 1 TO M + 1
  220.             IF S = I + F THEN
  221.                 COLOR C1, C2
  222.             ELSEIF S = I + F - 1 THEN
  223.                 COLOR C2, C1
  224.             ELSE
  225.                 COLOR C2, C2
  226.             END IF
  227.             LOCATE I * 2 + TOP - 1, X: PRINT STRING$(LL + 15, CHR$(220));
  228.         NEXT I
  229.  
  230.         ' Print search text
  231.         IF N THEN COLOR C3, C2 ELSE COLOR C4, C2
  232.         Z$ = LEFT$(W$, 40)
  233.         LOCATE 24, 20: PRINT Z$; SPACE$(40 - LEN(Z$));
  234.         IF LEN(W$) THEN LOCATE 24, 20 + LEN(Z$), 1, 12, 13 ELSE LOCATE 1, 1, 0
  235.  
  236.         K$ = "": WHILE K$ = "": K$ = INKEY$: WEND
  237.  
  238.         LOCATE 1, 1, 0 ' Turn off cursor
  239.  
  240.         ' Process search text
  241.         N = 0
  242.         IF LEN(K$) = 1 THEN
  243.             U = ASC(UCASE$(K$))
  244.             IF LEN(W$) AND K$ = CHR$(8) THEN ' BACKSPACE
  245.                 W$ = LEFT$(W$, LEN(W$) - 1)
  246.             ELSEIF U = 32 OR U > 64 AND U < 91 OR (U > 47 AND U < 58) THEN ' TYPING
  247.                 W$ = W$ + K$
  248.             END IF
  249.             IF LEN(W$) THEN
  250.                 FOR G = 1 TO UBOUND(C$) ' FIND ITEM
  251.                     IF UCASE$(LEFT$(C$(G), LEN(W$))) = UCASE$(W$) THEN
  252.                         N = 1
  253.                         S = G
  254.                         IF S < F OR S > F + M THEN
  255.                             F = S - FIX(M / 2)
  256.                             IF F < 0 THEN F = 0
  257.                             IF F > MM - M THEN F = MM - M
  258.                         END IF
  259.                         EXIT FOR
  260.                     END IF
  261.                 NEXT G
  262.             END IF
  263.         END IF
  264.  
  265.         SELECT CASE K$
  266.             CASE CHR$(0) + "G": ' HOME
  267.                 W$ = ""
  268.                 S = 1
  269.                 F = 0
  270.             CASE CHR$(0) + "O": ' END
  271.                 W$ = ""
  272.                 S = MM
  273.                 F = MM - M
  274.                 IF F < 0 THEN F = 0
  275.             CASE CHR$(0) + "I": ' PGUP
  276.                 W$ = ""
  277.                 S = S - M
  278.                 F = F - M
  279.                 IF S < 1 THEN S = 1
  280.                 IF F < 0 THEN F = 0
  281.             CASE CHR$(0) + "Q": ' PGDN
  282.                 W$ = ""
  283.                 S = S + M
  284.                 F = F + M
  285.                 IF S > MM THEN S = MM
  286.                 IF F > MM - M THEN F = MM - M
  287.                 IF F < 0 THEN F = 0
  288.             CASE CHR$(0) + "H": ' UP ARROW
  289.                 W$ = ""
  290.                 IF S > 1 THEN
  291.                     S = S - 1
  292.                     IF S <= F THEN F = F - 1
  293.                 END IF
  294.             CASE CHR$(0) + "P": ' DOWN ARROW
  295.                 W$ = ""
  296.                 IF S < MM THEN
  297.                     S = S + 1
  298.                     IF S >= F + I - 1 THEN F = F + 1
  299.                 END IF
  300.             CASE CHR$(13): EXIT DO ' ENTER
  301.             CASE CHR$(0) + "K": EXIT DO ' LEFT ARROW
  302.             CASE CHR$(0) + "M": EXIT DO ' RIGHT ARROW
  303.             CASE CHR$(0) + "-": S = -1: EXIT DO ' ALT-X
  304.             CASE CHR$(0) + "k": S = -1: EXIT DO ' ALT-F4
  305.             CASE CHR$(27): S = -1: EXIT DO ' ESC
  306.         END SELECT
  307.     LOOP
  308.  
  309.     ERASE C$
  310.     COLOR 7, 0
  311.     CLS
  312.  
  313.  
  314. ' Prints some text in the middle of the screen.
  315. ' We're assuming 80x25 color text mode.
  316. SUB CENTER (TEXTCOLOR, ROW, TEXT$)
  317.     COLOR TEXTCOLOR
  318.     LOCATE ROW, 40 - FIX(LEN(TEXT$) / 2): PRINT TEXT$;
  319.  
  320. ' This function returns the Nth word from a list.
  321. ' Words must be separated by the separator character S.
  322. ' S must hold the ASCII value of the character to be
  323. ' used as a separator character. i.e. S=32 means space
  324. ' Example:
  325. '    GETWORD$("apples peaches kiwi grapes", 1, 32) -> "apples"
  326. '    GETWORD$("apples/peaches/kiwi/grapes", 3, 47) -> "kiwi"
  327. '    GETWORD$("apples+peaches+kiwi+grapes", 9, 43) -> "" (out of range)
  328. '
  329. FUNCTION GETWORD$ (L$, N, S)
  330.     LL = LEN(L$)
  331.     IF N < 1 OR N > LL / 2 + 2 THEN GETWORD$ = "": EXIT FUNCTION
  332.     W = 0
  333.     F = 0
  334.     FOR I = 1 TO LL + 1
  335.         IF I > LL THEN C = S ELSE C = ASC(MID$(L$, I, 1))
  336.         IF C = S THEN
  337.             IF F AND W = N THEN
  338.                 GETWORD$ = MID$(L$, F, I - F)
  339.                 EXIT FUNCTION
  340.             END IF
  341.             F = 0
  342.         ELSE
  343.             IF F = 0 THEN F = I: W = W + 1
  344.         END IF
  345.     NEXT I
  346.     GETWORD$ = ""
  347.  
  348.  

5
Programs / Re: Convert image content to PSET expressions....
« on: December 17, 2018, 10:06:58 pm »
Thank you!

I'll post final code and wwwbasic template example once I get it all working.

6
Programs / Re: Convert image content to PSET expressions....
« on: December 17, 2018, 08:28:41 pm »
Found this on an old forum on Pete's site:


color = 65536 * BLUE + 256 * GREEN + RED

wondering if that will work in wwwbasic the same.

7
QB64 Discussion / Re: My QB64 debut anniversary
« on: December 17, 2018, 06:23:53 pm »
QB64 is what re-woke my dusty DOS programming into the new world!

Thank you,

Maybe a history book should be in the works of everyone major behind the effort.

8
Programs / Re: Convert image content to PSET expressions....
« on: December 17, 2018, 06:18:50 pm »
Petr,

Nice though:

How do I do this in 1981 BASIC:

k = _RGB32(r, g, b)
        PSET (drawX, drawY), k

what exactly does RGB32(r,g,b) do under the hood in BASIC language?

9
QB64 Discussion / Re: A look to QB64 from the external of QB64 community
« on: December 17, 2018, 05:04:43 pm »

1. What do you think about how we seem to the WWW?
2. What is not present in our QB64 to let it appear a good enviroment of development today?

1. I googled around about 10 years ago and found it that way looking for a 32/64 bit way to compile my old 16 bit DOS programs bc you can't expect noobs to know how to use DOSbox etc.

2. For me, it is good development platform for command line level. I have not tried the form option yet and I'm not too interested in it either. Everything just works better in DOS.

Also the introduction of the _STATEMENTS have expanded the use of the programming to modern application/device support

What I would like to see is audio sound card Input and Soft-Modem i/o use. Most audio stuff supported is only output.

10
Programs / Re: Convert image content to PSET expressions....
« on: December 17, 2018, 04:32:57 pm »
Thank you,

Program now works, after debugging some other obvious issues.

Code: QB64: [Select]
  1. DIM fil$(255)
  2. SHELL _HIDE "dir/b *.jpg > list.txt"
  3. SHELL _HIDE "dir/b *.png >> list.txt"
  4. SHELL _HIDE "dir/b *.bmp >> list.txt"
  5. SHELL _HIDE "dir/b *.gif >> list.txt"
  6. OPEN "list.txt" FOR INPUT AS #1
  7. a = 0
  8.     a = a + 1
  9.     IF NOT (EOF(1)) THEN INPUT #1, fil$(a) ELSE SYSTEM
  10.     list$ = list$ + fil$(a) + "|"
  11. '
  12. ' Originally: COUNTRY.BAS
  13. ' This program asks the user to select his country from a list.
  14. ' The user may press the UP and DOWN arrows or PAGE UP/PAGE DOWN
  15. ' or HOME/END keys to navigate the menu. The user may also start
  16. ' typing the name of his country to find it faster.
  17. '
  18. ' Written by Zsolt Nagy-Perge in October 2018, Pensacola, Fla.
  19. ' <zsolt500n@gmail.com>
  20. '
  21. ' Code adapted in file selector for loadimg.bas by Jason Page
  22. ' December 2018. This program generates a file containing
  23. ' all the pset commands needed to generate any image you put
  24. ' in the program. This is ideal to generate images using for
  25. ' example wwwbasic. This program will only work and compile
  26. ' using QB64. Visit QB64.org to use the free compiler/IDE
  27. ' <pagetelegram@gmail.com>
  28. '
  29. ' QBasic 1.1 source code:
  30. '
  31. DEFINT A-Z
  32. DECLARE SUB CENTER (TEXTCOLOR, ROW, TEXT$)
  33. DECLARE SUB MENU (S, TITLE$, L$, TEXT$)
  34. DECLARE FUNCTION GETWORD$ (L$, N, S)
  35.  
  36. SELECTED = 3
  37. 'list$ = "United States of America|Mexico|Canada|United Kingdom|Australia|Afghanistan|Albania|Algeria|Andorra|Angola|Anguilla|Antigua and Barbuda|Argentina|Armenia|Aruba|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bonaire|Bosnia and Herzegovina|Botswana|Brazil|British Virgin Islands|Brunei|Bulgaria|Burkina Faso|Burundi|Cabo Verde|Cambodia|Cameroon|Cayman Islands|Central African Republic|Chad|Chile|China|Clipperton Island|Colombia|Comoros|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Curacao|Cyprus|Czech Republic|Democratic Republic of the Congo|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Finland|France|French Polynesia|Gabon|Gambia|Georgia|Germany|Ghana|Greece|Greenland|Grenada|Guadeloupe|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Israel|Italy|Jamaica|Japan|Jordan|Kazakhstan|Kenya|Kiribati|Kosovo|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macedonia (FYROM)|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Martinique|Mauritania|Mauritius|Micronesia|Moldova|Monaco|Mongolia|Montenegro|Montserrat|Morocco|Mozambique|Myanmar (Burma)|Namibia|Nauru|Navassa Island|Nepal|Netherlands|New Zealand|Nicaragua|Niger|Nigeria|North Korea|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Poland|Portugal|Puerto Rico|Qatar|Republic of the Congo|Romania|Russia|Rwanda|Saba|Saint Barthelemy|Saint Kitts and Nevis|Saint Lucia|Saint Martin|Saint Pierre and Miquelon|Saint Vincent and the Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Singapore|Sint Eustatius|Sint Maarten|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Korea|South Sudan|Spain|Sri Lanka|Sudan|Suriname|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Timor-Leste|Togo|Tonga|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Turks and Caicos Islands|Tuvalu|Uganda|Ukraine|United Arab Emirates|Uruguay|US Virgin Islands|Uzbekistan|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe"
  38. MENU SELECTED, "Files", list$, "Please select your image file from the list below:"
  39.  
  40. CENTER 15, 10, "You picked :    " + GETWORD$(list$, SELECTED, 124)
  41. fle$ = GETWORD$(list$, SELECTED, 124)
  42.  
  43. SCREEN _NEWIMAGE(640, 480, 32)
  44.  
  45. img& = _LOADIMAGE(fle$, 32) 'load the image file to be drawn
  46. n = _LOADIMAGE(fle$, 32)
  47. m = _MEMIMAGE(n) 'screen memory of image
  48.  
  49. wide% = _WIDTH(img&): deep% = _HEIGHT(img&)
  50. TLC$ = "BL" + STR$(wide% \ 2) + "BU" + STR$(deep% \ 2) 'start draw at top left corner
  51. RET$ = "BD BL" + STR$(wide%) 'return to left side of image
  52. _SOURCE img&
  53. SHELL "echo. > pset.txt"
  54. OPEN "pset.txt" FOR OUTPUT AS #2
  55. Tmp& = _NEWIMAGE(32, 32, 256)
  56.     x = x + 1
  57.     IF x > wide% THEN
  58.         x = 0: y = y + 1
  59.     END IF
  60.     DRAW "C" + STR$(POINT(x, y)) + "R1" 'color and DRAW each pixel
  61.  
  62.     colour~& = POINT(x, y)
  63.     c% = _RGB(_RED32(colour~&), _GREEN32(colour~&), _BLUE32(colour~&), Tmp&)
  64.     clr = (c%) 'POINT(x, y) / (16553 * 256 * 16 * 8)
  65.     x$ = STR$(x)
  66.     y$ = STR$(y)
  67.     clr$ = STR$(clr)
  68.     PRINT #2, "pset(" + x$ + CHR$(44) + y$ + ")" + CHR$(44) + clr$
  69.     'LOCATE 2, 1: PRINT x, y
  70.     PSET (x, y), clr
  71.  
  72. LOOP UNTIL y >= deep%
  73. LOCATE 22, 1
  74. PRINT "Saved as pset.txt"
  75.  
  76. ' Steve Contrib:
  77.  
  78. DIM c AS _UNSIGNED LONG 'color value of the pixels
  79. DIM ShortByte AS _UNSIGNED _BYTE, LongData AS _UNSIGNED LONG
  80. ShortByte = 0
  81. SHELL _HIDE "echo. > databas.txt"
  82. 'open  a file for saving
  83. OPEN "databas.txt" FOR OUTPUT AS #1
  84.  
  85.  
  86. DO UNTIL finished
  87.     count = 1 'count is the count of repetitive times a color appears in a row
  88.     _MEMGET m, m.OFFSET + p * 4, c 'p is the current point
  89.     IF p >= m.SIZE THEN
  90.         finished = -1
  91.     ELSE
  92.         IF (p + count) * 4 >= m.SIZE THEN
  93.             finished = -1
  94.         ELSE
  95.             DO UNTIL _MEMGET(m, m.OFFSET + (p + count) * 4, _UNSIGNED LONG) <> c
  96.                 count = count + 1
  97.                 IF (p + count) * 4 >= m.SIZE THEN finished = -1: count = count - 1: EXIT DO
  98.             LOOP
  99.         END IF
  100.     END IF
  101.     p = p + count
  102.     r = _RED32(c): g = _GREEN32(c): b = _BLUE32(c)
  103.     PRINT #1, "DATA "; r; ","; g; ","; b; ",";
  104.     IF count > 255 THEN
  105.         LongData = count
  106.         PRINT #1, ShortByte; ","; LongData
  107.     ELSE
  108.         ShortByte = count
  109.         PRINT #1, ShortByte
  110.     END IF
  111.     ShortByte = 0 'reset the default count to 0
  112.  
  113. 'free resources
  114. LOCATE 23, 1
  115. PRINT "Image saved as database.txt"
  116.  
  117. SUB MENU (S, TITLE$, L$, TEXT$)
  118.  
  119.     C0 = 0 ' Main window background pick:0-7
  120.     C1 = 7 ' Color 2 (FG) pick:0-7
  121.     C2 = 0 ' Color 1 (BG) pick:0-7
  122.     C3 = 15 ' Typing color pick:0-15
  123.     C4 = 12 ' Mistyped item color pick:0-15
  124.     C5 = 9 ' Title color (TITLE$) pick:0-15
  125.     C6 = 14 ' Description color (TEXT$) pick:0-15
  126.  
  127.     ORIGINAL = S
  128.     SCREEN 0
  129.     WIDTH 80, 25
  130.     COLOR C1, C0
  131.     CLS
  132.  
  133.     ' Display title.
  134.     CENTER C5, 2, TITLE$
  135.  
  136.     ' Display description text.
  137.     CENTER C6, 4, TEXT$
  138.  
  139.     REDIM C$(1 TO 250) ' <<< Array size may need to be modified.
  140.  
  141.     ' Split list into string array
  142.     P = 1
  143.     LL = 0 ' Longest line
  144.     FOR I = 1 TO UBOUND(C$)
  145.         F = P
  146.         P = INSTR(P, L$, "|")
  147.         IF P < 1 THEN P = 9999
  148.         C$(I) = MID$(L$, F, P - F)
  149.         IF LL < LEN(C$(I)) THEN LL = LEN(C$(I))
  150.         IF P = 9999 THEN EXIT FOR
  151.         P = P + 1
  152.     NEXT I
  153.  
  154.     ' S   = Selected Item
  155.     ' LL  = Longest line length
  156.     MM = I ' MM  = Number of menu items
  157.     W$ = "" ' W$  = User typed search text
  158.     N = 0 ' N   = User typed search text found?
  159.     F = 0 ' F   = Vertical Display Offset
  160.     M = 8 ' M   = Number of menu items to display on screen
  161.     TOP = 5 ' TOP = Top row where menu starts Y
  162.     ' X   = Start printing menu at pos X
  163.     X = 33 - FIX(LL / 2)
  164.  
  165.  
  166.     ' Displays a menu on the screen, and allows the user to select
  167.     ' one item from the list. L$ should contain the list of menu items
  168.     ' separated by the | character. S will hold the number of the
  169.     ' selected menu item. If S is 5 at the beginning, this means the
  170.     ' 5th item on the list is selected by default. If the user picks
  171.     ' a different menu item and presses Enter, then S will change.
  172.     ' If the user presses ESC, ALT+X or ALT+F4, S will be -1.
  173.     '
  174.  
  175.  
  176.     DO
  177.         ' Print menu items
  178.         FOR I = 1 TO M
  179.             Y = I * 2 + TOP
  180.             IF S = I + F THEN
  181.                 COLOR C2, C1
  182.             ELSE
  183.                 COLOR C1, C2
  184.             END IF
  185.             T$ = C$(I + F)
  186.             LOCATE Y, X: PRINT SPACE$(5); T$; SPACE$(LL - LEN(T$) + 10);
  187.         NEXT I
  188.  
  189.         ' Put lines or spaces among menu items
  190.         FOR I = 1 TO M + 1
  191.             IF S = I + F THEN
  192.                 COLOR C1, C2
  193.             ELSEIF S = I + F - 1 THEN
  194.                 COLOR C2, C1
  195.             ELSE
  196.                 COLOR C2, C2
  197.             END IF
  198.             LOCATE I * 2 + TOP - 1, X: PRINT STRING$(LL + 15, CHR$(220));
  199.         NEXT I
  200.  
  201.         ' Print search text
  202.         IF N THEN COLOR C3, C2 ELSE COLOR C4, C2
  203.         Z$ = LEFT$(W$, 40)
  204.         LOCATE 24, 20: PRINT Z$; SPACE$(40 - LEN(Z$));
  205.         IF LEN(W$) THEN LOCATE 24, 20 + LEN(Z$), 1, 12, 13 ELSE LOCATE 1, 1, 0
  206.  
  207.         K$ = "": WHILE K$ = "": K$ = INKEY$: WEND
  208.  
  209.         LOCATE 1, 1, 0 ' Turn off cursor
  210.  
  211.         ' Process search text
  212.         N = 0
  213.         IF LEN(K$) = 1 THEN
  214.             U = ASC(UCASE$(K$))
  215.             IF LEN(W$) AND K$ = CHR$(8) THEN ' BACKSPACE
  216.                 W$ = LEFT$(W$, LEN(W$) - 1)
  217.             ELSEIF U = 32 OR U > 64 AND U < 91 OR (U > 47 AND U < 58) THEN ' TYPING
  218.                 W$ = W$ + K$
  219.             END IF
  220.             IF LEN(W$) THEN
  221.                 FOR G = 1 TO UBOUND(C$) ' FIND ITEM
  222.                     IF UCASE$(LEFT$(C$(G), LEN(W$))) = UCASE$(W$) THEN
  223.                         N = 1
  224.                         S = G
  225.                         IF S < F OR S > F + M THEN
  226.                             F = S - FIX(M / 2)
  227.                             IF F < 0 THEN F = 0
  228.                             IF F > MM - M THEN F = MM - M
  229.                         END IF
  230.                         EXIT FOR
  231.                     END IF
  232.                 NEXT G
  233.             END IF
  234.         END IF
  235.  
  236.         SELECT CASE K$
  237.             CASE CHR$(0) + "G": ' HOME
  238.                 W$ = ""
  239.                 S = 1
  240.                 F = 0
  241.             CASE CHR$(0) + "O": ' END
  242.                 W$ = ""
  243.                 S = MM
  244.                 F = MM - M
  245.                 IF F < 0 THEN F = 0
  246.             CASE CHR$(0) + "I": ' PGUP
  247.                 W$ = ""
  248.                 S = S - M
  249.                 F = F - M
  250.                 IF S < 1 THEN S = 1
  251.                 IF F < 0 THEN F = 0
  252.             CASE CHR$(0) + "Q": ' PGDN
  253.                 W$ = ""
  254.                 S = S + M
  255.                 F = F + M
  256.                 IF S > MM THEN S = MM
  257.                 IF F > MM - M THEN F = MM - M
  258.                 IF F < 0 THEN F = 0
  259.             CASE CHR$(0) + "H": ' UP ARROW
  260.                 W$ = ""
  261.                 IF S > 1 THEN
  262.                     S = S - 1
  263.                     IF S <= F THEN F = F - 1
  264.                 END IF
  265.             CASE CHR$(0) + "P": ' DOWN ARROW
  266.                 W$ = ""
  267.                 IF S < MM THEN
  268.                     S = S + 1
  269.                     IF S >= F + I - 1 THEN F = F + 1
  270.                 END IF
  271.             CASE CHR$(13): EXIT DO ' ENTER
  272.             CASE CHR$(0) + "K": EXIT DO ' LEFT ARROW
  273.             CASE CHR$(0) + "M": EXIT DO ' RIGHT ARROW
  274.             CASE CHR$(0) + "-": S = -1: EXIT DO ' ALT-X
  275.             CASE CHR$(0) + "k": S = -1: EXIT DO ' ALT-F4
  276.             CASE CHR$(27): S = -1: EXIT DO ' ESC
  277.         END SELECT
  278.     LOOP
  279.  
  280.     ERASE C$
  281.     COLOR 7, 0
  282.     CLS
  283.  
  284.  
  285. ' Prints some text in the middle of the screen.
  286. ' We're assuming 80x25 color text mode.
  287. SUB CENTER (TEXTCOLOR, ROW, TEXT$)
  288.     COLOR TEXTCOLOR
  289.     LOCATE ROW, 40 - FIX(LEN(TEXT$) / 2): PRINT TEXT$;
  290.  
  291. ' This function returns the Nth word from a list.
  292. ' Words must be separated by the separator character S.
  293. ' S must hold the ASCII value of the character to be
  294. ' used as a separator character. i.e. S=32 means space
  295. ' Example:
  296. '    GETWORD$("apples peaches kiwi grapes", 1, 32) -> "apples"
  297. '    GETWORD$("apples/peaches/kiwi/grapes", 3, 47) -> "kiwi"
  298. '    GETWORD$("apples+peaches+kiwi+grapes", 9, 43) -> "" (out of range)
  299. '
  300. FUNCTION GETWORD$ (L$, N, S)
  301.     LL = LEN(L$)
  302.     IF N < 1 OR N > LL / 2 + 2 THEN GETWORD$ = "": EXIT FUNCTION
  303.     W = 0
  304.     F = 0
  305.     FOR I = 1 TO LL + 1
  306.         IF I > LL THEN C = S ELSE C = ASC(MID$(L$, I, 1))
  307.         IF C = S THEN
  308.             IF F AND W = N THEN
  309.                 GETWORD$ = MID$(L$, F, I - F)
  310.                 EXIT FUNCTION
  311.             END IF
  312.             F = 0
  313.         ELSE
  314.             IF F = 0 THEN F = I: W = W + 1
  315.         END IF
  316.     NEXT I
  317.     GETWORD$ = ""
  318.  

11
QB64 Discussion / Re: Compiler error due to memory limits
« on: December 17, 2018, 03:55:12 pm »
OP, you kind of sound a bit like me on one point I think we can relate: with your expression that "every byte was worth it's weight in gold." I could concur with that, that Moore's law has led to bloat in my opinion.

However I also concur to William Strunk's philosophy to "omit needless words," in the Elements of Style even though I maybe better at that as a writer than  as a programmer.

With programming, I'm a tad bit lazy to think about organization and making code easily understandable by others with well put remarks and variable names that make sense.

12
QB64 Discussion / Re: How big is yours?
« on: December 17, 2018, 03:35:22 pm »
My Lottery programs are only 3000 line max, but my data for them can extend to 10,000 lines depending on how many draws have been made and how far back I go, generally I go back at least 5 years. Russ

Lottery program?

Anything like this ?

http://pagetelegram.com/piball.html


A lot less lines than 4k tho.

13
QB64 Discussion / Re: Compiler error due to memory limits
« on: December 17, 2018, 03:21:42 pm »
Ryster,

Use FreeBasic! With that compiler every byte does counts! Instead of a 1.5mb+ QB64 compile you get your old DOS sized 40kb+ compiled executable.

Just put
Code: QB64: [Select]
  1. #lang "qb"
  2.  

at the top of your code and compile away!


https://www.freebasic.net/

14
Programs / Re: Convert image content to PSET expressions....
« on: December 17, 2018, 03:16:09 pm »
Steve, I do not want to screen grab just load from file.

I'm lost in this new method unable to feasibly translate from old method.

The problem I have is in the '_MEM' method, which I do not understand.

Here is the code I have so far in my initial attempt to adapt:

Code: QB64: [Select]
  1. DIM fil$(255)
  2. SHELL _HIDE "dir/b *.jpg > list.txt"
  3. SHELL _HIDE "dir/b *.png >> list.txt"
  4. SHELL _HIDE "dir/b *.bmp >> list.txt"
  5. SHELL _HIDE "dir/b *.gif >> list.txt"
  6. OPEN "list.txt" FOR INPUT AS #1
  7. a = 0
  8.     a = a + 1
  9.     IF NOT (EOF(1)) THEN INPUT #1, fil$(a) ELSE SYSTEM
  10.     list$ = list$ + fil$(a) + "|"
  11. '
  12. ' COUNTRY.BAS
  13. ' This program asks the user to select his country from a list.
  14. ' The user may press the UP and DOWN arrows or PAGE UP/PAGE DOWN
  15. ' or HOME/END keys to navigate the menu. The user may also start
  16. ' typing the name of his country to find it faster.
  17. '
  18. ' Written by Zsolt Nagy-Perge in October 2018, Pensacola, Fla.
  19. ' <zsolt500n@gmail.com>
  20. '
  21. ' Code adapted in file selector for loadimg.bas by Jason Page
  22. ' December 2018. This program generates a file containing
  23. ' all the pset commands needed to generate any image you put
  24. ' in the program. This is ideal to generate images using for
  25. ' example wwwbasic. This program will only work and compile
  26. ' using QB64. Visit QB64.org to use the free compiler/IDE
  27. ' <pagetelegram@gmail.com>
  28. '
  29. ' QBasic 1.1 source code:
  30. '
  31. DEFINT A-Z
  32. DECLARE SUB CENTER (TEXTCOLOR, ROW, TEXT$)
  33. DECLARE SUB MENU (S, TITLE$, L$, TEXT$)
  34. DECLARE FUNCTION GETWORD$ (L$, N, S)
  35.  
  36. SELECTED = 3
  37. 'list$ = "United States of America|Mexico|Canada|United Kingdom|Australia|Afghanistan|Albania|Algeria|Andorra|Angola|Anguilla|Antigua and Barbuda|Argentina|Armenia|Aruba|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bonaire|Bosnia and Herzegovina|Botswana|Brazil|British Virgin Islands|Brunei|Bulgaria|Burkina Faso|Burundi|Cabo Verde|Cambodia|Cameroon|Cayman Islands|Central African Republic|Chad|Chile|China|Clipperton Island|Colombia|Comoros|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Curacao|Cyprus|Czech Republic|Democratic Republic of the Congo|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Finland|France|French Polynesia|Gabon|Gambia|Georgia|Germany|Ghana|Greece|Greenland|Grenada|Guadeloupe|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Israel|Italy|Jamaica|Japan|Jordan|Kazakhstan|Kenya|Kiribati|Kosovo|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macedonia (FYROM)|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Martinique|Mauritania|Mauritius|Micronesia|Moldova|Monaco|Mongolia|Montenegro|Montserrat|Morocco|Mozambique|Myanmar (Burma)|Namibia|Nauru|Navassa Island|Nepal|Netherlands|New Zealand|Nicaragua|Niger|Nigeria|North Korea|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Poland|Portugal|Puerto Rico|Qatar|Republic of the Congo|Romania|Russia|Rwanda|Saba|Saint Barthelemy|Saint Kitts and Nevis|Saint Lucia|Saint Martin|Saint Pierre and Miquelon|Saint Vincent and the Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Singapore|Sint Eustatius|Sint Maarten|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Korea|South Sudan|Spain|Sri Lanka|Sudan|Suriname|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Timor-Leste|Togo|Tonga|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Turks and Caicos Islands|Tuvalu|Uganda|Ukraine|United Arab Emirates|Uruguay|US Virgin Islands|Uzbekistan|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe"
  38. MENU SELECTED, "Files", list$, "Please select your image file from the list below:"
  39.  
  40. CENTER 15, 10, "You picked :    " + GETWORD$(list$, SELECTED, 124)
  41. fle$ = GETWORD$(list$, SELECTED, 124)
  42.  
  43. SCREEN _NEWIMAGE(640, 480, 32)
  44.  
  45. img& = _LOADIMAGE(fle$, 32) 'load the image file to be drawn
  46. wide% = _WIDTH(img&): deep% = _HEIGHT(img&)
  47. TLC$ = "BL" + STR$(wide% \ 2) + "BU" + STR$(deep% \ 2) 'start draw at top left corner
  48. RET$ = "BD BL" + STR$(wide%) 'return to left side of image
  49. _SOURCE img&
  50. SHELL "echo. > image.txt"
  51. OPEN "pset.txt" FOR OUTPUT AS #2
  52. Tmp& = _NEWIMAGE(32, 32, 256)
  53.     x = x + 1
  54.     IF x > wide% THEN
  55.         x = 0: y = y + 1
  56.     END IF
  57.     DRAW "C" + STR$(POINT(x, y)) + "R1" 'color and DRAW each pixel
  58.  
  59.     colour~& = POINT(x, y)
  60.     c% = _RGB(_RED32(colour~&), _GREEN32(colour~&), _BLUE32(colour~&), Tmp&)
  61.     clr = (c%) 'POINT(x, y) / (16553 * 256 * 16 * 8)
  62.     x$ = STR$(x)
  63.     y$ = STR$(y)
  64.     clr$ = STR$(clr)
  65.     PRINT #2, "pset(" + x$ + CHR$(44) + y$ + ")" + CHR$(44) + clr$
  66.     'LOCATE 2, 1: PRINT x, y
  67.     PSET (x, y), clr
  68.  
  69.     ' Steve Contrib:
  70.  
  71.     'SCREEN _NEWIMAGE(640, 480, 32)
  72.     'RANDOMIZE TIMER
  73.     'CLS , _RGB32(RND * 255, RND * 255, RND * 255)
  74.     'draw a few boxes
  75.     'FOR i = 1 TO 3
  76.     'LINE (RND * 640, RND * 480)-(RND * 640, RND * 480), _RGB32(RND * 255, RND * 255, RND * 255), BF
  77.     'NEXT
  78.  
  79.     'Now do a screen grab
  80.     DIM m AS _MEM
  81.     ' m = _MEMIMAGE(0) 'screen memory of image
  82.     m = _LOADIMAGE(fle$, 32)
  83.  
  84.     DIM c AS _UNSIGNED LONG 'color value of the pixels
  85.     DIM ShortByte AS _UNSIGNED _BYTE, LongData AS _UNSIGNED LONG
  86.     ShortByte = 0
  87.  
  88.     'open  a file for saving
  89.     OPEN "databas.txt" FOR OUTPUT AS #3
  90.  
  91.  
  92.     DO UNTIL finished
  93.         count = 1 'count is the count of repetitive times a color appears in a row
  94.         _MEMGET m, m.OFFSET + p * 4, c 'p is the current point
  95.         IF p >= m.SIZE THEN
  96.             finished = -1
  97.         ELSE
  98.             IF (p + count) * 4 >= m.SIZE THEN
  99.                 finished = -1
  100.             ELSE
  101.                 DO UNTIL _MEMGET(m, m.OFFSET + (p + count) * 4, _UNSIGNED LONG) <> c
  102.                     count = count + 1
  103.                     IF (p + count) * 4 >= m.SIZE THEN finished = -1: count = count - 1: EXIT DO
  104.                 LOOP
  105.             END IF
  106.         END IF
  107.         p = p + count
  108.         r = _RED32(c): g = _GREEN32(c): b = _BLUE32(c)
  109.         PRINT #3, "DATA "; r; ","; g; ","; b; ",";
  110.         IF count > 255 THEN
  111.             LongData = count
  112.             PRINT #1, ShortByte; ","; LongData
  113.         ELSE
  114.             ShortByte = count
  115.             PRINT #1, ShortByte
  116.         END IF
  117.         ShortByte = 0 'reset the default count to 0
  118.     LOOP
  119.  
  120.     'free resources
  121.     CLOSE #3
  122.     _MEMFREE m
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. LOOP UNTIL y >= deep%
  130. PRINT "Saved as image.txt"
  131.  
  132. SUB MENU (S, TITLE$, L$, TEXT$)
  133.  
  134.     C0 = 0 ' Main window background pick:0-7
  135.     C1 = 7 ' Color 2 (FG) pick:0-7
  136.     C2 = 0 ' Color 1 (BG) pick:0-7
  137.     C3 = 15 ' Typing color pick:0-15
  138.     C4 = 12 ' Mistyped item color pick:0-15
  139.     C5 = 9 ' Title color (TITLE$) pick:0-15
  140.     C6 = 14 ' Description color (TEXT$) pick:0-15
  141.  
  142.     ORIGINAL = S
  143.     SCREEN 0
  144.     WIDTH 80, 25
  145.     COLOR C1, C0
  146.     CLS
  147.  
  148.     ' Display title.
  149.     CENTER C5, 2, TITLE$
  150.  
  151.     ' Display description text.
  152.     CENTER C6, 4, TEXT$
  153.  
  154.     REDIM C$(1 TO 250) ' <<< Array size may need to be modified.
  155.  
  156.     ' Split list into string array
  157.     P = 1
  158.     LL = 0 ' Longest line
  159.     FOR I = 1 TO UBOUND(C$)
  160.         F = P
  161.         P = INSTR(P, L$, "|")
  162.         IF P < 1 THEN P = 9999
  163.         C$(I) = MID$(L$, F, P - F)
  164.         IF LL < LEN(C$(I)) THEN LL = LEN(C$(I))
  165.         IF P = 9999 THEN EXIT FOR
  166.         P = P + 1
  167.     NEXT I
  168.  
  169.     ' S   = Selected Item
  170.     ' LL  = Longest line length
  171.     MM = I ' MM  = Number of menu items
  172.     W$ = "" ' W$  = User typed search text
  173.     N = 0 ' N   = User typed search text found?
  174.     F = 0 ' F   = Vertical Display Offset
  175.     M = 8 ' M   = Number of menu items to display on screen
  176.     TOP = 5 ' TOP = Top row where menu starts Y
  177.     ' X   = Start printing menu at pos X
  178.     X = 33 - FIX(LL / 2)
  179.  
  180.     DO
  181.         ' Print menu items
  182.         FOR I = 1 TO M
  183.             Y = I * 2 + TOP
  184.             IF S = I + F THEN
  185.                 COLOR C2, C1
  186.             ELSE
  187.                 COLOR C1, C2
  188.             END IF
  189.             T$ = C$(I + F)
  190.             LOCATE Y, X: PRINT SPACE$(5); T$; SPACE$(LL - LEN(T$) + 10);
  191.         NEXT I
  192.  
  193.         ' Put lines or spaces among menu items
  194.         FOR I = 1 TO M + 1
  195.             IF S = I + F THEN
  196.                 COLOR C1, C2
  197.             ELSEIF S = I + F - 1 THEN
  198.                 COLOR C2, C1
  199.             ELSE
  200.                 COLOR C2, C2
  201.             END IF
  202.             LOCATE I * 2 + TOP - 1, X: PRINT STRING$(LL + 15, CHR$(220));
  203.         NEXT I
  204.  
  205.         ' Print search text
  206.         IF N THEN COLOR C3, C2 ELSE COLOR C4, C2
  207.         Z$ = LEFT$(W$, 40)
  208.         LOCATE 24, 20: PRINT Z$; SPACE$(40 - LEN(Z$));
  209.         IF LEN(W$) THEN LOCATE 24, 20 + LEN(Z$), 1, 12, 13 ELSE LOCATE 1, 1, 0
  210.  
  211.         K$ = "": WHILE K$ = "": K$ = INKEY$: WEND
  212.  
  213.         LOCATE 1, 1, 0 ' Turn off cursor
  214.  
  215.         ' Process search text
  216.         N = 0
  217.         IF LEN(K$) = 1 THEN
  218.             U = ASC(UCASE$(K$))
  219.             IF LEN(W$) AND K$ = CHR$(8) THEN ' BACKSPACE
  220.                 W$ = LEFT$(W$, LEN(W$) - 1)
  221.             ELSEIF U = 32 OR U > 64 AND U < 91 OR (U > 47 AND U < 58) THEN ' TYPING
  222.                 W$ = W$ + K$
  223.             END IF
  224.             IF LEN(W$) THEN
  225.                 FOR G = 1 TO UBOUND(C$) ' FIND ITEM
  226.                     IF UCASE$(LEFT$(C$(G), LEN(W$))) = UCASE$(W$) THEN
  227.                         N = 1
  228.                         S = G
  229.                         IF S < F OR S > F + M THEN
  230.                             F = S - FIX(M / 2)
  231.                             IF F < 0 THEN F = 0
  232.                             IF F > MM - M THEN F = MM - M
  233.                         END IF
  234.                         EXIT FOR
  235.                     END IF
  236.                 NEXT G
  237.             END IF
  238.         END IF
  239.  
  240.         SELECT CASE K$
  241.             CASE CHR$(0) + "G": ' HOME
  242.                 W$ = ""
  243.                 S = 1
  244.                 F = 0
  245.             CASE CHR$(0) + "O": ' END
  246.                 W$ = ""
  247.                 S = MM
  248.                 F = MM - M
  249.                 IF F < 0 THEN F = 0
  250.             CASE CHR$(0) + "I": ' PGUP
  251.                 W$ = ""
  252.                 S = S - M
  253.                 F = F - M
  254.                 IF S < 1 THEN S = 1
  255.                 IF F < 0 THEN F = 0
  256.             CASE CHR$(0) + "Q": ' PGDN
  257.                 W$ = ""
  258.                 S = S + M
  259.                 F = F + M
  260.                 IF S > MM THEN S = MM
  261.                 IF F > MM - M THEN F = MM - M
  262.                 IF F < 0 THEN F = 0
  263.             CASE CHR$(0) + "H": ' UP ARROW
  264.                 W$ = ""
  265.                 IF S > 1 THEN
  266.                     S = S - 1
  267.                     IF S <= F THEN F = F - 1
  268.                 END IF
  269.             CASE CHR$(0) + "P": ' DOWN ARROW
  270.                 W$ = ""
  271.                 IF S < MM THEN
  272.                     S = S + 1
  273.                     IF S >= F + I - 1 THEN F = F + 1
  274.                 END IF
  275.             CASE CHR$(13): EXIT DO ' ENTER
  276.             CASE CHR$(0) + "K": EXIT DO ' LEFT ARROW
  277.             CASE CHR$(0) + "M": EXIT DO ' RIGHT ARROW
  278.             CASE CHR$(0) + "-": S = -1: EXIT DO ' ALT-X
  279.             CASE CHR$(0) + "k": S = -1: EXIT DO ' ALT-F4
  280.             CASE CHR$(27): S = -1: EXIT DO ' ESC
  281.         END SELECT
  282.     LOOP
  283.  
  284.     ERASE C$
  285.     COLOR 7, 0
  286.     CLS
  287.  
  288.  
  289. ' Prints some text in the middle of the screen.
  290. ' We're assuming 80x25 color text mode.
  291. SUB CENTER (TEXTCOLOR, ROW, TEXT$)
  292.     COLOR TEXTCOLOR
  293.     LOCATE ROW, 40 - FIX(LEN(TEXT$) / 2): PRINT TEXT$;
  294.  
  295. ' This function returns the Nth word from a list.
  296. ' Words must be separated by the separator character S.
  297. ' S must hold the ASCII value of the character to be
  298. ' used as a separator character. i.e. S=32 means space
  299. ' Example:
  300. '    GETWORD$("apples peaches kiwi grapes", 1, 32) -> "apples"
  301. '    GETWORD$("apples/peaches/kiwi/grapes", 3, 47) -> "kiwi"
  302. '    GETWORD$("apples+peaches+kiwi+grapes", 9, 43) -> "" (out of range)
  303. '
  304. FUNCTION GETWORD$ (L$, N, S)
  305.     LL = LEN(L$)
  306.     IF N < 1 OR N > LL / 2 + 2 THEN GETWORD$ = "": EXIT FUNCTION
  307.     W = 0
  308.     F = 0
  309.     FOR I = 1 TO LL + 1
  310.         IF I > LL THEN C = S ELSE C = ASC(MID$(L$, I, 1))
  311.         IF C = S THEN
  312.             IF F AND W = N THEN
  313.                 GETWORD$ = MID$(L$, F, I - F)
  314.                 EXIT FUNCTION
  315.             END IF
  316.             F = 0
  317.         ELSE
  318.             IF F = 0 THEN F = I: W = W + 1
  319.         END IF
  320.     NEXT I
  321.     GETWORD$ = ""
  322.  
  323. ' Displays a menu on the screen, and allows the user to select
  324. ' one item from the list. L$ should contain the list of menu items
  325. ' separated by the | character. S will hold the number of the
  326. ' selected menu item. If S is 5 at the beginning, this means the
  327. ' 5th item on the list is selected by default. If the user picks
  328. ' a different menu item and presses Enter, then S will change.
  329. ' If the user presses ESC, ALT+X or ALT+F4, S will be -1.
  330. '
  331.  

15
QB64 Discussion / Re: How big is yours?
« on: December 17, 2018, 02:38:59 pm »
433 lines: Benford Bench.

Touched up on it on and off for 6 years. It is a digital analysis program using Benford's Law.

https://www.qb64.org/basbin/4B4B.txt

I developed it for my groups primary use to investigate time stamps of in election log data for Chicago to demonstrate admissibility of it's method for fraud detection.

I use this program and another team member uses his program in Fox Pro to solidify results.

Trouble is finding a control pool.

Pages: [1] 2