Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 748
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 29
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 28
|
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 1,888
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,198
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 309
|
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 118
|
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,319
|
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 235
|
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 139
|
|
|
Color picker bug or just something I'm missing |
Posted by: OldMoses - 08-09-2023, 05:35 PM - Forum: Help Me!
- Replies (8)
|
|
I don't see a dialog box "Title" that I assign. It just calls it "Color". Otherwise, it works fine.
Code: (Select All) SCREEN _NEWIMAGE(1024, 512, 32)
a~& = _COLORCHOOSERDIALOG("Flood", &HFF000000)
COLOR , a~&
CLS
t~& = _COLORCHOOSERDIALOG("Word", &HFFFFFFFF)
COLOR t~&
LOCATE 10, 10
PRINT "This is your color scheme"
END
|
|
|
Charlie posting too much BAM at Retro |
Posted by: bplus - 08-05-2023, 03:07 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (26)
|
|
Charlie shame on you for posting over 50% materials at Retro! (I am being totally sarcastic. Shame on them in my eyes! for criticizing you for being so prolific, my goodness most forums love you when you are so active!). And like you complained doing this publicly is pretty nasty too, just lets jokers like me see and make fun of them though.
Don't you know not to post more than Ron77? LOL this is so funny to me, but I hate how you are being treated!
|
|
|
A Perplexing Issue |
Posted by: NakedApe - 08-03-2023, 03:47 PM - Forum: Help Me!
- Replies (5)
|
|
This sub took me hours to get going because it's behaving so strangely. It's a simple routine to print out some info, but it won't work unless an INPUT statement is used at the end, not an INPUT$() or INKEY$. Even SLEEP causes the sub not to run right. My first choice is for the user just to press a single key and exit the sub, but only the input statement works right - which requires a carriage return. I don't get it. Any help will be much appreciated! See remarks below...
SUB destTable () '
SHARED destData() AS STRING
SHARED destCounter AS INTEGER
SHARED fuel AS SINGLE
DIM range AS SINGLE
DIM AS INTEGER counter, entry, entries(20) '
DIM n AS STRING
range = fuel / 35.29 ' fuel / rate of burn per light year
counter = 0
_FONT messFont: COLOR YELLOW
n = _TRIM$(MID$(STR$(range), 1, 5))
_PRINTSTRING (30, 40), "Destinations Within Present Range" + " (" + n + " Light Years)"
DO
counter = counter + 1
IF range >= VAL(destData(counter, 3)) THEN ' if range is greater than distance to destination...
entry = entry + 1
entries(entry) = counter
_FONT messFont: COLOR ORANGE
_PRINTSTRING (30, 66 + entry * 25), CHR$(64 + entry) + ") " + destData(counter, 1) '
_FONT courseFont: COLOR GREEN
_PRINTSTRING (340, 70 + entry * 25), destData(counter, 2)
_FONT courseFont: COLOR PINK
_PRINTSTRING (580, 72 + entry * 25), destData(counter, 3) + " Light Years"
END IF
LOOP UNTIL counter = 20
_FONT messFont: COLOR YELLOW
_PRINTSTRING (40, 138 + entry * 25), "Your Destination Choice is"
LOCATE 30, 344
INPUT n ' <======= !! reuse n string
' n = INPUT$(1) ' ALL THESE REMMED COMMANDS CAUSE THE ABOVE NOT TO DISPLAY TO SCREEN
' WHILE INKEY$ = "": n = INKEY$: WEND ' UNTIL *AFTER* USER PRESSES A KEY
' DO: n = INKEY$: LOOP UNTIL n <> "" ' only an INPUT statement gets the above table to print ...
' SLEEP ... otherwise program freezes w/o performing above code until key is hit, then the table appears for a sec
counter = ASC(n) - 96 ' reuse counter
destCounter = entries(counter) '
pickDest
END SUB
|
|
|
SVG lines to micro(A) string array initialization |
Posted by: mnrvovrfc - 08-03-2023, 07:51 AM - Forum: QBJS, BAM, and Other BASICs
- Replies (2)
|
|
This is a program that processes an SVG file and creates code for micro(A). This attempts to "steal" coordinates in millimeters of a "plain" SVG file and present them into strings of run-on 4-digit numbers, which are X and Y absolute coordinate pairs. The values will have to be scaled for a graphics screen according to the maximum dimensions out of the SVG. It looks like the graphics screen of micro(A) is 780x570.
This could probably be done with "sodipodi" format, which is that of Inkscape, but it's not recommended. That program could insert a lot of transformation commands which would make for an uneven picture, and this effort by a hobbyist doesn't provision for that.
N.B. The SVG is expected to have relative coordinates, except the first point of each path. But this is translated into code which employs absolute coordinates. Directly copying from the original document to a QB64 graphics program requires PSET or something else to anchor, then "LINE" with "STEP" option to draw things relatively.
The run-on strings will have sequences of "99999999". This is a reset which means a new shape will begin with the next point listed, and should not connect with the previous coordinate that was obtained. I had to do it this way because micro(A) doesn't process strings very well. Originally it was going to be a string check for "######" for three-digit coordinates. This program shouldn't be used for very large vector pictures anyway.
I had to make more edits to the program to account for "z" at the end of path command. However this could come up with missing lines. I will need more time to look into this.
As it stands, this does not produce useable running micro(A) code, it only creates a couple of array variables and initializes them. I should also offer some simple code in micro(A) to put the lines together for the drawing. But my cohort protested. :/ But why since it's only "line" statements to use? In fact this could be translated into a QB64 or any BASIC program that supports graphics and has a line-drawing statement supporting absolute coordinates.
I got a bit lazy with this program. I was supposed to add Dav's routine to get filenames on Linux or Windows and display them in a nice box in SCREEN 0, and allow this for any version of QB64. Instead if you don't have Phoenix Edition v3.4 or later, you will have to type in a filename for a file that exists inside "(home)/Pictures". Including the directories. This is hard-coded. Yes I know it should be better.
Despite this caveat, this code should run on QB64 v2.0 and up. It does nothing fancy except parse a few values in text format.
There are more explanations as comments in the source code.
Neat trick of the QB64 IDE! It makes "pale" the code that the "conditional" decides doesn't apply for "$IF... THEN... $ELSE... $END IF".
User "roquedrivel" from "BASIC4US" forum helped with this program.
Code: (Select All)
'by mnrvovrfc 3-Aug-2023
'this needs extensive testing because Inkscape keeps mixing absolute and relative coordinates.
'it doesn't matter between "sodipodi" or "plain" SVG.
'GIMP exports paths in absolute coordinates only, but is clunkier to work with.
'this would be easier with relative coordinates only, with the first
' "m" command of a path having the only absolute coordinate.
'it helps sometimes setting, before creating any document:
' Preferences/Input and Output/SVG Output/Paths: choose "relative" from menu.
'this works with lines only! Not bezier paths! Any bezier paths need to have the
' two control points reset: press [N] to choose node tool,
' select the node then the first choice
' on the toolbar for path nodes on the top of the screen.
'one more thing: from a plain SVG the measurement
' is in millimeters *NOT* in pixels!
'This program is meant to be run from the terminal!
'It's up to you to select the terminal text, copy and then paste into a text editor
' or into micro(A)'s editor. Then keep developing the script from there.
'If this is not satisfactory then the user is free to add code
' to create an output file.
$CONSOLE:ONLY
OPTION _EXPLICIT
DIM SHARED sf(1 TO 20) AS STRING, sl(1 TO 20) AS STRING
DIM AS DOUBLE xx, yy, x0, y0, x1, y1
DIM AS LONG fe, x, y, u, v, gh, coma
DIM AS INTEGER g, h
DIM apath$, afile$, dee$, a$, c$, qu$, entry$
DIM f AS _BYTE, lut AS _BYTE
qu$ = CHR$(34)
h = 1
g = 0
gh = 0
sf(h) = "st[" + _TRIM$(STR$(h)) + "] = " + qu$
dee$ = " d=" + qu$
$IF WIN THEN
apath$ = environ$("USERPROFILE") + "\Pictures\"
$ELSE
apath$ = ENVIRON$("HOME") + "/Pictures/"
'/" let's see if this fixes the "qb" code block bug on forum
$END IF
$IF VERSION < 3.4 THEN
'sorry Dav's file list routine was supposed to be here...
' but that would require "direntry.h"
PRINT "The current path now is "; apath$
PRINT "Please type in the name of an SVG file to load."
LINE INPUT afile$
IF afile$ = "" THEN SYSTEM
afile$ = apath$ + afile$
IF NOT _FILEEXISTS(afile$) THEN
PRINT "Unable to proceed!"
PRINT "File not found: "; afile$
END IF
$ELSE
afile$ = _OPENFILEDIALOG$("Please choose an SVG file.", apath$, "*.svg", "Plain SVG")
IF afile$ = "" THEN SYSTEM
$END IF
fe = FREEFILE
OPEN afile$ FOR INPUT AS fe
DO UNTIL EOF(fe)
LINE INPUT #fe, entry$
u = INSTR(entry$, dee$)
IF u THEN
lut = 0
x = -1E+6
y = -1E+6
xx = 0
yy = 0
c$ = ""
a$ = ""
entry$ = MID$(entry$, LEN(dee$) + u)
entry$ = LEFT$(entry$, LEN(entry$) - 1)
PRINT entry$
'trying to squash a bug where it refuses to read the final pair
entry$ = entry$ + " "
sf(h) = sf(h) + "99999999"
gh = gh + 8
g = g + 1
v = 1
u = INSTR(entry$, " ")
DO WHILE u
a$ = MID$(entry$, v, u - v)
'must make sure there are lines only here.
'might also have to check "M" and "m", this only assumes "m" at beginning
' is absolute coordinate.
'this cannot handle "h" nor "v", requires manual editing of SVG file or a
' search-and-replace conversion in this program.
'at last moment I had to make a provision for "z" which means draw a line,
' going back to the first (absolute) point of the path.
IF a$ = "L" THEN lut = 1
IF a$ = "l" THEN lut = 0
IF a$ = "z" THEN EXIT DO
IF LEN(a$) <> 1 THEN
coma = INSTR(a$, ",")
x1 = VAL(LEFT$(a$, coma - 1))
y1 = VAL(MID$(a$, coma + 1))
IF x = -1E+6 AND y = -1E+6 THEN
x0 = x1
y0 = y1
xx = x1
yy = y1
x = INT(xx)
y = INT(yy)
ELSEIF lut THEN
xx = x1
yy = y1
ELSE
xx = xx + x1
yy = yy + y1
END IF
outtheline
END IF
v = u + 1
u = INSTR(v, entry$, " ")
LOOP
IF RIGHT$(entry$, 3) = " z " THEN
xx = x0
yy = y0
outtheline
END IF
PRINT "---"
END IF
LOOP
CLOSE fe
sf(h) = sf(h) + qu$
a$ = _TRIM$(STR$(h))
sl(h) = "sl[" + a$ + "] =" + STR$(gh)
PRINT "var i, j, x1, y1, x2, y2, xscale, yscale, xmove, first, stnumele"
PRINT "str a, b"
PRINT "str st["; a$; "]"
PRINT "var sl["; a$; "]"
FOR g = 1 TO h
PRINT sf(g)
PRINT sl(g)
NEXT
PRINT "stnumele ="; h + 1
PRINT "xscale = 1"
PRINT "yscale = 1"
PRINT "xmove = 0"
PRINT "wcolor 0, 0, 0"
PRINT "fcolor 255, 255, 255"
PRINT "i = 1"
PRINT "label lb02"
PRINT " j = 1"
PRINT " label lb03"
PRINT " x1 = x2"
PRINT " y1 = y2"
PRINT " b = st[i]"
PRINT " a = mstr(b, j, 4)"
PRINT " x2 = val(a)"
PRINT " if x2 = 9999"
PRINT " first = 1"
PRINT " j = j + 8"
PRINT " goto cb03"
PRINT " endif"
PRINT " x2 = x2 * xscale"
PRINT " x2 = x2 + xmove"
PRINT " j = j + 4"
PRINT " b = st[i]"
PRINT " a = mstr(b, j, 4)"
PRINT " y2 = val(a)"
PRINT " y2 = y2 * yscale"
PRINT " if first = 0"
PRINT " line x1, y1, x2, y2"
PRINT " endif"
PRINT " if first = 1 : first = 0 : endif"
PRINT " j = j + 4"
PRINT "label cb03"
PRINT " if j < sl[i] : goto lb03 : endif"
PRINT "i = i + 1"
PRINT "if i < stnumele : goto lb02 : endif"
PRINT "swap"
SYSTEM
SUB outtheline ()
SHARED AS LONG x, y, gh
SHARED AS DOUBLE xx, yy
SHARED AS INTEGER g, h
SHARED qu$
DIM hs$
x = INT(xx)
y = INT(yy)
PRINT x; ","; y
sf(h) = sf(h) + Zeroes$(x, 4) + Zeroes$(y, 4)
gh = gh + 8
g = g + 1
IF g >= 80 THEN
hs$ = _TRIM$(STR$(h))
sf(h) = sf(h) + qu$
sl(h) = "sl[" + hs$ + "] =" + STR$(gh)
gh = 0
g = 0
h = h + 1
hs$ = _TRIM$(STR$(h))
sf(h) = "st[" + hs$ + "] = " + qu$
END IF
END SUB
FUNCTION Zeroes$ (num AS LONG, numdig AS INTEGER)
DIM b$, v AS LONG
DIM AS INTEGER sg, hx
IF num < 0 THEN sg = -1: num = num * -1
IF numdig < 0 THEN hx = 1: numdig = numdig * -1 ELSE hx = 0
IF hx THEN
b$ = HEX$(num)
ELSE
b$ = LTRIM$(STR$(num))
END IF
v = numdig - LEN(b$)
IF v > 0 THEN b$ = STRING$(v, 48) + b$
IF sg = -1 THEN b$ = "-" + b$
Zeroes$ = b$
END FUNCTION
|
|
|
|