- sbasici.exe - My original port of SmallBASIC that I abandoned several years ago but recently brought back to life using FLTK 1.4.
That's great Chris, thanks - numpad keys work as expected. I don't have to keep remembering to use the numbers above the main keys now. Thanks also for the clarification of the files. I'm sticking with the SDL g64 version for now for those fast graphics on my Windows 7.
Another oddity I noticed is that the arrow keys give ASCII 27, same as the Escape key. Is that how it should be?
' Get key codes.bas SmallBASIC 0.12.9 (B+=MGA) 2017-12-18
WHILE 1 'find code for keypress
k$ = INKEY
IF LEN(k$) THEN
SELECT CASE LEN(k$)
CASE 1: PRINT "1 char keypress = "; ASC(k$)
IF ASC(k$) = 27 THEN EXIT loop
CASE 2: PRINT "2 char keypress = "; ASC(RIGHT$(k$, 1))
END SELECT
END IF
WEND
asc(left(k$,1)),
and yes, it's the escape 27.but a big request of mine would be if inkey could be speeded up. Its slow speed makes it unusable in any kind of real-time control situation like a game.
but a big request of mine would be if inkey could be speeded up. Its slow speed makes it unusable in any kind of real-time control situation like a game.
Hi..I don't understand. I want to know more about this "inkey". How slow is the "inkey"? Any example? Thanks.
'Updated Plasmatic with Full Color Mixing.bas translated to SmallBASIC b+ 2020-01-24
' from QB64 "Color Mixing 4 Plasmatic" ' b+ 2020-01-23
' continued study of what makes Plasmatic tick,
' here the color palette is updated for full range of color mixing options,
' PLUS I think color band creation for palette has been a little demystified,
' PLUS more fully commented code.
' common shared unchanging variables and static arrays
const xxmax = 500 'need smaller screen for interpreted Basic
const yymax = 400
const xoff = (xmax - xxmax) \ 2
const yoff = (ymax - yymax) \ 2
dim c(360), p(6), f(6)
'start program
randomize timer
label restart 'select rgb1 and rgb2 based on mode of color mixing
IF mode = 0 THEN 'new plasma option ANY color for border and ANY color for middle
r1 = RND * 255: g1 = RND * 255: b1 = RND * 255: r2 = RND * 255: g2 = RND * 255: b2 = RND * 255
ELSE ' traditional high contrast plasma black borders, white centers
r1 = 0: g1 = 0: b1 = 0: r2 = 255: g2 = 255: b2 = 255 'regular Plasma
END IF
'create 6 x 60 bands of color palette based on coloring mode (rgb1 set and rgb2 set)
FOR i = 0 TO 360
IF i MOD 60 = 0 THEN r = RND * 255: g = RND * 255: b = RND * 255 'start new color band
m = i MOD 60 'color bands have width of 60, 4 stages
if m < 15 then ' 1st stage increase rgb1 towards rgb color in 15 steps
c(i) = midInk(r1, g1, b1, r, g, b, m / 15)
elif m < 30 ' 2nd stage increase rgb color towards rgb2 set in 15 steps
c(i) = midInk(r, g, b, r2, g2, b2, (m - 15) / 15)
elif m < 45 ' 3rd stage decrease rgb2 color back to rgb color in 15 steps
c(i) = midInk(r2, g2, b2, r, g, b, (m - 30) / 15)
elif m < 60 ' 4th and finally decrease rgb back to starting rgb1 set in 15 steps
c(i) = midInk(r, g, b, r1, g1, b1, (m - 45) / 15)
END if
NEXT
' behind the scenes variables for motion, weighting and shaping color mixing
FOR n = 0 TO 5
p(n).x = RND * xxmax: p(n).y = RND * yymax: p(n).dx = RND * 2 - 1: p(n).dy = RND * 2 - 1 'create points
f(n) = .1 * RND ' create the inverse size and weight factor, large f = small globs but carry weight
NEXT
'screen labeling 3 lines for title above, 2 lines instruction below
cls
at xoff, yoff - 60
if mode = 0 then
CP yoff - 60, "New Color Options for Plasma:"
else
CP yoff - 60, "Traditional High Contrast Plasma: Black Borders and White Centers"
end if
CP yoff - 40, "Borders: RGB(" + str(r1 \ 1) + ", " + str(g1 \ 1) + ", " + str(b1 \ 1) + ")"
CP yoff - 20, "Centers: RGB(" + str(r2 \ 1) + ", " + str(g2 \ 1) + ", " + str(b2 \ 1) + ")"
CP yoff + yymax + 10, "Press t to toggle between Traditional and New Color Options Plasma"
CP yoff + yymax + 30, "Press spacebar to get a new color set."
'plasma in motion
WHILE 1
'get user input choices
' Here! Check out Plasmatic with and without INKEY
k = INKEY '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
IF k = " " THEN GOTO restart
'if k = "q" or asc(k) = 27 then end
'IF k = "t" THEN mode = 1 - mode: GOTO restart
'move points
FOR i = 0 TO 5
p(i).x = p(i).x + p(i).dx
IF p(i).x > xxmax OR p(i).x < 0 THEN p(i).dx = -p(i).dx
p(i).y = p(i).y + p(i).dy
IF p(i).y > yymax OR p(i).y < 0 THEN p(i).dy = -p(i).dy
NEXT
'calculate each screen x, y color based on distance to 6 points
FOR y = 0 TO yymax - 1 STEP 3
FOR x = 0 TO xxmax - 1 STEP 3
d = 0
FOR n = 0 TO 5
dx = x - p(n).x: dy = y - p(n).y
k = SQR(dx * dx + dy * dy)
d = d + (SIN(k * f(n)) + 1) / 2
NEXT n: d = d * 60
rect x + xoff, y + yoff STEP 3, 3, c(d) filled
NEXT
NEXT
'showpage 'guess this not needed might work better without
WEND
'report the color number between rgb1 and rgb2 at fraction fr from rgb1
func midInk(r1, g1, b1, r2, g2, b2, fr)
midInk = rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)
end
'Center Print at topYpixel down from top
sub CP(topYpixel, stringg)
at (xmax - txtw(stringg))/2, topYpixel :print stringg
end sub
On my system with INKEY this graphics intense program runs a bit slower and more jerky. But I have to say this is not as bad as it once was. PS run on v sbasicg64.exeHi round157, here's a better example for being a bit simpler. It's also the basis of many games where you use A,Z and <> to control something. I could name at least one other language where you'd have to put delays in to stop it whizzing off the screen before you know where you are.but a big request of mine would be if inkey could be speeded up. Its slow speed makes it unusable in any kind of real-time control situation like a game.
Hi..I don't understand. I want to know more about this "inkey". How slow is the "inkey"? Any example? Thanks.
REM SmallBASIC
REM created: 24/03/2020
x=xmax\2:y=ymax\2
? "INKEY speed test. Use a,z and <> keys to move '@' - see how fast it is?"
? "To compare (random motion) without the inkey statement, hit q."
? "There's still a select case, in the loop, but a random slice of 'az,.' instead of inkey."
? "Or make it a constant of your choice to see it just go in one direction."
repeat
k=inkey
at x,y,:? " "
select case k
case "a":y--
case "z":y++
case ",":x--
case ".":x++
end select
at x,y:? "@"
showpage
until k="q"
repeat
at x,y:? " "
k=mid("az,.",(rnd*4)+1,1)
' k=","
select case k
case "a":y--
case "z":y++
case ",":x--
case ".":x++
end select
at x,y:? "@"
showpage
until 0
end
Hi,
Another report: forget adding this feature to the sbasici.exe.
https://www.syntaxbomb.com/index.php/topic,6677.msg33355.html#msg33355
here's a better example for being a bit simpler.
Hi,
Another report: forget adding this feature to the sbasici.exe.
https://www.syntaxbomb.com/index.php/topic,6677.msg33355.html#msg33355
I've created an issue for this: https://github.com/smallbasic/SmallBASIC/issues/93
Hey I wonder if that is what slows down the editor version from FKLT, inkey has to be on all the time. eh?
BTW using the editor may be really slow testing runs but much more pleasant for editing with tabbed files and Help access right there, but Aurel's should have that maybe more but no help access.
Hmm, yes, thanks, maybe that's all it is. It is of course dependent on the typematic delay, but it will also depend on the speed the interpreter processes the command. Maybe it's as fast as it should be, whatever that means, I was just surprised that I can't write code with flow control via some keys in the way I expected. However, I checked out the same kind of test in BBC BASIC for Windows, and that wasn't any better.here's a better example for being a bit simpler.
I have tried your example. The problem of "Inkey" is typematic delay: when I press a key but don't release, the "@" will move one step, then will stop a moment, then will move again. I see, "@" did not move continuously. It is a problem.
sbasicg.exe -- It is an editor with dark texts(dark green, dark grey, etc.) and black background. Therefore, it is hard to view. If colours can be changed, this editor will be suitable for editing.
Did you see this? Scroll down to "How to help design a better looking editor color theme" https://smallbasic.github.io/pages/sdl.html
Cheers,
Hmm, yes, thanks, maybe that's all it is. It is of course dependent on the typematic delay, but it will also depend on the speed the interpreter processes the command. Maybe it's as fast as it should be, whatever that means, I was just surprised that I can't write code with flow control via some keys in the way I expected. However, I checked out the same kind of test in BBC BASIC for Windows, and that wasn't any better.
Cheers,
Cheers,
Hi...
Another proposal: add this feature to the next version of sbasicg.exe: make EXE file -- pack sbasicg.exe and one source code file into one single executable file.
Two purposes:
1. SmallBASIC users can distribute their finished programs to end-users easily.
2. Source code will not be viewed easily by end-users. Thus source code will be protected.
Cheers,
Hi...
Another proposal: add this feature to the next version of sbasicg.exe: make EXE file -- pack sbasicg.exe and one source code file into one single executable file.
Two purposes:
1. SmallBASIC users can distribute their finished programs to end-users easily.
2. Source code will not be viewed easily by end-users. Thus source code will be protected.
It's a lot of work building a compiler for an interpreter!
Hi... I didn't mean "compile". Not "compile". I said "pack". I meant "embed" or "attach". I try to explain with my insufficient knowledge:
QuoteHi... I didn't mean "compile". Not "compile". I said "pack". I meant "embed" or "attach". I try to explain with my insufficient knowledge:
Oh yeah! the SDLBasic method, OK now I understand. Crypt the bas source, and attach to the end of a special version of SB that tells itself to find the encrypted part of itself at the end of normal SB.exe, decrypt and run that decryption, piece of cake! ;-)
Cheers,
Cheers,
@authorI noticed that. I can't find anything, and it would be useful, but you can use the goto method.
Is there something like "continue" (skip a for-loop iteration)? Referece/language does not yield any such.
Still have a little proposal:
It is about sbasicg.exe. Assume source code has setsize() command, for example:
w = window()
w.setsize(640, 480)
Run the source code. Right-click. Select 'Back' in the menu. The source code page comes back. However, the source code page is still in 640x480. The source code page is not in the original size(maximum size). sbasicg.exe forgets changing the source code page's size back to the original size(maximum size).
Thanks.
ox=xmax:oy=ymax
w = window()
w.setsize(640, 480)
?
? "Click/key to close"
pause
w.setsize(ox,oy)
end
It doesn't automatically reset the size (for instance, in an error situation) and you still have to end the program after resetting the size to the original.REM SmallBASIC
REM created: 09/04/2020
' create the window object, this provides access to a number of sub-commands
w = window()
' select graphics mode screen 1 for output
w.graphicsScreen1()
for i = 0 to 10
print "this is printed on screen 1"
next i
w.message("1 click to continue. ")
pause
' select graphics mode screen 1 for output
w.graphicsScreen2()
color 1,3
cls
print "this is printed on screen 2"
w.message("2 click to continue. ")
pause
w.graphicsScreen1()
print "back to screen 1"
w.message("3 click to continue. ")
pause
' select the text mode for output
' text mode can display more text but is slow
' also this is currently broken and will cause a crash
'w.textScreen()
w.alert("This is an alert", "title")
w.ask("Yes or no?", "Question")
print "your answer was "; w.answer
w.message("4 click to continue. ")
pause
w.menu("option1", "option2", "option3")
' weirdly the result is sent to the keyboard handler
' it should at least go to w.answer. also there is no option for placement
select case asc(inkey)
case 0
print "one"
case 1
print "two"
case 2
print "three"
case else
print "unk"
end select
w.message("5 click to continue. ")
pause
' this raises the virtual keypad on android
w.showKeypad()
' set the font size
' arg1 = size
' arg2 = unit amount for size, "px" or "em"
' px= pixels
' em= emphasis - this is a multiplication factor for the current size
' arg3= bold 1=on 0=off
' arg4= italic 1=on, 0=off
' this sets the font to be double in size with bold and italic
' using pixels is likely to give an unexpected result in android
w.setFont(2, "em", 1,1)
cls
? "How does this look?"
w.insetTextScreen(5,10,90,90)
for i = 0 to 200
? "This is in the text screen"
next i
' comment out the above cls to see the bug
w.message("spot the bug (see comments)?")
w.setFont(11, "px", 0,0)
? "press a key to end..."
pause
The window example on the website needs a little debugging, as it interprets the square brackets in things like
w.message("[2] click to continue. ")
wrongly and gives an error about arrays or something
I'm not sure resetting the window is going to be high on the todo list,
but in the meantime, you could do something like this:
Here's the window example (debugged, Win7), by the way.
Thus conversation is so important. :D I hope that the Author will spend more time on discussing with us(the community of SmallBASIC) about the direction of the development of SmallBASIC.
And then I worry it might not be maintained, as happened with a couple of my favourite languages in the past. I've sometimes been anxious to share suggestions and bug reports, here and elsewhere, because I hate to over-burden authors, and it can sometimes look like complaining. If I started to deliberately put a wish-list together, it might get quite long, but they're almost all that, just wishes
It might be good to put a pinned topic on the board with the link to the issues list. Can you add sections? It could really help to have a section for suggestions, bug reports, general chit chat, etc., rather than all of the threads being in one list.
It's a pity it's not a dedicated forum.
At this stage I'm just making minor incremental changes, mostly from suggestions such as this one!
At this stage I'm just making minor incremental changes, mostly from suggestions such as this one!
Do you mean that the development of SmallBASIC nearly stopped? Oh....
Adding a pinned topic is an excellent idea, but I don't seem to have permissions. I guess I could work something out with the forum maintainers, but it would be more awesome for people to create an account with git-hub.It's useful to know that's your preference, and I guess we'll all have our own. For me, github has always looked pretty daunting, and involves learning a new set of procedures to edit or submit things like bug reports, as well as involving setting up another account. Also, as I've just demonstrated a couple of times, a forum allows discussion and resolution of an issue that might look like a bug but is just a noob mistake, so nobody has to put it on github and you don't have to take it off again (meanwhile, probably not having time to explain why it wasn't a bug, so losing the learning potential for the noob)!
Then you could register your suggestions and bug reports and they'd never be lost or forgotten:
https://github.com/smallbasic/SmallBASIC/issues
My ulterior motive is for people to help improve the documentation. Here's how:Yeah, that all sounds a bit much, to be honest. Besides, I personally think the help files could be improved most not by improving each page of documentation (although they have value), but by rewriting it as either a set of html files with an index where every keyword is itemised in alphabetical order, linked to a details page, or - perhaps even better - a single html page with all the detail as well. I know the latter sounds mad, but it's surprisingly useful, because you can just have the page open in your browser and use Ctrl-F or whatever to find the info. It could maybe have tables and other layout types and would have hyperlinked index at the top. I would be happy to put something together like that. I just started experimenting with doing it using sB to write the text, hence the TSAVE experiment. Hopefully I'm better at writing html than text documents, lol.
1. Navigate to the documentation page:
https://github.com/smallbasic/smallbasic.github.io
2. Click clone to create your own copy.
3. In your clone, navigate to any of the poorly documented SUBs/FUNCs
For example:
https://github.com/smallbasic/smallbasic.github.io/blob/master/_build/reference/569-data-data.markdown
4. Click the edit link to make some improvements.
Since this is BASIC, in a lot of cases there's already some other place that could be used for "inspiration" for example;Yes, but only for inspiration. Since every BASIC dialect/interpreter works differently, it is also confusing. I tried the first example on that very page and had to re-write it for sB, which doesn't use % in variable names and has different escaping of quotes. So this method is limited to fairly experienced programmers who know the differences, or you risk introducing errors into the sB help.
https://www.c64-wiki.com/wiki/DATA
I think it's unrealistic to imagine ordinary users are going to bother to do any of that. When you're used to it, it probably doesn't seem a big deal. But as round157 said, it's good to discuss these sorts of things and I'm glad to hear where you're coming from.
5. Commit and raise a pull request.
Click "Create a new branch" for this commit and start a pull request.
Click "Learn more about pull requests."
Click "commit"
You don't need any special software to do any of this, just a web browser :)
I am not familiar with SmallBASIC. Chrisws is also busy for making the next version of SmallBASIC better. You are familiar with SmallBASIC. You are very enthusiastic, too. Would you mind being the moderator of the SmallBASIC sub-forum? If you don't mind being the moderator, then we need to suggest in this thread:Erm...I dunno, I guess it depends what it involved and if Chris or whoever- the forum owners - asked me, but I'm only slightly familiar with sB really. I ask lots of newbie questions myself. I've got long experience with BASIC, although mostly with an ancient version. Moderating would normally be day-to-day administration, like - if we had sub-boards - moving things to an appropriate place, 'policing' the guidelines, etc., so maybe you're as qualified as me for the role. :P
https://www.syntaxbomb.com/index.php/topic,43.210.html
I see. I'm less interested in the other languages on here. I've checked one or two out online, but I'm a bit fussy and there's usually something that puts me off. So far I only come here for the sB.QuoteIt's a pity it's not a dedicated forum.
Ha.....then I will not come frequently. Many official forums of BASIC languages are dead forums or inactive forums. Basic4GL, NaaLaa, etc. Visiting them once per several months is enough. :D
I frequently come to SyntaxBomb forum because it is active and I can get information or news of different BASIC dialects.
a=[3,2,1,-42]
? absmin(a),absmax(a)
end
It may also seem a backward step to put every keyword together in alphabetical order, but one of the things that slowed down my introduction to sB was the sections, since it's not immediately obvious which section a keyword might be under. This is especially true when you don't know what you're looking for, but is actually just a logical problem with any tree or discrete section structure. It leads to repetitions, like PEN, which is listed under Console with barely any information, and under Graphics with the full list of parameters. What's ARC, or PTDISTLN, maths or graphics - so it goes on, slowing you down looking stuff up every time you write a new line of code as a newbie. Where should PRINT be, since it can be to the console or a file? It could be useful in an alphabetical list to indicate those categories with each keyword, but they're more like tags than sections.
I also think absmin and absmax are the wrong way round:Code: [Select]a=[3,2,1,-42]
? absmin(a),absmax(a)
end
-> 42 1
What tends to work for me is an alphabetical list of keywords on one page, and I guess it would be good if they were on that main reference page, with a link direct to the details page for each keyword. Ideally, each keyword in the alphabetical list would also have a brief explanation next to it. But I'm aware you've got a more important task with the actual language, so if it's just me requesting this, don't make it a priority.QuoteIt may also seem a backward step to put every keyword together in alphabetical order, but one of the things that slowed down my introduction to sB was the sections, since it's not immediately obvious which section a keyword might be under. This is especially true when you don't know what you're looking for, but is actually just a logical problem with any tree or discrete section structure. It leads to repetitions, like PEN, which is listed under Console with barely any information, and under Graphics with the full list of parameters. What's ARC, or PTDISTLN, maths or graphics - so it goes on, slowing you down looking stuff up every time you write a new line of code as a newbie. Where should PRINT be, since it can be to the console or a file? It could be useful in an alphabetical list to indicate those categories with each keyword, but they're more like tags than sections.
Do you have any specific suggestion of how you'd like this to appear? I can add it to this page:
https://smallbasic.github.io/pages/reference.html
What tends to work for me is an alphabetical list of keywords on one page, and I guess it would be good if they were on that main reference page, with a link direct to the details page for each keyword. Ideally, each keyword in the alphabetical list would also have a brief explanation next to it. But I'm aware you've got a more important task with the actual language, so if it's just me requesting this, don't make it a priority.QuoteIt may also seem a backward step to put every keyword together in alphabetical order, but one of the things that slowed down my introduction to sB was the sections, since it's not immediately obvious which section a keyword might be under. This is especially true when you don't know what you're looking for, but is actually just a logical problem with any tree or discrete section structure. It leads to repetitions, like PEN, which is listed under Console with barely any information, and under Graphics with the full list of parameters. What's ARC, or PTDISTLN, maths or graphics - so it goes on, slowing you down looking stuff up every time you write a new line of code as a newbie. Where should PRINT be, since it can be to the console or a file? It could be useful in an alphabetical list to indicate those categories with each keyword, but they're more like tags than sections.
Do you have any specific suggestion of how you'd like this to appear? I can add it to this page:
https://smallbasic.github.io/pages/reference.html
I have made a start on something myself. I don't know if I'll stick at it, but I hope so. I might get inspired. It's helping me learn more of the language as I do it. I've also remembered that there's a lot more to a language than the keywords, so I'll have to work out what to put in and how it might look and operate. It could be useful to have certain special characters like <<, &, @, etc. in the list itself, or headings like Special Characters that link to another page.
I wondered about making it an actual smallBASIC program, but I'm not sure how that would work. Probably better would be to output the data to an html file, adding the tags for the formatting programmatically.
So far, I've gathered the keywords from all the reference categories, sorted them and put them in column 0 of an array, with other columns for reference syntax, tags (largely reproducing the sections of the current help), description, examples, further notes, and related keywords. Most of that is populated by zeros - I've filled in the other bits as far as absmin(). Incidentally, I'm toying with writing them all in lowercase, and putting parentheses at the end when they take them.
It could be tabulated in a single html page, which might give that overview and searchability I wanted, but each item could also link to more detailed discussion or longer examples of code where available. Currently I'm working on displaying the data in the program itself, and routines to deal with structural changes like adding 'columns'. Since it's all in a text file that loads into the array, I can add information to the file in Notepad or whatever and save it, and I can copy a lot of it off the web, but it'll take a bit of time.
Thanks for the clarification. Parts of the web site are generated using SmallBASIC. Have a look here:
https://github.com/smallbasic/smallbasic.github.io/tree/master/_build
I put this all together fairly quickly, but hopefully it's not too indecipherable :-[
It should be fairly trivial to make the change.
Erm...I dunno, I guess it depends what it involved and if Chris or whoever- the forum owners - asked me, but I'm only slightly familiar with sB really. I ask lots of newbie questions myself. I've got long experience with BASIC, although mostly with an ancient version. Moderating would normally be day-to-day administration, like - if we had sub-boards - moving things to an appropriate place, 'policing' the guidelines, etc., so maybe you're as qualified as me for the role. :P
With numbers as they are, I don't suppose it would be a big job, but yeah, it looks like something Chris doesn't want to be doing too much of. From what he said earlier, it might also be useful if the moderator was actually fairly proficient with sB and with github - then they could add suggestions and bug reports posted here to the issues list there. Maybe if a moderator is an idea that catches on, the right person will volunteer.
QuoteAt this stage I'm just making minor incremental changes, mostly from suggestions such as this one!
Do you mean that the development of SmallBASIC nearly stopped? Oh....
No I think he means at this moment small changes are being made, he says nothing about stopping development at all.
Did you see this? Scroll down to "How to help design a better looking editor color theme" https://smallbasic.github.io/pages/sdl.html
Thank you!!! I have edited the text file and the file name is settings.txt. I uploaded to this forum. You can download in this post and the colour combination may be liked by you.
Another thing to really put time into is how everything fits together with icons color, etc.
Here's a shot of an editor with everything working together:
- On the left is the code view. note the colors and icons.
- On the right is the code editor, note the line numbers with the same icons and colors
The theme looks really nice. I'm using it in the next update. Just a quick question, mind if I call it "R157"?
Also, the themes will be selectable from the context menu in the start screen. This will be in the SDL and android versions.
I haven't done a huge amount of work on SB but plan to release what I have soon......