|
Post by Pjot on Apr 1, 2017 10:41:40 GMT 1
All, BaCon version 3.5.3 has just been released and can be obtained from the BaCon website. This is mainly a maintenance release to stabilize BaCon after the new statements and functions in the 3.5 series. Highlights: - Functions to handle UTF8 strings
- Bug fixes and code cleaning / optimization
See the full list of changes for more details (please refresh your browser cache to see the latest). Thanks to the BaCon forum members for testing and providing feedback. Without them, BaCon would not have achieved its current level of maturity. BaCon releases are made available after testing on several platforms, including Tru64Unix, MacOSX and several flavors of Linux. Best regards Peter
|
|
|
Post by vovchik on Apr 1, 2017 12:54:49 GMT 1
Dear Peter,
Thanks for the UTF8 enhancements, which will prove useful and convenient. Everything compiled nicely in Mint and Raspberry PI. And the fews I ran were all OK.
With kind regards, vovchik
|
|
|
Post by Pjot on Apr 1, 2017 18:42:52 GMT 1
Thanks vovchik, Accidentally, I ran into a book called "10 PRINT CHR$(205.5+RND(1)); : GOTO 10". It is a socio-cultural study about the role of software various aspects of life. An interesting read, taking a simple BASIC line as basis for its views. Of course, I wondered how to translate this line of code into BaCon. With the newly added UTF8 stuff, we can now use any code from the UCS tables. The codes 9585 '╱' and 9586 '╲' are perfectly suitable. An attempt to stay as close to the original Commodore code (not golfed): LABEL _10 : PRINT UTF8$(9585+RANDOM(2)); : GOTO _10
Regards Peter
|
|
|
Post by vovchik on Apr 2, 2017 9:22:58 GMT 1
Dear Peter, Thanks for the book link - it's there as a pdf for free. And the little one-liner is delightful and shows how UTF8 can be used in place of those old DOS ASCII chars. WIth kind regards, vovchik
|
|
|
Post by vovchik on Apr 2, 2017 14:16:40 GMT 1
Dear Peter,
And this is another little demo of UTF8 in action...
With kind regards, vovchik
SUB UTF_BLOCK(STRING name$, STRING start$, int amount) PRINT "UTF8 BLOCK: ", name$, " (", amount, " code points)" LOCAL i TYPE int FOR i = 0 TO amount - 1 PRINT UTF8$(DEC(start$) + i), " "; NEXT i PRINT NL$ END SUB
UTF_BLOCK("DOS BOX", "2500", 128) UTF_BLOCK("BLOCKS", "2580", 32) UTF_BLOCK("DINGBATS", "2701", 92) UTF_BLOCK("GEOMETRIC", "25A0", 96) UTF_BLOCK("SYMBOLS AND ARROWS", "2B00", 90) UTF_BLOCK("MATHEMATICS", "2200", 256) UTF_BLOCK("MATHEMATICS SUPPLEMENTAL", "2A00", 256) UTF_BLOCK("ARROWS", "2190", 112) UTF_BLOCK("CYRILLIC", "0400", 256) UTF_BLOCK("GREEK", "0374", 144) UTF_BLOCK("MISCELLANEOUS SYMBOLS", "2600", 256)
|
|
|
Post by Pjot on Apr 2, 2017 17:45:31 GMT 1
Thanks vovchik, Nice! There even seems to be a Klingon font in a special private code ranges of UCS. I looked for a font which covers a lot of characters. The Quivira font covers more than 11.000 characters and looks promising... BR Peter
|
|
|
Post by vovchik on Apr 2, 2017 19:57:43 GMT 1
Dear Peter, This might be slightly more efficient for displaying the UTF8 blocks, since we don't have to convert a string to an int in the SUB (and we can supply decimal values if we know them): SUB UTF_BLOCK(STRING name$, int start_point, int code_points) PRINT FILL$(63, ASC("-")) PRINT "UTF8 BLOCK: ", name$, " (", code_points, " code points)" PRINT FILL$(63, ASC("-")) LOCAL i TYPE int FOR i = 0 TO code_points - 1 IF NOT(MOD(i, 32)) AND i > 0 THEN PRINT END IF PRINT UTF8$(start_point + i), " "; NEXT i PRINT NL$, FILL$(63, ASC("-")) PRINT "Starting UTF8 code point: 0x", HEX$(start_point), NL$ END SUB
UTF_BLOCK("DOS BOX", 0x2500, 128) UTF_BLOCK("BLOCKS", 0x2580, 32) UTF_BLOCK("DINGBATS", 0x2701, 92) UTF_BLOCK("GEOMETRIC", 0x25A0, 96) UTF_BLOCK("SYMBOLS AND ARROWS", 0x2B00, 90) UTF_BLOCK("MATHEMATICS", 0x2200, 256) UTF_BLOCK("MATHEMATICS SUPPLEMENTAL", 0x2A00, 256) UTF_BLOCK("ARROWS", 0x2190, 112) UTF_BLOCK("CYRILLIC", 0x0400, 256) UTF_BLOCK("GREEK", 0x0374, 144) UTF_BLOCK("MISCELLANEOUS SYMBOLS", 0x2600, 256) Thanks for the Quivira link. I hope they eventually do a Sans style (Quivira is Serif), since it would be nice to have one all-encompassing font. With kind regards, vovchik UPDATED: Added a bit of pretty print to output.
|
|
|
Post by Pjot on Apr 3, 2017 20:01:52 GMT 1
Thx vovchik, Nice! I especially like the DosBox range Regards Peter
|
|
|
Post by vovchik on Apr 4, 2017 11:26:29 GMT 1
Dear Peter,
Here is a little demo that draws simple single-line and double line boxes:
' UTF8 DOS box drawing characters
' single lines ' ┌───┐ ' │Box│ ' └───┘ BOX_SLR$ = UTF8$(0x2500) :' ─ BOX_SUD$ = UTF8$(0x2502) :' │ BOX_SUL$ = UTF8$(0x2518) :' ┘ BOX_SUR$ = UTF8$(0x2514) :' └ BOX_SDL$ = UTF8$(0x2510) :' ┐ BOX_SDR$ = UTF8$(0x250C) :' ┌ BOX_SULR$ = UTF8$(0x2534) :' ┴ BOX_SDLR$ = UTF8$(0x252C) :' ┬ BOX_SUDL$ = UTF8$(0x2524) :' ┤ BOX_SUDR$ = UTF8$(0x251C) :' ├ BOX_SUDLR$ = UTF8$(0x253C) :' ┼ ' double lines ' ╔═══╗ ' ║Box║ ' ╚═══╝ BOX_DLR$ = UTF8$(0x2550) :' ═ BOX_DUD$ = UTF8$(0x2551) :' ║ BOX_DUL$ = UTF8$(0x255D) :' ╝ BOX_DUR$ = UTF8$(0x255A) :' ╚ BOX_DDL$ = UTF8$(0x2557) :' ╗ BOX_DDR$ = UTF8$(0x2554) :' ╔ BOX_DUDL$ = UTF8$(0x2563) :' ╣ BOX_DUDR$ = UTF8$(0x2560) :' ╠ BOX_DULR$ = UTF8$(0x2569) :' ╩ BOX_DDLR$ = UTF8$(0x2566) :' ╦ BOX_DUDLR$ = UTF8$(0x256C) :' ╬ BOX_DU_SL$ = UTF8$(0x255C) :' ╜ BOX_DU_SR$ = UTF8$(0x2559) :' ╙ BOX_DD_SL$ = UTF8$(0x2556) :' ╖ BOX_DD_SR$ = UTF8$(0x2553) :' ╓ BOX_DL_SU$ = UTF8$(0x255B) :' ╛ BOX_DL_SD$ = UTF8$(0x2555) :' ╕ BOX_DR_SU$ = UTF8$(0x2558) :' ╘ BOX_DR_SD$ = UTF8$(0x2552) :' ╒ BOX_DU_SLR$ = UTF8$(0x2568) :' ╨ BOX_DD_SLR$ = UTF8$(0x2565) :' ╥ BOX_DL_SUD$ = UTF8$(0x2561) :' ╡ BOX_DR_SUD$ = UTF8$(0x255E) :' ╞ BOX_DLR_SU$ = UTF8$(0x2567) :' ╧ BOX_DLR_SD$ = UTF8$(0x2564) :' ╤ BOX_DLR_SUD$ = UTF8$(0x256A) :' ╪ BOX_DUD_SL$ = UTF8$(0x2562) :' ╢ BOX_DUD_SR$ = UTF8$(0x255F) :' ╟ BOX_DUD_SLR$ = UTF8$(0x256B) :' ╫
' single FOR i$ IN "─ │ ┘ └ ┐ ┌ ┴ ┬ ┤ ├ ┼" STEP " " PRINT HEX$(UCS(i$)) NEXT ' double PRINT FOR i$ IN "═ ║ ╝ ╚ ╗ ╔ ╣ ╠ ╩ ╦ ╬ ╜ ╙ ╖ ╓ ╛ ╕ ╘ ╒ ╨ ╥ ╡ ╞ ╧ ╤ ╪ ╢ ╟ ╫" STEP " " PRINT HEX$(UCS(i$)) NEXT PRINT
' single PRINT BOX_SDR$, BOX_SLR$, BOX_SLR$, BOX_SLR$, BOX_SDL$ PRINT BOX_SUD$, "Box", BOX_SUD$ PRINT BOX_SUR$, BOX_SLR$, BOX_SLR$, BOX_SLR$, BOX_SUL$
' double PRINT BOX_DDR$, BOX_DLR$, BOX_DLR$, BOX_DLR$, BOX_DDL$ PRINT BOX_DUD$, "Box", BOX_DUD$ PRINT BOX_DUR$, BOX_DLR$, BOX_DLR$, BOX_DLR$, BOX_DUL$
With kind regards, vovchik
|
|
|
Post by vovchik on Apr 5, 2017 13:35:48 GMT 1
Dear Peter, BOX is easy. But BOX_TEXT, TABLE and TABLE_TEXT will require a little more thought. With kind regards, vovchik ' UTF8 BOX - single and double lines
DECLARE xx, yy, w, h, j TYPE int
' ------------------ SUB BOX(int x, int y, int width, int height, int mode) ' ------------------ ' single (mode = 0) and double (mode = 1) lines LOCAL i TYPE int LOCAL bx$[6] TYPE STRING bx$[1] = SPC$(width - 2) IF mode = 0 THEN bx$[0] = UTF8$(0x250C) : ' ┌ bx$[1] = REPLACE$(bx$[1], " ", UTF8$(0x2500)) :' ─ bx$[2] = UTF8$(0x2510) :' ┐ bx$[3] = UTF8$(0x2502) :' │ bx$[4] = UTF8$(0x2514) :' └ bx$[5] = UTF8$(0x2518) :' ┘ ELSE bx$[0] = UTF8$(0x2554) :' ╔ bx$[1] = REPLACE$(bx$[1], " ", UTF8$(0x2550)) :' ═ bx$[2] = UTF8$(0x2557) :' ╗ bx$[3] = UTF8$(0x2551) :' ║ bx$[4] = UTF8$(0x255A) :' ╚ bx$[5] = UTF8$(0x255D) :' ╝ END IF GOTOXY x, y PRINT bx$[0], bx$[1], bx$[2]; FOR i = 1 TO height - 1 GOTOXY x, y + i PRINT bx$[3]; GOTOXY x + width - 1, y + i PRINT bx$[3]; NEXT i GOTOXY x, y + height - 1 PRINT bx$[4], bx$[1], bx$[5]; END SUB
COLOR INTENSE COLOR BG TO BLACK COLOR FG TO GREEN CLEAR CURSOR OFF w = 20 h = 20 xx = 1 yy = 2 FOR j = 1 TO 10 BOX(xx, yy, w, h, 1) BOX(xx + 20, yy, w, h, 0) BOX(xx + 40, yy, w, h, 1) BOX(xx + 60, yy, w, h, 0) INCR xx INCR yy DECR w, 2 DECR h, 2 NEXT j
BOX(26, 22, 33, 3, 0) GOTOXY 28, 23 COLOR FG TO YELLOW PRINT "Press <escape> to exit now..."; key = GETKEY IF key = 27 THEN COLOR RESET PRINT END END IF
UDATED: Looks a bit better now - and thanks to Peter for CURSOR OFF.
|
|
|
Post by Pjot on Apr 5, 2017 19:29:30 GMT 1
Hi vovchik, Very nice! It opens a lot of new possibilities (BTW with CURSOR OFF we can make the cursor invisible.) Thanks, Peter
|
|
|
Post by vovchik on Apr 5, 2017 20:39:44 GMT 1
Dear Peter, Thanks. I implemented the CURSOR OFF and improved the appearance in the above code. I have been looking at menu.h and curses.h. It would not be that hard to hack together some easy routines for menus, drop-boxes, etc. And we can use the keyboard and mouse. I am investigating... With kind regards, vovchik
|
|
|
Post by alexfish on Apr 10, 2017 22:30:38 GMT 1
Whilst looking for a work around for hugrpi widgets IE :: trying to avoid some ASSOC's and the limited RECORD defined as an ARRAY can not remember C typedef been accepted in BaCon not it Appears to work . Example, OPTION PARSE FALSE
typedef struct { char * title
} Book
' make a book Book book book.title = "C Programming" puts(book.title)
LOCAL txt$
' make another Book LOCAL book2 TYPE Book
book2.title = "BaCon C Programming " txt$= book2.title
PRINT txt$ BR Alex
|
|
|
Post by Pjot on Apr 11, 2017 19:38:08 GMT 1
Hey Alex, Just to let you know that RECORDS automatically are typedef'ed as soon as they occur in BaCon code - see here. So your code could be written more nicely as follows: RECORD Book LOCAL title$ ENDRECORD
' make a book DECLARE book TYPE Book_type
book.title$ = "C Programming"
PRINT book.title$
' make another Book DECLARE book2 TYPE Book_type
book2.title$ = "BaCon C Programming "
txt$ = book2.title$
PRINT txt$
BR Peter
|
|
|
Post by alexfish on Apr 11, 2017 23:35:20 GMT 1
Peter, you are a Diamond.
Brill
had been trying that $.
suppose the important bit of defining a typedef Book in 'Book_type' , is the '_type'
BR Alex
|
|