'DIM m AS _MEM
a = 0
a = a + 1
'
' Originally: COUNTRY.BAS
' This program asks the user to select his country from a list.
' The user may press the UP and DOWN arrows or PAGE UP/PAGE DOWN
' or HOME/END keys to navigate the menu. The user may also start
' typing the name of his country to find it faster.
'
' Written by Zsolt Nagy-Perge in October 2018, Pensacola, Fla.
' <zsolt500n@gmail.com>
'
' Code adapted in file selector for loadimg.bas by Jason Page
' December 2018. This program generates a file containing
' all the pset commands needed to generate any image you put
' in the program. This is ideal to generate images using for
' example wwwbasic. This program will only work and compile
' using QB64. Visit QB64.org to use the free compiler/IDE
' <pagetelegram@gmail.com>
'
' QBasic 1.1 source code:
'
SELECTED = 3
'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"
MENU SELECTED
, "Files", list$
, "Please select your image file from the list below:"
CENTER
15, 10, "You picked : " + GETWORD$
(list$
, SELECTED
, 124)fle$
= GETWORD$
(list$
, SELECTED
, 124)
'img& = _LOADIMAGE(fle$, 32) 'load the image file to be drawn
'wide% = _WIDTH(img&): deep% = _HEIGHT(img&)
'TLC$ = "BL" + STR$(wide% \ 2) + "BU" + STR$(deep% \ 2) 'start draw at top left corner
'RET$ = "BD BL" + STR$(wide%) 'return to left side of image
'_SOURCE img&
'_DEST 0
'SHELL "echo. > pset.txt"
'OPEN "pset.txt" FOR OUTPUT AS #2
'CLS
'Tmp& = _NEWIMAGE(32, 32, 256)
'DO
' x = x + 1
'IF x > wide% THEN
'x = 0: y = y + 1
'END IF
'DRAW "C" + STR$(POINT(x, y)) + "R1" 'color and DRAW each pixel
'
'colour~& = POINT(x, y)
'c% = _RGB(_RED32(colour~&), _GREEN32(colour~&), _BLUE32(colour~&), Tmp&)
'clr = (c%) 'POINT(x, y) / (16553 * 256 * 16 * 8)
'x$ = STR$(x)
'y$ = STR$(y)
'clr$ = STR$(clr)
'PRINT #2, "pset(" + x$ + CHR$(44) + y$ + ")" + CHR$(44) + clr$
'LOCATE 2, 1: PRINT x, y
'PSET (x, y), clr
'LOOP UNTIL y >= deep%
'CLOSE #2
'LOCATE 22, 1
'PRINT "Saved as pset.txt"
'SLEEP 1
' Steve Contrib (SMcNeill):
'DIM c AS _UNSIGNED LONG 'color value of the pixels
'DIM ShortByte AS _UNSIGNED _BYTE, LongData AS _UNSIGNED LONG
'ShortByte = 0
''open a file for saving
'OPEN "databas.txt" FOR OUTPUT AS #1
'DO UNTIL finished
'count = 1 'count is the count of repetitive times a color appears in a row
'_MEMGET m, m.OFFSET + p * 4, c 'p is the current point
'IF p >= m.SIZE THEN
' finished = -1
'ELSE
' IF (p + count) * 4 >= m.SIZE THEN
' finished = -1
'ELSE
' DO UNTIL _MEMGET(m, m.OFFSET + (p + count) * 4, _UNSIGNED LONG) <> c
' count = count + 1
' IF (p + count) * 4 >= m.SIZE THEN finished = -1: count = count - 1: EXIT DO
'LOOP
'END IF
'END IF
'p = p + count
'r = _RED32(c): g = _GREEN32(c): b = _BLUE32(c)
'PRINT #1, "DATA "; r; ","; g; ","; b; ",";
'IF count > 255 THEN
' LongData = count
'PRINT #1, ShortByte; ","; LongData
'ELSE
' ShortByte = count
'PRINT #1, ShortByte
'END IF
'ShortByte = 0 'reset the default count to 0
'LOOP
'free resources
'CLOSE #1
'_MEMFREE m
' Example by Petr
image = n '_LOADIMAGE(fle$, 32)
outfile$ = "databas.txt"
OPEN outfile$
FOR OUTPUT AS #chan
'but binary access is much faster than input / output mode
_MEMGET m
, m.OFFSET
+ writeit
, colors
PRINT "Image saved as database.txt"
SUB MENU
(S
, TITLE$
, L$
, TEXT$
)
C0 = 0 ' Main window background pick:0-7
C1 = 7 ' Color 2 (FG) pick:0-7
C2 = 0 ' Color 1 (BG) pick:0-7
C3 = 15 ' Typing color pick:0-15
C4 = 12 ' Mistyped item color pick:0-15
C5 = 9 ' Title color (TITLE$) pick:0-15
C6 = 14 ' Description color (TEXT$) pick:0-15
ORIGINAL = S
' Display title.
CENTER C5, 2, TITLE$
' Display description text.
CENTER C6, 4, TEXT$
REDIM C$
(1 TO 250) ' <<< Array size may need to be modified.
' Split list into string array
P = 1
LL = 0 ' Longest line
F = P
C$
(I
) = MID$(L$
, F
, P
- F
) P = P + 1
' S = Selected Item
' LL = Longest line length
MM = I ' MM = Number of menu items
W$ = "" ' W$ = User typed search text
N = 0 ' N = User typed search text found?
F = 0 ' F = Vertical Display Offset
M = 8 ' M = Number of menu items to display on screen
TOP = 5 ' TOP = Top row where menu starts Y
' X = Start printing menu at pos X
' Displays a menu on the screen, and allows the user to select
' one item from the list. L$ should contain the list of menu items
' separated by the | character. S will hold the number of the
' selected menu item. If S is 5 at the beginning, this means the
' 5th item on the list is selected by default. If the user picks
' a different menu item and presses Enter, then S will change.
' If the user presses ESC, ALT+X or ALT+F4, S will be -1.
'
' Print menu items
Y = I * 2 + TOP
T$ = C$(I + F)
' Put lines or spaces among menu items
' Print search text
LOCATE 1, 1, 0 ' Turn off cursor
' Process search text
N = 0
W$ = W$ + K$
N = 1
S = G
W$ = ""
S = 1
F = 0
W$ = ""
S = MM
F = MM - M
W$ = ""
S = S - M
F = F - M
W$ = ""
S = S + M
F = F + M
W$ = ""
S = S - 1
W$ = ""
S = S + 1
IF S
>= F
+ I
- 1 THEN F
= F
+ 1
' Prints some text in the middle of the screen.
' We're assuming 80x25 color text mode.
SUB CENTER
(TEXTCOLOR
, ROW
, TEXT$
)
' This function returns the Nth word from a list.
' Words must be separated by the separator character S.
' S must hold the ASCII value of the character to be
' used as a separator character. i.e. S=32 means space
' Example:
' GETWORD$("apples peaches kiwi grapes", 1, 32) -> "apples"
' GETWORD$("apples/peaches/kiwi/grapes", 3, 47) -> "kiwi"
' GETWORD$("apples+peaches+kiwi+grapes", 9, 43) -> "" (out of range)
'
W = 0
F = 0
GETWORD$
= MID$(L$
, F
, I
- F
) F = 0
IF F
= 0 THEN F
= I: W
= W
+ 1 GETWORD$ = ""