Page 1 of 1

copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 1:37 pm
by AndyRed64
Last time I was on here I learnt the command DLINE from the toolkit. Thank you.

Does anyone know if I can copy a block of lines in a loaded program so I get a second copy later on in the same program?

Thank you

Andrew

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 1:38 pm
by AndyRed64
I have looked in the toolkit manual but the forum has classifed me as "ROM Dongle" for a reason :D
AJ

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 2:11 pm
by dilwyn
This is a feature I would dearly love to see added to editing BASIC programs!

As I normally use SBASIC (as opposed to SuperBASIC), when I want to block copy code I either load the program into a text editor (saved programs are basically just plain text), or save the block of code to be copied to a ramdisc, load it into an SBASIC job, renumber it there, save again, then merge with the original program.

Very clumsy, but once you've done it a few times, it just becomes normal.

e.g. LOAD mybigprogram_bas
SAVE ram1_tmp_bas;line1 TO line2 (line number range to be copied)
SBASIC
LOAD ram1_TMP_bas (into the new SBASIC)
RENUM as required
SAVE ram1_TMP_bas
switch back to original BASIC program
MERGE ram1_tmp_bas

It looks long winded and clumsy, I know. I've just got so used to doing this over the years I don't give it a second thought.

Not tried this on Minerva MultiBASIC, don't know if it would work on that.

Another approach might be to learn to use Tim Swenson's SSB (Structured Super BASIC) https://dilwyn.theqlforum.com/program/index.html. It allows you to write QL BASIC programs without line numbers using an editor, making it very easy to do things like copying blocks and other things not so easy to do in standard QL BASIC. Probably the nearest thing we have to an IDE (Integrated Development Environment) for developing QL BASIC programs.

Might also be useful for you to look at the MasterBasic software, originally from Ergon Development, now available as freeware. It's been a while since I last used it, but I remember it being very useful when writing BASIC programs. https://dilwyn.theqlforum.com/program/mbs151d.zip

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 4:35 pm
by AndyRed64
Dilwyn

That is super useful. Thank you very much. I think I will try the ram disc idea

Andrew

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 5:11 pm
by pjw
AndyRed64 wrote: Sat Aug 23, 2025 1:37 pm <>
Does anyone know if I can copy a block of lines in a loaded program so I get a second copy later on in the same program?
<>
For short snippets of code I would normally just add a digit to each line I want to copy. If your code is numbered, say, 100 to 1000 and you want to copy 160 to 200 to the end, then just add 2 to the front of each line: 2160, 2170,.. 2200. Then RENUMber.

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 9:22 pm
by AndyRed64
Dilwyn

When I entered the command SBASIC I got an error message so I tried the following and that seemed to work too:

LOAD mybigprogram_bas
SAVE ram1_tmp_bas;line1 TO line2 (line number range to be copied)
NEW
LOAD ram1_TMP_bas
RENUM as required
MERGE mybigprogram_bas

I guess that does about the same thing - but I may be doing something silly ...

Thanks

Andrew

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 9:23 pm
by AndyRed64
Thank you PJW
AJ
pjw wrote: Sat Aug 23, 2025 5:11 pm
AndyRed64 wrote: Sat Aug 23, 2025 1:37 pm <>
Does anyone know if I can copy a block of lines in a loaded program so I get a second copy later on in the same program?
<>
For short snippets of code I would normally just add a digit to each line I want to copy. If your code is numbered, say, 100 to 1000 and you want to copy 160 to 200 to the end, then just add 2 to the front of each line: 2160, 2170,.. 2200. Then RENUMber.

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 10:29 pm
by dilwyn
AndyRed64 wrote: Sat Aug 23, 2025 9:22 pm Dilwyn

When I entered the command SBASIC I got an error message so I tried the following and that seemed to work too:

LOAD mybigprogram_bas
SAVE ram1_tmp_bas;line1 TO line2 (line number range to be copied)
NEW
LOAD ram1_TMP_bas
RENUM as required
MERGE mybigprogram_bas

I guess that does about the same thing - but I may be doing something silly ...

Thanks

Andrew
That's why I mentioned that I normally use SBASIC on an SMSQ/E system. Standard QL SuperBASIC doesn't have SBASIC jobs (which are like second copies of SuperBASIC in some ways - the SBASIC command starts a new copy of BASIC).

For ordinary QDOS/SuperBASIC, you can't use the SBASIC command. So the way you described would be the way to do it on those systems.

For short bits of code to be copied (since you have to do it one line at a time), Per's suggestion is better and quicker.

I can dream that one day someone far cleverer than me will write a proper development environment for QL BASIC. I've been using the IDE in Basics like QBasic on the PC and although it's old-fashioned and clunky, it works quite well, allowing you to do things like copying and pasting bits of code, search/replace and debugging such as setting breakpoints.
Edit menu in QBX
Edit menu in QBX
Debug menu in QBX
Debug menu in QBX

Re: copy of block of lines from a program to another part of the same program

Posted: Sat Aug 23, 2025 11:02 pm
by Derek_Stewart
Hi,

QD can load S*BASIC files and allow full text editing, and use the SBAS/QD Thingbto run the programme.