Christmas Fun

Anything QL Software or Programming Related.
User avatar
Andrew
Aurora
Posts: 796
Joined: Tue Jul 17, 2018 9:10 pm

Re: Christmas Fun

Post by Andrew »

Derek_Stewart wrote: Thu Dec 29, 2022 9:10 am But if the program was written in the emulator and saved in a QL environment, this problem would not occurr.
This program was written and zipped in a QL Environment. Some other user modified it outside the QL.
When I write small programs I use a Ql environment.
But when I write larger programs I prefer to use Notepad++ because:
- It has syntax highlighting
- I can easily copy and move large chunks of code
- I do not have to bother with line numbers until I test something (and then it is very easy to renumber everything)
- I can open several documents at the same time and copy-paste between them
- It has a very flexible search in a doc or across several docs at the same time
- I can use file compare to check for differences between several versions of the same program (very handy when you introduce a new bug :D )
- I can easily integrate it with QPCII by having the doc on a dos drive and using Shift-Enter in QL Commander to LRUN it
- Notepad++ automatically reloads the doc if/when changes were saved in QL environment
and much more
Last edited by Andrew on Thu Dec 29, 2022 7:45 pm, edited 1 time in total.


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Christmas Fun

Post by dilwyn »

For anyone who runs into the problem of having carriage returns at the end of lines of S*BASIC, a simple BASIC program like this will remove those pesky carriage returns. Minerva is actually useful with this problem, as the extended character set can indicate the CR at the end of the MISTake line with i's miniature CR character.

Since _bas files are plain text files, you can simply step through them INPUTting line by line, stripping the carriage return at the end of a line. And if you get an editor which adds LF-CR in that order instead of CR-LF, you'd just check for a carriage return at the start of a line instead.

Shouldn't cause any changes to BASIC programs which already have the correct end of line characters, but always keep the original JUST IN CASE!

Code: Select all

