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: 764
|
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,034
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,262
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 316
|
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
|
|
|
JavaScript-ing it, I need to get with it |
Posted by: mnrvovrfc - 11-06-2022, 03:53 PM - Forum: General Discussion
- Replies (15)
|
|
https://staging.qb64phoenix.com/showthre...66#pid9266
This thread exists because I didn't want to reply to that post, and I selfishly didn't want to post on the dedicated thread about the subject.
Good job with this project, surprised that it's as deep as it is in such a short time. Normally I don't like stunts done by clunky web browsers but this interested me. I visited the page on Github to learn about support for QB64(PE) keywords. These are just my observations.
- "COMMAND$" - not even a special "global" dialog to put in its value? Some programs depend on this, including all-uppercase return value, and it might be difficult to change away from it. Might not have to worry a lot about "COMMAND$(1)" or alike. OTOH Linux is very lame about this sometimes, limiting terminal command line to a maximum of 255 characters.
- "IF... THEN" - clarify that it has to be "IF (condition) THEN GOTO (linenum/label)", or "GOTO" cannot be used at all? (OK discovered below "GOTO" and labels aren't even supported.) Does this mean only block "IF" could work? No problem for me but some old programs would need extensive revision then, you know how much colons were loved back then...
- "LOCATE" - does this mean changing the cursor shape? Because this is a bit sad this day and age. I mean in graphics mode "druw yer own kersair for krissakes"...
- "OPEN FOR RANDOM AS" - this should be easy to implement one way. "TYPE... END TYPE" is supported, am I correct? It must have to do with a security issue. Entire files could be "dowloaded" which isn't as useful to me and I could never get to grips with Internet functionality in QB64PE.
- "SELECT CASE" - what is "EVERYCASE"? Do you mean "CASE ELSE"? Must be Visual Basic tendency.
- "TIMER" - a few QB64 programs will be broken because of this. So this might mean the QB64-only edition of "ON TIMER" isn't supported neither.
- "_MOUSEINPUT" - LOL so this is like being on a Macintosh.
- "_OS$" - I think this should work like in normal QB64, some programs depend on this information and don't use the preprocessor.
A few other things:
Sub parameters are passed only by value: this is one reason why I'll have difficulty with this package. LOL I like using "SUBs" instead of "FUNCTIONs" to return values, especially more than one value since I also like to program in Lua.
"GOSUB... RETURN" not supported: yeech!
Function return could be array, associative arrays support: don't need unless the above two are fixed!
Errm... I understand the tendency toward Visual Basic, but I guess this isn't for converting programs created before M$ came up with that product. No spaghetti code allowed! Also give them no choice with "OPTION _EXPLICIT" always enabled. Some people with bad habits made by Q(uick)BASIC are going to be alienated, however.
As I've said, these are just observations (opinions).
|
|
|
Day 001: _GREEN32 |
Posted by: SMcNeill - 11-06-2022, 02:33 PM - Forum: Keyword of the Day!
- Replies (3)
|
|
Perhaps not the greatest of keywords to start with, but that's the nature of randomness. It is what it is, so with no further ado, here's _GREEN32 explained and showcased.
What is _GREEN32? It's a simple command that takes a color value and returns the green component back to you from it.
When would you use it? Basically when you have a color (perhaps taken from one of the color names), and you need to know what the green value is in it.
Example:
Code: (Select All) Screen _NewImage(640, 480, 32)
$Color:32
Print "Lime : "; Hex$(Lime)
Print "======"
Print "Alpha: "; Hex$(_Alpha32(Lime)), _Alpha32(Lime)
Print "Red : "; Hex$(_Red32(Lime)), _Red32(Lime)
Print "Green: "; Hex$(_Green32(Lime)), _Green32(Lime)
Print "Blue : "; Hex$(_Blue32(Lime)), _Blue32(Lime)
As you can see from the simple example above, _GREEN32 can be used to easily get back the green color values from whatever 32-bit color you send to it. Used in conjection with _ALPHA32, _RED32, and _BLUE32, you can quickly and easily break down a complex color value into its component parts with almost no effort on your part.
|
|
|
Keyword of the Day! |
Posted by: SMcNeill - 11-06-2022, 02:21 PM - Forum: Learning Resources and Archives
- Replies (1)
|
|
From the topic here -- Code fix (qb64phoenix.com) -- I was surprised to see both Dimster and OldMoses were both unaware of the INPUT$ function. It's one of those commands that's been in the language since the beginning of time (back when cavemen used LET and such), so I just assumed everyone was familiar with it by now.
Fool me once, as they say!
So the question then becomes, "What other keywords are folks missing out on? And how can we help draw attention to those keywords, to make the user base aware of them?"
My solution??
Keyword of the Day!!
Every day I'll run the little code below and TRY to write up an explanation and a few simple samples of whatever keyword the list gives me. If it's a keyword that's already been covered, then YAYYYY -- I get a day off!! For those that know the keyword, I encourage you to add any explanation and examples that you can with it, to showcase WHY one would use it and WHEN they would use it. On any day which I might miss due to illness, life, or whatnot, I encourage any other user to feel free to run the code below and put up a sample for a Keyword of the Day!
Let's see how many days in a row we can go without missing one!
Code: (Select All) '$INCLUDE:'.\source\subs_functions\syntax_highlighter_list.bas'
ReDim KeyWords(0) As String
ParseList KeyWords(), listOfKeywords$
Randomize Timer
i = Int(Rnd * UBound(KeyWords)) + 1
Print "The KeyWord for the day is: "; KeyWords(i)
Sub ParseList (Array() As String, list$)
ReDim Array(10000) As String
Do
p = InStr(list$, "@")
Array(count) = Left$(list$, p - 1)
list$ = Mid$(list$, p + 1)
If Left$(list$, 3) <> "_GL" Then count = count + 1
Loop Until p = 0
ReDim _Preserve Array(count) As String
End Sub
|
|
|
Code fix |
Posted by: Chris - 11-06-2022, 11:51 AM - Forum: General Discussion
- Replies (15)
|
|
Hello
Please modify the code.
Normal inputs are: zero (inclusive) to 6
How to convert the code so that the option without entering digits after pressing the Enter key, T # takes the value 7.
Thank You
PRINT "Enter a digit"
K$ = "": F$ = ""
WHILE LEN(K$) < 1 AND F$ <> CHR$(13)
F$ = ""
WHILE F$ = "": F$ = INKEY$: _LIMIT 30: WEND
IF F$ = CHR$(27) THEN 15
IF F$ = CHR$(32) THEN 20
IF F$ <> CHR$(13) THEN K$ = K$ + F$
WEND
T# = VAL(K$): PRINT T#
|
|
|
Single v Double |
Posted by: Dimster - 11-05-2022, 04:44 PM - Forum: Help Me!
- Replies (18)
|
|
I'm damn sure you guys have explained this once before so if anyone could point me to the thread I'd appreciate it. Can't seem to come up with the one I kind of remember that addressed this, it could be on the other site. Anyway here's the simply code
Dim a As Double
Dim b As Single
a = .12345678
Print a
b = Abs(a * 10000000)
Print a; b
So my search is to find out what happened to the 7 in the difference between variable a and variable b
|
|
|
Sam-Clip |
Posted by: Pete - 11-04-2022, 10:46 PM - Forum: Works in Progress
- Replies (24)
|
|
Note: Windows only app. (Saving you time reading if you only have Linux or Mac.)
For fun, I thought I'd start putting together an app that let's us paste text in a small persistent QB64 window. We can then click on line of text in the window, and insert it into another document, including a QB64 IDE window. So basically I'm making a multi-use clipboard app.
For now, it's bar bones, not goof proofed, but this is why I love this section of the boards where we can share stuff in the making. This is enough for now to demonstrate the basic mechanics. A lot more needs to be added to make it really worth using.
One challenge was a difference between apps like Notepad and QB64. _SCREENPRINT can be used for non-QB64 apps, but copying to highlighted text in the QB64 IDE results in the text being replaced with a "c" and paste has similar problems. I had to use a hack to get around this and used SENDEKY Windows API sub to open the QB64 Edit Menu and select "C" or "P" to get the operations to work properly. Not all that happy with it, but at least it works, and it is nice to include the IDE in the Sam-Clip app.
So how to separate the QB64 from other apps like Notepad? Hold Ctrl when highlighting or pasting to an app like Notepad and simple use the mouse without any key held to copy or paste in a QB64 IDE.
So to test it, try this....
1) Open Notepad and type some crap like, "Steve is brilliant." (We can so edit that later.)
2) Run Sam-Clip
3) Hold the Ctrl key and use your mouse to highlight part of the text like, "brilliant" When you release the left mouse button what you highlighted will be pasted into the Sam-Clip window.
3) Now press Enter a couple of times on notepad.
4) Next go to Sam-Clip and click on "brilliant" The text will be highlighted.
5) Go back to Notepad, hold down the Ctrl key, and left click where you want the text inserted. The word "brilliant" will be pasted into Notepad.
You can add more stuff to Sam-Clip, but for now it can't handle more than the window height. You can't same your additions yet, either.
You can bulk copy multiple lines of text to Sam-Clip, and bulk paste. .
Edit: Added Sam.clip.dat and Sam-clip.tmp database to save clipped selections.
Added ability to click where in the list to add a clipped line.
Edit: Added the ability to copy a bunch of text and keep it on Sam-Clip as a custom named [Header]. You right mouse hold on the [Header] and it will show you the contents.
Added the ability to click to highlight a [Header] and click the document. The contents of the [Header] will be paste into the document.
Added a bypass. If you hold Alt with a Sam-Clip entry highlighted, you can move about your doc and your Sam-Clip window will be grey and disengaged until you release the Alt key.
Code: (Select All) WIDTH 50, 25
_DELAY .1
a = _DESKTOPWIDTH - (_FONTWIDTH * _WIDTH)
_SCREENMOVE a, 0
CONST HWND_TOPMOST%& = -1
CONST SWP_NOSIZE%& = &H1
CONST SWP_NOMOVE%& = &H2
CONST SWP_SHOWWINDOW%& = &H40
CONST KEYEVENTF_KEYUP = &H2
CONST VK_ALT = &H12 'Alt key
REDIM Hold AS POINTAPI
TYPE POINTAPI
X_Pos AS LONG
Y_Pos AS LONG
END TYPE
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION GetAsyncKeyState% (BYVAL vkey AS LONG)
FUNCTION GetCursorPos (lpPoint AS POINTAPI)
FUNCTION FindWindowA& (BYVAL ClassName AS _OFFSET, WindowName$) 'handle by title
FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
FUNCTION GetForegroundWindow& 'Find currently focused process handle
FUNCTION SetWindowPos& (BYVAL hWnd AS LONG, BYVAL hWndInsertAfter AS _OFFSET, BYVAL X AS INTEGER, BYVAL Y AS INTEGER, BYVAL cx AS INTEGER, BYVAL cy AS INTEGER, BYVAL uFlags AS _OFFSET)
SUB SENDKEYS ALIAS keybd_event (BYVAL bVk AS LONG, BYVAL bScan AS LONG, BYVAL dwFlags AS LONG, BYVAL dwExtraInfo AS LONG)
END DECLARE
title$ = "Sam-Clip"
_TITLE (title$)
_DELAY .1
DIM SHARED hWnd AS LONG
hWnd = _WINDOWHANDLE
TYPE ClipType
clip AS STRING
cnt AS INTEGER
END TYPE
DIM SHARED AS ClipType a, c, placement, paste, header
REDIM SHARED clipper$(_HEIGHT * 2), clipper%(_HEIGHT * 2)
_CLIPBOARD$ = "" ' Clear clipboard.
IF _FILEEXISTS("Sam-Clip.dat") THEN
c.cnt = 0
OPEN "Sam-Clip.dat" FOR BINARY AS #1
DO UNTIL EOF(1)
c.cnt = c.cnt + 1
LINE INPUT #1, clipper$(c.cnt)
LOOP
CLOSE #1
END IF
CALL show_sam
DO
_LIMIT 60
z = GetCursorPos(Hold)
IF pal = -1 THEN IF GetAsyncKeyState(18) = 0 THEN PALETTE 0, 0: pal = 0
IF GetAsyncKeyState(18) THEN
IF pal = 0 THEN pal = -1: PALETTE 0, 56
_CONTINUE ' Bypass everything to do other stuff off screen.
END IF
FGwin& = GetForegroundWindow&
IF hWnd <> FGwin& THEN ' QB64 no longer in focus.
y& = SetWindowPos&(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)
END IF
IF Hold.Y_Pos >= _SCREENY AND Hold.Y_Pos <= _SCREENY + _FONTHEIGHT * (_HEIGHT + 1) AND Hold.X_Pos >= _SCREENX AND Hold.X_Pos <= _SCREENX + _FONTWIDTH * _WIDTH THEN
WHILE _MOUSEINPUT: WEND
my = _MOUSEY
mx = _MOUSEX
IF _MOUSEBUTTON(1) AND lb = 0 THEN ' Left button pressed.
lb = -1: z2 = TIMER
ELSEIF _MOUSEBUTTON(1) = 0 AND lb THEN ' Left button released.
lb = 0: hl = 0: drag = 0: begin_hl = 0: begin_hl_toggle = 0: z2 = TIMER
END IF
IF my < _HEIGHT THEN
IF _MOUSEBUTTON(2) AND show_c = 0 THEN
IF INSTR(clipper$(my), CHR$(255)) THEN
IF show_c = 0 THEN CALL show_collapse(my): show_c = -1
END IF
ELSE
IF _MOUSEBUTTON(2) = 0 AND show_c THEN
show_c = 0
SCREEN 0, 0, 0, 0
END IF
END IF
IF lb AND hl = 0 AND drag = 0 THEN
IF paste.cnt AND my = paste.cnt THEN ' Toggle for single selected item.
clipper%(paste.cnt) = 0
CALL show_sam
paste.cnt = 0
hl = -1 ' Prevents highlighting from relooping.
ELSE
hl = 1 ' Highlight a single line.
LOCATE 1, 1, 0 ' Hide cursor.
REDIM clipper%(_HEIGHT * 2)
CALL show_sam
LOCATE my, 1
IF clipper%(my) THEN ' Unhighlighted one line.
clipper%(my) = 0
COLOR 7, 0: PRINT MID$(clipper$(my), 1, _WIDTH);
_CLIPBOARD$ = ""
ELSE
REDIM clipper%(_HEIGHT * 2)
IF LEN(clipper$(my)) THEN ' Highlight a line.
COLOR 14, 1: PRINT MID$(clipper$(my), 1, _WIDTH);: COLOR 7, 0
clipper%(my) = my: paste.cnt = my
ELSE
paste.cnt = 0: ' Ignore a blank line.
END IF
END IF
END IF
ELSE
IF lb THEN
IF oldmy <> my AND drag = 0 THEN
LOCATE oldmy, 1
REDIM clipper%(_HEIGHT * 2)
COLOR 14, 1: PRINT MID$(clipper$(oldmy), 1, _WIDTH);: COLOR 7, 0
clipper%(oldmy) = 1
LOCATE oldmy, 1 ' IMPORTANT to restoring correct row with print to edge entries. This will be passed to drag_hl as CSRLIN.
CALL drag_hl(drag): _CONTINUE
END IF
IF clipper$(my) = "" AND drag = 0 THEN
LOCATE my, 1, 1, 7, 30 ' Show cursor at a blank space.
placement.cnt = my
END IF
END IF
END IF
ELSE ' Click on the next space you want another clip added to the list.
IF lb AND drag = 0 THEN
LOCATE my, 1, 1, 7, 30 ' Show cursor.
placement.cnt = my
END IF
END IF
oldmy = my
ELSEIF drag = 0 THEN ' Mouse cursor is outide of QB64 program window and drag is not engaged.
IF paste.cnt THEN ' Paste into document.
IF GetAsyncKeyState(1) < 0 THEN
CALL prep_doc_paste
SOUND 1000, .2
_SCREENCLICK Hold.X_Pos, Hold.Y_Pos
_DELAY .1
IF GetAsyncKeyState(17) = 0 THEN
SENDKEYS VK_ALT, 0, 0, 0
SENDKEYS &H45, 0, 0, 0 ' Alt+E open IDE edit menu.
_DELAY .1
SENDKEYS &H50, 0, 0, 0 ' P
_DELAY .1
SENDKEYS &H50, 0, KEYEVENTF_KEYUP, 0
SENDKEYS &H45, 0, KEYEVENTF_KEYUP, 0
SENDKEYS VK_ALT, 0, KEYEVENTF_KEYUP, 0
ELSE
_SCREENPRINT CHR$(22)
_DELAY .1
END IF
END IF
_CLIPBOARD$ = "" ' Clear clipboard after paste.
ELSE ' Add to Sam-Clip.
IF GetAsyncKeyState(1) < 0 AND win32lb = 0 THEN win32lb = -1: z1 = TIMER
IF win32lb = -1 AND GetAsyncKeyState(1) >= 0 THEN
IF ABS(z1 - TIMER) > .5 THEN
IF GetAsyncKeyState(17) = 0 THEN
_DELAY .1
SENDKEYS VK_ALT, 0, 0, 0
SENDKEYS &H45, 0, 0, 0 ' Alt+E open IDE edit menu.
_DELAY .2
SENDKEYS &H43, 0, 0, 0 ' C
_DELAY .2
SENDKEYS &H43, 0, KEYEVENTF_KEYUP, 0
SENDKEYS &H45, 0, KEYEVENTF_KEYUP, 0
SENDKEYS VK_ALT, 0, KEYEVENTF_KEYUP, 0
ELSE
_SCREENPRINT CHR$(3)
END IF
_DELAY .1
_KEYCLEAR
IF LEN(_CLIPBOARD$) THEN CALL clip_get
_CLIPBOARD$ = ""
win32lb = 0: z1 = TIMER
ELSE
win32lb = 0: z1 = TIMER
END IF
END IF
END IF
END IF
LOOP
END
SUB prep_doc_paste:
tmp2$ = ""
IF INSTR(clipper$(paste.cnt), CHR$(255)) THEN
tmp$ = _TRIM$(MID$(clipper$(paste.cnt), 151))
DO UNTIL INSTR(tmp$, CHR$(255)) = 0
j = INSTR(tmp$, CHR$(255)) - 1
tmp2$ = tmp2$ + MID$(tmp$, 1, j) + CHR$(13) + CHR$(10)
tmp$ = MID$(tmp$, j + 2)
LOOP
tmp2$ = MID$(tmp2$, 1, LEN(tmp2$) - 2) ' Chop off trailing CHR$(13) + CHR$(10)
_CLIPBOARD$ = tmp2$: tmp2$ = ""
ELSE
i = 0
DO
i = i + 1
IF clipper%(i) THEN
IF INSTR(clipper$(i), CHR$(255)) THEN
' Ignore collapsed headers in paste prep.
ELSE
_CLIPBOARD$ = _CLIPBOARD$ + clipper$(i) + CHR$(13) + CHR$(10)
END IF
END IF
LOOP UNTIL i >= c.cnt
_CLIPBOARD$ = MID$(_CLIPBOARD$, 1, LEN(_CLIPBOARD$) - 2)
END IF
paste.cnt = 0
REDIM clipper%(_HEIGHT * 2)
CALL show_sam
END SUB
SUB show_sam
CLS
FOR i = 1 TO _HEIGHT - 1
LOCATE i, 1
IF clipper%(i) < 0 THEN COLOR 2 ELSE COLOR 7
IF INSTR(clipper$(i), CHR$(255)) THEN
PRINT MID$(clipper$(i), 1, INSTR(clipper$(i), "]"));
ELSE
PRINT MID$(clipper$(i), 1, _WIDTH);
END IF
IF LEN(clipper$(i)) THEN placement.cnt = i
NEXT
COLOR 7
placement.cnt = placement.cnt + 1 ' Next available space.
END SUB
SUB clip_get
LOCATE , , 0 ' Hide cursor.
IF c.cnt < _HEIGHT THEN
a.clip = _CLIPBOARD$
IF RIGHT$(a.clip, 2) <> CHR$(13) + CHR$(10) THEN a.clip = a.clip + CHR$(13) + CHR$(10)
IF LEN(a.clip) THEN
SOUND 1000, .2
IF INSTR(INSTR(a.clip, CHR$(13) + CHR$(10)) + 1, a.clip, CHR$(13) + CHR$(10)) THEN
CALL condense
END IF
c.cnt = 0: REDIM clipper%(_HEIGHT * 2), clipper$(_HEIGHT * 2)
IF _FILEEXISTS("Sam-Clip.dat") THEN
OPEN "Sam-Clip.dat" FOR BINARY AS #1
IF LOF(1) THEN
DO UNTIL EOF(1)
IF c.cnt + 1 >= placement.cnt THEN EXIT DO
c.cnt = c.cnt + 1
LINE INPUT #1, clipper$(c.cnt)
LOOP
END IF
END IF
IF placement.cnt > c.cnt + 1 THEN ' Include any blank spaces between established text and new entry.
DO UNTIL c.cnt = placement.cnt - 1
c.cnt = c.cnt + 1
clipper$(c.cnt) = ""
LOOP
END IF
' Parse clipboard.
i = 0: j = 1 ' Instr() seed.
IF INSTR(a.clip, CHR$(255)) = 0 THEN
DO UNTIL INSTR(j, a.clip, CHR$(13) + CHR$(10)) = 0
i = i + 1
tmp$ = MID$(a.clip, j, INSTR(j, a.clip, CHR$(13)) - j)
j = j + LEN(tmp$) + 2
DO UNTIL INSTR(tmp$, CHR$(9)) = 0
tmp$ = MID$(tmp$, 2)
LOOP
DO UNTIL INSTR(tmp$, CHR$(0)) = 0
tmp$ = MID$(tmp$, 2)
LOOP
tmp$ = LTRIM$(tmp$)
c.cnt = c.cnt + 1
clipper$(c.cnt) = tmp$
clipper%(c.cnt) = -1
LOOP
ELSE
c.cnt = c.cnt + 1
clipper$(c.cnt) = a.clip
clipper%(c.cnt) = -1
END IF
_CLIPBOARD$ = ""
' Save file update routine.
IF _FILEEXISTS("Sam-Clip.dat") THEN
IF NOT EOF(1) AND LOF(1) > 0 THEN
DO UNTIL EOF(1)
c.cnt = c.cnt + 1
LINE INPUT #1, clipper$(c.cnt)
LOOP
END IF
CLOSE #1
END IF
IF _FILEEXISTS("Sam-Clip.dat") THEN
IF _FILEEXISTS("Sam-Clip.tmp") THEN KILL "Sam-Clip.tmp"
NAME "Sam-Clip.dat" AS "Sam-Clip.tmp"
END IF
i = 0
OPEN "Sam-Clip.dat" FOR OUTPUT AS #2
DO UNTIL i = c.cnt
i = i + 1
PRINT #2, clipper$(i)
LOOP
CLOSE #2
CALL show_sam
END IF
ELSE
BEEP ' Clipboard menu full.
END IF
END SUB
SUB condense
y = CSRLIN: x = POS(0)
LOCATE placement.cnt, 1
COLOR 2
PRINT "[Collapse Copied Text into Header? ";: COLOR 15, 2: PRINT " Y ";: COLOR 2, 0: PRINT "/";: COLOR 15, 2: PRINT " N ";: COLOR 2, 0: PRINT "]"
i = 0
DO
_LIMIT 30
WHILE _MOUSEINPUT: WEND
my2 = _MOUSEY
mx2 = _MOUSEX
IF _MOUSEBUTTON(1) OR i THEN
i = SCREEN(my2, mx2)
IF i = ASC("Y") THEN
LOCATE my2, 1
LOCATE my2, 1: PRINT "[" + SPACE$(_WIDTH - 2) + "]";
LOCATE my2, 2
CALL keyboard
' Routine to add contents to header for file input...
tmp$ = ""
j = 1 ' Instr() seed.
DO UNTIL INSTR(j, a.clip, CHR$(13) + CHR$(10)) = 0
tmp$ = MID$(a.clip, j, INSTR(j, a.clip, CHR$(13)) - j)
j = j + LEN(tmp$) + 2
DO UNTIL INSTR(tmp$, CHR$(9)) = 0
tmp$ = MID$(tmp$, 2)
LOOP
DO UNTIL INSTR(tmp$, CHR$(0)) = 0
tmp$ = MID$(tmp$, 2)
LOOP
tmp2$ = tmp2$ + LTRIM$(tmp$) + CHR$(255)
LOOP
a.clip = "[" + header.clip + "]" + SPACE$(150) + tmp2$
EXIT DO
ELSEIF i = ASC("N") THEN
EXIT DO
END IF
END IF
b$ = INKEY$
IF UCASE$(b$) = "Y" THEN
i = ASC("Y")
ELSEIF UCASE$(b$) = "N" THEN
i = ASC("N")
END IF
LOOP
END SUB
SUB keyboard
LOCATE , , 1, 7, 7 ' Show cursor.
numofspaces% = _WIDTH - 2
startpos% = POS(1)
endpos% = startpos% + numofspaces%
DO
DO
_LIMIT 30
b$ = INKEY$
IF LEN(b$) THEN EXIT DO
LOOP
xx% = CSRLIN: yy% = POS(1)
SELECT CASE b$
CASE CHR$(0) + "K"
mov% = -1: GOSUB action
CASE CHR$(0) + "M"
mov% = 1: GOSUB action
CASE CHR$(0) + "S"
GOSUB wash: GOSUB delete
CASE CHR$(0) + "R"
IF ins% = 0 THEN ins% = -1 ELSE ins% = 0
IF ins% = 0 THEN LOCATE , , 1, 7, 7 ELSE LOCATE , , 1, 7, 30
CASE CHR$(0) + "O"
IF word$ <> "" THEN LOCATE xx%, startpos% + LEN(word$)
CASE CHR$(0) + "G"
LOCATE xx%, startpos%
CASE CHR$(8)
IF yy% > startpos% THEN
LOCATE , POS(1) - 1
yy% = POS(1)
GOSUB wash: GOSUB delete
END IF
CASE CHR$(13)
LOCATE , , 0 ' Hide cursor.
header.clip = word$
EXIT SUB
CASE CHR$(27)
EXIT DO
CASE CHR$(32) TO CHR$(126)
key$ = b$: GOSUB action
END SELECT
mov% = 0: key$ = ""
LOOP
action:
IF POS(1) + mov% >= startpos% AND POS(1) + mov% < endpos% THEN
DO
IF key$ <> "" THEN
SELECT CASE ins%
CASE 0
IF LEN(word$) + LEN(key$) > endpos% - startpos% THEN EXIT DO
word$ = MID$(word$, 1, POS(1) - startpos%) + key$ + MID$(word$, POS(1) - startpos% + 1)
CASE -1
word$ = MID$(word$, 1, POS(1) - startpos%) + key$ + MID$(word$, POS(1) - startpos% + 2)
END SELECT
END IF
IF POS(1) - startpos% >= LEN(word$) - LEN(key$) AND key$ <> "" OR key$ = "" OR ins% = -1 THEN
IF key$ = "" AND mov% = 1 THEN IF POS(1) - startpos% = LEN(word$) THEN EXIT DO
LOCATE , POS(1) + mov%: PRINT key$;
ELSE
LOCATE xx%, startpos%: PRINT MID$(word$, 1, yy% - startpos%); key$;: yy2% = POS(1): PRINT MID$(word$, yy% - startpos% + 2);: LOCATE xx%, yy2%
END IF
EXIT DO
LOOP
END IF
RETURN
wash:
IF POS(1) >= startpos% AND word$ <> "" AND POS(1) - startpos% < LEN(word$) THEN
LOCATE xx%, startpos% + LEN(word$) - 1
PRINT " ";
LOCATE xx%, yy%
END IF
RETURN
delete:
IF POS(1) - startpos% = 0 THEN
word$ = MID$(word$, 2)
ELSE
word$ = MID$(word$, 1, POS(1) - startpos%) + MID$(word$, POS(1) - startpos% + 2)
END IF
PRINT MID$(word$, yy% - startpos% + 1);: LOCATE xx%, yy%
RETURN
END SUB
SUB show_collapse (my)
SCREEN 0, 0, 1, 0
PALETTE 4, 8
COLOR 15, 4
tmp$ = _TRIM$(MID$(clipper$(my), 151))
i = 0
CLS
DO UNTIL INSTR(tmp$, CHR$(255)) = 0
i = i + 1
j = INSTR(tmp$, CHR$(255)) - 1
tmp2$ = MID$(tmp$, 1, j)
PRINT MID$(tmp2$, 1, _WIDTH)
IF i >= _HEIGHT - 1 THEN EXIT DO
tmp$ = MID$(tmp$, j + 2)
LOOP
SCREEN 0, 0, 1, 1
COLOR 7, 0
END SUB
SUB drag_hl (drag)
LOCATE , , 0 ' Hide cursor
y = CSRLIN
WHILE -1
_LIMIT 120
WHILE _MOUSEINPUT: WEND
my = _MOUSEY
x = SGN(my - y)
IF x THEN
IF oldx AND x <> oldx THEN
IF retrace THEN retrace = 0 ELSE retrace = 1
LOCATE y, 1
END IF
DO UNTIL y = my OR y = 1 AND x < 0 OR y = _HEIGHT - 1 AND x > 0
IF _MOUSEBUTTON(1) = 0 THEN EXIT WHILE
IF retrace = 0 THEN y = y + x
LOCATE y, 1
IF clipper%(y) = 0 THEN COLOR 14, 1: clipper%(y) = 1 ELSE COLOR 7, 0: clipper%(y) = 0
PRINT MID$(clipper$(y), 1, _WIDTH);
retrace = 0
LOOP
oldx = x
END IF
IF _MOUSEBUTTON(1) = 0 THEN EXIT WHILE
WEND
COLOR 7, 0
drag = 0
END SUB
Pete
|
|
|
Simple drawing that fades to background. |
Posted by: Dav - 11-04-2022, 10:27 PM - Forum: Programs
- Replies (8)
|
|
Started playing with a smooth drawing routine and a screen fading method. Curious as to what could become of using this method.
- Dav
Code: (Select All) 'Simple drawing that fades to background.
'Coded by Dav, NOV/2022
SCREEN _NEWIMAGE(1000, 800, 32)
DO
WHILE _MOUSEINPUT: WEND
mx = _MOUSEX: my = _MOUSEY
mb1 = _MOUSEBUTTON(1)
IF mb1 THEN
IF stilldown = 1 THEN
stepx = lastmx - mx
stepy = lastmy - my
length = INT((stepx ^ 2 + stepy ^ 2) ^ .5)
dx = stepx / length
dy = stepy / length
FOR i = 0 TO length
FOR d = 1 TO size%
CIRCLE (mx + dx * i, my + dy * i), d, clr&
NEXT
NEXT
ELSE
size% = RND * 20 + 5 '<=== brush size
clr& = _RGB(RND * 255, RND * 255, RND * 255) '<=== brush color
FOR d = 1 TO size% STEP .2
CIRCLE (mx, my), d, clr&
NEXT
END IF
lastmx = mx: lastmy = my
stilldown = 1
ELSE
stilldown = 0
END IF
LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(32, 32, 32, 32), BF
_DISPLAY
_LIMIT 30
LOOP
|
|
|
|