02-13-2023, 07:21 PM
I'm not going to install Purebasic only to do a screenshot, in fact never again. Sorry.
I was unable to find the "utility" which uses "vorbiscomment" program from the OGG Vorbis tools, with the "Tinydialog" library for Freebasic, I think it was written by stylin?
Welp, I created something that could work on any platform, but it's not quite the same as I requested on this topic.
Change the text filename to the one you want on the line with "OPEN" statement.
For a string variable delimited by newline characters, call "readtextwindow". If it's a string array, call "readtextwindow2". If you want control over the screen colors and the screen dimensions, use the ordinary subprogram call. Note this is SCREEN 0, not graphics screen. Also I believe in the second version of this, which now I can't find in my backups, had mouse support. This presented one, however, supports the arrow keys.
I still want one which looks like standard dialogs out of an operating system desktop.
I was unable to find the "utility" which uses "vorbiscomment" program from the OGG Vorbis tools, with the "Tinydialog" library for Freebasic, I think it was written by stylin?
Welp, I created something that could work on any platform, but it's not quite the same as I requested on this topic.
Code: (Select All)
OPTION _EXPLICIT
DIM txt$, a$, ff AS LONG
DIM SHARED crlf$
crlf$ = CHR$(13)
$IF WIN THEN
crlf$ = crlf$ + chr$(10)
$ELSEIF LINUX THEN
crlf$ = CHR$(10)
$END IF
ff = FREEFILE
txt$ = ""
OPEN "fd13.bas" FOR INPUT AS ff
DO UNTIL EOF(ff)
LINE INPUT #ff, a$
txt$ = txt$ + a$ + crlf$
LOOP
CLOSE ff
readtextwindow txt$
SYSTEM
SUB readtextwindowex (s$, wantwidth, wantheigh, wantcolorf, wantcolorb)
STATIC prevwindow AS LONG
DIM breakaway AS _UNSIGNED _BIT
DIM update AS _UNSIGNED _BIT
DIM a$, na$, ke$, ch AS INTEGER, kk AS INTEGER
DIM AS LONG wantminus, wantchrwd, faketextwindow, numele, l, u, uu, p, up, lastline, top, numnum, y, otop
IF s$ = "" THEN EXIT SUB
prevwindow = _COPYIMAGE(0)
IF wantwidth < 40 OR wantwidth > 160 THEN wantwidth = 120
IF wantheigh < 20 OR wantheigh > 50 THEN wantheigh = 40
wantminus = 10
wantchrwd = wantwidth - wantminus
IF wantcolorf < 0 OR wantcolorf > 15 THEN wantcolorf = 0
IF wantcolorb < 0 OR wantcolorb > 15 THEN wantcolorb = 7
IF wantcolorf = wantcolorb THEN wantcolorf = 0: wantcolorb = 7
faketextwindow = _NEWIMAGE(wantwidth, wantheigh, 0)
SCREEN faketextwindow
COLOR wantcolorf, wantcolorb
CLS
_SCREENMOVE _MIDDLE
numele = 1000
REDIM sf(1 TO numele) AS STRING
breakaway = 0
l = 0
u = INSTR(s$, crlf$)
uu = 1
DO
IF u = 0 THEN breakaway = NOT breakaway
IF breakaway THEN
a$ = MID$(s$, uu)
na$ = _TRIM$(a$)
IF na$ = "" THEN EXIT DO
ELSE
a$ = SEG1$(s$, uu, u)
na$ = _TRIM$(a$)
IF a$ <> na$ THEN a$ = na$
p = INSTR(a$, crlf$)
DO WHILE p > 0
a$ = LEFT$(a$, p - 1) + MID$(a$, p + 1)
p = INSTR(a$, crlf$)
LOOP
END IF
l = l + 1
IF l > numele THEN
numele = numele + 1000
REDIM _PRESERVE sf(1 TO numele) AS STRING
END IF
p = LEN(a$)
IF p > wantchrwd THEN
up = wantchrwd + 1
ch = ASC(a$, up)
DO UNTIL ch = 32
up = up - 1
ch = ASC(a$, up)
LOOP
sf(l) = LEFT$(a$, up - 1)
a$ = MID$(a$, up + 1)
p = LEN(a$)
DO WHILE p > wantchrwd
l = l + 1
IF l > numele THEN
numele = numele + 1000
REDIM _PRESERVE sf(1 TO numele) AS STRING
END IF
up = wantchrwd + 1
ch = ASC(a$, up)
DO UNTIL ch = 32
up = up - 1
ch = ASC(a$, up)
LOOP
sf(l) = LEFT$(a$, up - 1)
a$ = MID$(a$, up + 1)
p = LEN(a$)
LOOP
l = l + 1
IF l > numele THEN
numele = numele + 1000
REDIM _PRESERVE sf(1 TO numele) AS STRING
END IF
END IF
sf(l) = a$
IF breakaway THEN EXIT DO
uu = u + LEN(crlf$)
u = INSTR(uu, s$, crlf$)
LOOP UNTIL breakaway
lastline = l - wantheigh
top = 1
update = 1
numnum = 0
DO
_LIMIT 1000
IF update THEN
update = 0
CLS
p = top
FOR y = 1 TO wantheigh
LOCATE y, 1
PRINT sf(p);
p = p + 1
IF p > l THEN EXIT FOR
NEXT
END IF
ke$ = INKEY$
IF ke$ <> "" THEN
kk = ASC(ke$)
IF kk = 0 THEN kk = ASC(ke$, 2) * -1
SELECT CASE kk
CASE -81, 32
update = 1
otop = top
top = top + wantheigh - 2
IF top > lastline THEN top = lastline
IF top < 1 OR top > l THEN update = 0: top = otop
CASE -80, -77, 13
otop = top
top = top + 1
IF top > lastline THEN top = lastline ELSE update = 1
IF top < 1 OR top > l THEN update = 0: top = otop
CASE -79
update = 1
top = lastline
CASE -72, -75
top = top - 1
IF top < 1 THEN top = 1 ELSE update = 1
CASE -73
update = 1
top = top - wantheigh - 2
IF top < 1 THEN top = 1
CASE -71
update = 1
top = 1
CASE 27: EXIT DO
CASE 48 TO 57
IF numnum = 0 THEN
numnum = VAL(ke$)
ELSE
numnum = VAL(ke$) * 10 + numnum
END IF
IF numnum < 1 OR numnum > lastline THEN
numnum = 0
ELSE
update = 1
top = numnum
END IF
END SELECT
END IF
LOOP
ERASE sf
SCREEN prevwindow
_FREEIMAGE faketextwindow
END SUB
SUB readtextwindow2ex (sa() AS STRING, wantwidth, wantheigh, wantcolorf, wantcolorb)
STATIC a$
DIM AS LONG lb, ub, i
lb = LBOUND(sa)
ub = UBOUND(sa)
FOR i = lb TO ub
a$ = a$ + sa(i)
IF i < ub THEN a$ = a$ + crlf$
NEXT
readtextwindowex a$, wantwidth, wantheigh, wantcolorf, wantcolorb
a$ = ""
END SUB
SUB readtextwindow (s$)
readtextwindowex s$, -1, -1, -1, -1
END SUB
SUB readtextwindow2 (sa() AS STRING)
readtextwindow2ex sa(), -1, -1, -1, -1
END SUB
FUNCTION SEG1$ (astr$, stapos AS LONG, endpos AS LONG)
DIM sp AS LONG, ep AS LONG, l AS LONG
IF astr$ = "" THEN SEG1$ = "": EXIT FUNCTION
sp = stapos
ep = endpos
l = LEN(astr$)
IF sp < 1 THEN sp = l + sp
IF ep < 1 THEN ep = l + ep
IF (sp < 1 AND ep < 1) OR (sp > l AND ep > l) THEN SEG1$ = "": EXIT FUNCTION
IF sp < 1 THEN sp = 1
IF ep < 1 THEN ep = 1
IF sp > l THEN sp = l
IF ep > l THEN ep = l
IF sp > ep THEN SWAP sp, ep
SEG1$ = MID$(astr$, sp, ep - sp + 1)
END FUNCTION
Change the text filename to the one you want on the line with "OPEN" statement.
For a string variable delimited by newline characters, call "readtextwindow". If it's a string array, call "readtextwindow2". If you want control over the screen colors and the screen dimensions, use the ordinary subprogram call. Note this is SCREEN 0, not graphics screen. Also I believe in the second version of this, which now I can't find in my backups, had mouse support. This presented one, however, supports the arrow keys.
I still want one which looks like standard dialogs out of an operating system desktop.