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: 762
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
|
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,032
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
|
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
|
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
|
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
|
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155
|
|
|
Fancy font names |
Posted by: mnrvovrfc - 05-27-2023, 08:28 AM - Forum: Utilities
- Replies (8)
|
|
This is a program that interacts with the user, asking him/her what is the "fancy" font name, and then it shows a dialog indicating what is the QB64 code line to use to load that font. The QB64 code line is copied to the clipboard so it could be pasted right away into the QB64 IDE.
It requires a text file called "fancy-font-names.txt" in the same directory as the executable.
This program was tested on Linux (Manjaro MATE) but with the provided text file it should work on Windows. I have listed only the fonts actually installed by "winetricks corefonts" by Debian v11 "Bullseye". I added one more, for Lucida Console which is not installed for Wine.
It's easy to add more fonts to the text file. Each line should have two fields separated by semicolon. In the first field enter the font name you wish to use. The second field is the full path of the filename of the font. Note that Bold, Italic, Semicondensed etc. are on separate TTF files than the "Regular" version and will be called differently.
It should be easier than ever to pull a text-file directory listing on Windows. Use
Code: (Select All) dir /b/s C:\Windows\Fonts
the last time I checked. It has to be redirected to a text file, to then add the fancy names ending with semicolon at the front of each line. Tedious task, I know, but I did most of the work for you for the most common fonts.
The code is being shown here, but please download the ZIP attachment with this post.
Code: (Select All) 'by mnrvovrfc 27-May-2023
OPTION _EXPLICIT
$SCREENHIDE
TYPE twostring
fancy AS STRING * 64
apath AS STRING * 192
END TYPE
DIM infile$, oneline$, entry$, oldentry$
DIM AS LONG ff, sfl, i, u, lentry, choice
REDIM sf(1 TO 1) AS twostring
infile$ = "fancy-font-names.txt"
IF NOT _FILEEXISTS(infile$) THEN
_MESSAGEBOX "File not found", "I'm sorry, but the required file wasn't found." + CHR$(13) + infile$, "info"
SYSTEM
END IF
ff = FREEFILE
OPEN infile$ FOR INPUT AS ff
DO UNTIL EOF(ff)
LINE INPUT #ff, oneline$
u = INSTR(oneline$, ";")
IF u > 0 THEN
sfl = sfl + 1
REDIM _PRESERVE sf(1 TO sfl) AS twostring
sf(sfl).fancy = LEFT$(oneline$, u - 1)
sf(sfl).apath = MID$(oneline$, u + 1)
END IF
LOOP
CLOSE ff
entry$ = _INPUTBOX$("Fancy Font Names", "What is the fancy name of the font you'd like?", " ")
IF entry$ = "" THEN SYSTEM
oldentry$ = entry$
entry$ = LCASE$(entry$)
lentry = LEN(entry$)
choice = 0
oneline$ = ""
FOR i = 1 TO sfl
oneline$ = LEFT$(LCASE$(RTRIM$(sf(i).fancy)), lentry)
IF oneline$ = entry$ THEN choice = i: EXIT FOR
NEXT
IF choice THEN
_MESSAGEBOX "Fancy Font Names", "The QB64 statement to load" + CHR$(13) + oldentry$ + " is " + chr$(34) +_
"fonthandle = _LOADFONT(" + chr$(34) +rtrim$(sf(choice).apath) + chr$(34) + ", pointsize)" + chr$(13) +_
"Be sure to set the " + chr$(34) + "pointsize" + chr$(34) +"as an integer from 8 to 128." + chr$(13) +_
"The QB64 code line was copied to the clipboard.", "info"
_CLIPBOARD$ = "fonthandle = _LOADFONT(" + CHR$(34) + RTRIM$(sf(choice).apath) + CHR$(34) + ", pointsize)"
ELSE
_MESSAGEBOX "Font name not found", "I'm sorry, I was unable to find the filename for the fancy font you entered:" +_
CHR$(13) + oldentry$, "info"
END IF
SYSTEM
Note: I have discovered two misbehaviors that can't be termed bugs. The _INPUTBOX$ produces "password mode" whether or not the third parameter is included as the empty string. That's why in this code it's actually a space which could be annoying to some people. The second thing is that on Linux on my side, the result of _CLIPBOARD$ puts double-quotation marks around the entire string that is stored. This is OK for pasting to RHS of a string assignment in this programming language; otherwise it wasn't expected.
fancy-font-names.zip (Size: 1.48 KB / Downloads: 15)
|
|
|
Is this a problem with _RESIZE or expected behavior? |
Posted by: hanness - 05-27-2023, 03:02 AM - Forum: General Discussion
- Replies (7)
|
|
I have a program that is running in a console window. I use the _RESIZE function to detect when a user drags the resize handles on the program window to resize it. This works flawlessly for me. However, if I click on the "Maximize" button in the upper right of the program window, _RESIZE does not detect the fact that the program window changed size.
Is this a problem with the _RESIZE function or is there some other method of detecting the change in the window size when the maximize button is used?
EDIT: I should note that maximizing is NOT the same as running full screen. In maximized mode, you still have a title bar that run across the full width of the screen at the top, whereas full screen eliminates the title bar.
I have a way of handling full screen that works, it's simply the "maximize" button that is causing me fits.
|
|
|
QBJS v0.7.0 - Release |
Posted by: dbox - 05-26-2023, 06:23 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (19)
|
|
Hi All,
The latest version of QBJS (0.7.0) is now available. Here are some highlights for this release:
IDE Enhancements
Numerous enhancements to the IDE have been incorporated into this release. The code, output and console panels can be resized by dragging the panel dividers. There are now keyboard shortcuts for running the current program (F5) and the export/share feature (F11). Users can now customize the look and feel of the IDE by choosing from one of four themes.
Custom Fonts and Printing
Support has been added to allow the use of custom fonts. The following keywords are now available in support of this feature: _Font, _LoadFont, and _FreeFont. The _PrintMode keyword is also now supported to allow text to be printed with transparent background. Numerous updates have been made to the Print method to format the output more closely to QBasic/QB64.
2D Graphics Library
This release includes a new graphics library which provides native support for common graphics methods (e.g. FillTriangle, RotoZoom, FillCircle, FillEllipse). There is also new functionality to allow more control over both new graphics functions and standard QBasic graphics methods (e.g. LineWidth, LineCap, Shadow). The full list of new methods can be found here:
https://github.com/boxgaming/qbjs/wiki/S...d-graphics.
Console Output Library
A new console output library has been added to allow logging messages and simple output to the console window in the IDE. The full list of new methods can be found here:
https://github.com/boxgaming/qbjs/wiki/S...ds#console.
File I/O Extension Library
This library provides the ability to upload and download files to and from the browser from within your application. The full documentation for the library can be found here:
https://github.com/boxgaming/qbjs/wiki/S...filesystem.
See the full release announcement for a complete list of fixes and enhancements.
Check it out online here: https://qbjs.org
|
|
|
String Tokenizer |
Posted by: a740g - 05-25-2023, 03:33 PM - Forum: Utilities
- Replies (8)
|
|
Not sure if anyone will find this useful. I based my code off another simple string tokenizer that I found on the old QB64 forum. However, that one was too simple for my needs. So, I made some changes.
Original: Split1000 (simple string parser) Collaboration (alephc.xyz)
Code: (Select All) $CONSOLE:ONLY
OPTION _EXPLICIT
REDIM mytokens(-2 TO -2) AS STRING
DIM s AS STRING: s = "Function MyFunc(MyStr As String, Optional MyArg1 As Integer = 5, Optional MyArg2 = 'Dolores Abernathy')"
DIM n AS LONG: n = TokenizeString(s, "(),= ", 0, "''", mytokens())
PRINT n; " tokens parsed for: "; s
DIM i AS LONG
FOR i = LBOUND(mytokens) TO UBOUND(mytokens)
PRINT i; "="; mytokens(i)
SLEEP 1
NEXT
END
' Tokenizes a string to a dynamic string array
' text - is the input string
' delims - is a list of delimiters (multiple delimiters can be specified)
' tokens() - is the array that will hold the tokens
' returnDelims - if True, then the routine will also return the delimiters in the correct position in the tokens array
' quoteChars - is the string containing the opening and closing "quote" characters. Should be 2 chars only
' Returns: the number of tokens parsed
FUNCTION TokenizeString& (text AS STRING, delims AS STRING, returnDelims AS _BYTE, quoteChars AS STRING, tokens() AS STRING)
DIM strLen AS LONG: strLen = LEN(text)
IF strLen = 0 THEN EXIT FUNCTION ' nothing to be done
DIM arrIdx AS LONG: arrIdx = LBOUND(tokens) ' we'll always start from the array lower bound - whatever it is
DIM insideQuote AS _BYTE ' flag to track if currently inside a quote
DIM token AS STRING ' holds a token until it is ready to be added to the array
DIM char AS STRING * 1 ' this is a single char from text we are iterating through
DIM AS LONG i, count
' Iterate through the characters in the text string
FOR i = 1 TO strLen
char = CHR$(ASC(text, i))
IF insideQuote THEN
IF char = RIGHT$(quoteChars, 1) THEN
' Closing quote char encountered, resume delimiting
insideQuote = 0
GOSUB add_token ' add the token to the array
IF returnDelims THEN GOSUB add_delim ' add the closing quote char as delimiter if required
ELSE
token = token + char ' add the character to the current token
END IF
ELSE
IF char = LEFT$(quoteChars, 1) THEN
' Opening quote char encountered, temporarily stop delimiting
insideQuote = -1
GOSUB add_token ' add the token to the array
IF returnDelims THEN GOSUB add_delim ' add the opening quote char as delimiter if required
ELSEIF INSTR(delims, char) = 0 THEN
token = token + char ' add the character to the current token
ELSE
GOSUB add_token ' found a delimiter, add the token to the array
IF returnDelims THEN GOSUB add_delim ' found a delimiter, add it to the array if required
END IF
END IF
NEXT
GOSUB add_token ' add the final token if there is any
IF count > 0 THEN REDIM _PRESERVE tokens(LBOUND(tokens) TO arrIdx - 1) AS STRING ' resize the array to the exact size
TokenizeString = count
EXIT FUNCTION
' Add the token to the array if there is any
add_token:
IF LEN(token) > 0 THEN
tokens(arrIdx) = token ' add the token to the token array
token = "" ' clear the current token
GOSUB increment_counters_and_resize_array
END IF
RETURN
' Add delimiter to array if required
add_delim:
tokens(arrIdx) = char ' add delimiter to array
GOSUB increment_counters_and_resize_array
RETURN
' Increment the count and array index and resize the array if needed
increment_counters_and_resize_array:
count = count + 1 ' increment the token count
arrIdx = arrIdx + 1 ' move to next position
IF arrIdx > UBOUND(tokens) THEN REDIM _PRESERVE tokens(LBOUND(tokens) TO UBOUND(tokens) + 512) AS STRING ' resize in 512 chunks
RETURN
END FUNCTION
|
|
|
Is there an inconsistency in the Locate function? |
Posted by: PhilOfPerth - 05-25-2023, 05:24 AM - Forum: Help Me!
- Replies (3)
|
|
The result of running the small snippet of code below confuses me! I would expect Locate to use the first two arguments to set the column and row for text position,
but it uses the first for the vertical row position, and the second, not as the column but as a number to be determined from the font size.
I know, I'm easily confused, but can someone explain this to me?
PHP Code: Screen _NewImage(1280, 960, 32) f& = _LoadFont("c:\WINDOWS\Fonts\arial.ttf", 28) _Font f& ' Locate 31, 400 ' I would expect this to be an invalid horizontal position Print "This text location is row 31, column 400"; ' but it uses the pixel position, and prints it there! Sleep
|
|
|
Grade Keeper V4 |
Posted by: NasaCow - 05-23-2023, 04:35 AM - Forum: Works in Progress
- Replies (2)
|
|
After reading through the board and seeing other examples, I thought it be best I will keep the most recent verison on the first post (this post.) Starting a new thread to keep it clean and keeping the old for historical thoughts.
So here is the next update!
05-23-23.zip (Size: 537.68 KB / Downloads: 20)
Code: (Select All) '====================================================================================
'| |
'| Grade Keeper Build 4.1.2 - Resolving issues & adding more user-friendly features!|
'| |
'| Release #6 May 23rd, 2023 |
'| |
'| Additions: #1 - Gradebook Fuctionality! - Clear grades and deletion commands |
'| now fuctional (though I don't like the flow for deletion...) |
'| |
'| Modifications: #1 - All fonts built at start, faster report production! |
'| #2 - Duplication of code moved to a sub MENUFRAME (Title) |
'| #3 - Arial replaced with Arial Narrow due to rendering issue. |
'| #4 - New add student screen. Resolves issues and makes input less |
'| tedious (quicker to do and correct mistakes) |
'| |
'| Current Limitations: #1 - Printed reports limited to windows |
'| #2 = Printed reports limited to 1 page |
'| #3 - Gradebook commands: Add, clear grades, remove |
'| assignment and save and exit (F2, F6, F8, F12) |
'| are fuctional |
'| #4 - Gradebook limited to 20 students and about 20 |
'| assignments (name length dependent) |
'| |
'| Konwn Bugs & Issues: #X - Cancel changing class set will... (Resolved) |
'| #X - Adding an assignment will delay input and cause first |
'| keypress to be loss with GLI (Much less frequent) |
'| #X - Email and address field of add student can overlap |
'| (Resolved with new add student. Old modify student |
'| present until feedback and further testing before |
'| modifying that routinue. |
'| #1 - GLI word wrap issues here and there, will fix later. |
'====================================================================================
The more I use Terry's GLI library, the more powerful and useful I am finding it and how great it works. Do check out the new add student screen (now with mouse support!) to see it in action. Word wrapping is still an issue but it is lower on my list of things to get done. I left the old modify student routinue in place for now, pending on feedback. Then I will also adjust that to be more user-friendly as well!
I believe I got all (or at least most) of the mis-aligned text due to the font change. If you see something funny, please let me know so I can correct it.
Also, though all the files used are in the data.bas file as DATA lines, I also include the raw files in a Dev folder for ease of others to tweak changes.
Finally, I feel like I had to hack the delete assignment command to make it work right. For the life of me, I cannot figure out why the grades were not realigning with the cells after being updated. So after seeing the sub placing them correctly on relaunch, that is exactly what I see a loop up for. To relaunch the gradebook to show the grades right. Don't like such a hack but it works and therefore is staying for now until I have the time to figure out what happened...
Finally, Finally, on a personal note. I am now working (well suppose to starting yesterday) on my master thesis for my master in education. I wanted to get this update out before I unplug for a little bit. I may be a bit slower for a few months but I hope to keep working and improving this program (I do find it relaxing to program ). I feel like I am getting close to calling it a full-on beta here soon!
Current verison:
05-23-23.zip (Size: 537.68 KB / Downloads: 20)
|
|
|
|