100 REMark UNCR
110 CLS : CLS #0
120 INPUT #0,'Source file > ';ip$
130 IF ip$ = '' THEN STOP
140 INPUT #0,'Output file > ';op$
150 IF op$ = '' THEN STOP
160 OPEN_IN #3,ip$
170 OPEN_NEW #4,op$
180 REPeat loop
190   IF EOF(#3) : EXIT loop
200   INPUT #3,t$ : IF t$ = '' THEN PRINT #4, : NEXT loop
210   IF t$(LEN(t$)) = CHR$(13) THEN
220     IF LEN(t$) > 1 THEN t$ = t$(1 TO LEN(t$)-1) : ELSE t$ = ''
230   END IF
240   PRINT #4,t$
250 END REPeat loop
260 CLOSE #3
270 CLOSE #4
280 PRINT#0,'PROGRAM FINISHED.'
290 STOP


User avatar
Cristian
Aurora
Posts: 965
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Christmas Fun

Post by Cristian »

dilwyn wrote: Thu Dec 29, 2022 1:53 pm a simple BASIC program like this will remove those pesky carriage returns.
Thank you!


Derek_Stewart
Font of All Knowledge
Posts: 3975
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Christmas Fun

Post by Derek_Stewart »

Andrew wrote: Thu Dec 29, 2022 12:08 pm
Derek_Stewart wrote: Thu Dec 29, 2022 9:10 am But if the program was written in the emulator and saved in a QL environment, this problem would not occurr.
This program was written and zipped in a QL Environment. Some other user modified it outside the QL.
When I write small programs I use a Ql environment.
But when I write larger programs I prefer to use Notepad++ because:
- It has syntax highlighting
- I can easily copy and move large chunks of code
- I do not have to bother with line numbers until I test something (and then it is very easy to renumber everything)
- I can open several documents at the same time and copy-paste between them
- It has a very flexible search in a doc or across several docs at the same time
- I can use file compare to check for differences between several versions of the same program (very handy when you introduce a new bug :D )
- I can easily integrate it with QPCII by having the doc on a dos drive and using Shift-Enter in QL Commander to LRUN it
- Notepad++ automatically reloads the doc if/when changes were saved in QL environment
and much more
Hi Andrew,

Sounds a good way to write software.

I will give it a go.

But I prefer to use QD to write SBASIC, Assembler or C as there is a "Thing" that can load the compiler or interpreter.

QD can delete all the control codes that are causing problems, quoted here it only lacks Syntax Colouring, but MicroEmacs can do Syntax Colouring in High Colour QL environments.

Saying all that, why use vscode to write the program and have a macro to load the program into the emulator.


Regards,

Derek
User avatar
Andrew
Aurora
Posts: 796
Joined: Tue Jul 17, 2018 9:10 pm

Re: Christmas Fun

Post by Andrew »

Derek_Stewart wrote: Thu Dec 29, 2022 9:56 pm ... it only lacks Syntax Colouring, but MicroEmacs can do Syntax Colouring in High Colour QL environments.
I never got the hang of MicroEmacs and how the commands work. Also I never found a way to apply Syntax Colouring to sbasic programs :(
And I really tried to use it :cry:
So for now I stick with QD


User avatar
tofro
Font of All Knowledge
Posts: 2702
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Christmas Fun

Post by tofro »

On the standard QL black box I tend to use MasterSpy (available from the usual place), which really was a very sophisticated and lightning-fast editor for its time. Highly recommended.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Christmas Fun

Post by bwinkel67 »

Sorry for the hiccup. I had made a quick change as I screwed up the RedoBackground function. It wasn't initially working in SuperBASIC and I thought it was because I needed to set the BackDX variable to 0 in PutSantaFrame, but that just caused the stars not to re-print after the Santa gif flew by, so the quick fix was to remove that line (I discovered that only after my wife noticed the lack of stars behind Santa and I had already posted everything, including the gifs...so I redid all that stuff, including animated gif generation, very quickly -- most of it turned out ok).

The actual fix was that there were two variables: BackDX and backDX (the only difference being upper vs lower case) and those somehow conflicted in SuperBASIC (after drawing the Santa gif the program would error out), so I changed the local one in RedoBackground to newBackDX and that seemed to have fixed it for me. I'm not an SBASIC/SuperBASIC expert as I don't program in it as much, so I don't know all the ins and outs of the nuances of variable naming and difference between the two BASIC versions, etc. I also got rid of the % symbols in front of integer variables, since that also caused things not to run.

When I initially debugged the program I did that within a QL emulator in SuperBASIC (JS ROM) to get it to run and saved it that way, so no CR/NL issues. It was the quick fix I made in Notepad to edit out a bad line that caused the hiccup (I convert it to DOS, edit it, and then have to convert it back to UNIX -- see utilities below). I compress these into zip via the Windows 7-Zip tool since it's very compatible and easy to use (I find Windows Zip sometimes doesn't work with certain things...like the web version of DOSBox for one). When I write a BASIC program from scratch (i.e. like my ZXSimultar Elite program), sometimes I just use Notepad to type something up, because it's an easy point and click environment. But I usually finish it off in a QL emulator, or if I'm feeling nostalgic, on my actual BBQL.

I re-uploaded it to the original post (so no one would trip up again) as well as here. I double checked to make sure it looked like a big blob in Notepad under Windows. Note that there is a difference between this and Andrew's version, where this loops continuously and rearranges the splash screens.

Santa2.zip
(43.02 KiB) Downloaded 53 times

Also, when going back and forth between emulators and Windows, I use these utilities...they are drag and drop and pretty convenient:

dos2unix.zip
(97.66 KiB) Downloaded 45 times
Last edited by bwinkel67 on Sat Dec 31, 2022 2:31 am, edited 2 times in total.


User avatar
Andrew
Aurora
Posts: 796
Joined: Tue Jul 17, 2018 9:10 pm

Re: Christmas Fun

Post by Andrew »

bwinkel67 wrote: Fri Dec 30, 2022 10:22 pm The actual fix was that there were two variables: BackDX and backDX (the only difference being upper vs lower case)
SuperBasic does not differentiate between upper and lower case.
There were 2 variables with different names - one global BackDX% and one local backDX.
As pre-Minerva ROMs don't know about integer variables when you deleted the % the 2 variables ended up having the same name, hence the confusion.
Yes, it would have been better if I had named the local variable something different from the start.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Christmas Fun

Post by bwinkel67 »

Andrew wrote: Fri Dec 30, 2022 10:56 pm There were 2 variables with different names - one global BackDX% and one local backDX.
Ah, thank you for pointing that out...it was a cascade of changes on my part that caused the conflict. Feel a bit better now since I was worried some BASIC was case sensitive and some was not. Weird though that the local would conflict with the global...usually the local wins out, no?


Post Reply