Challenge: Create or Delete Lines from inside a program

Basic and Machine Language

Moderator: Moderators

wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: Challenge: Create or Delete Lines from inside a program

Post by wimoos »

Jeff,

Reordering the lines from within a Basic is indeed quite a challenge. Nowadays I would use BasEdit for such a thing.
30 years ago, with only a datasette at hand, the method would have been to save program segments under the right linenumbers in PETSCII format (using CMD...LIST...) and then merging them with the little ML program I had.

If you're interested in the RENUMBER program, I will try and reproduce it (got some experience from the ExBasic/WimBasic implementation :-))

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: Challenge: Create or Delete Lines from inside a program

Post by Boray »

Renumber program? What's wrong with Programmer's Aid's renumber command?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Challenge: Create or Delete Lines from inside a program

Post by Jeff-20 »

Boray wrote:Renumber program? What's wrong with Programmer's Aid's renumber command?
It requires the use of the Programmer's Aid cart. Haha


Sent from my iPhone using Tapatalk
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Challenge: Create or Delete Lines from inside a program

Post by Mike »

Jeff-20 wrote:It requires the use of the Programmer's Aid cart. [...]
... which, for one, is contained in the Mega-Cart. I know you own one.

Especially the toolkit of the Programmer's Aid cart is only used during program development. All the commands can only be used from direct mode. Which also means that a program written with the assistance of PA does not require PA to run afterwards.

But generally I see the very concept of BASIC extensions or any other 'black box' solution seems alien to you. You're not alone, though, otherwise I'd have seen a plethora of programs written by others using MINIGRAFIK in the meantime.


Sent from my Sony VAIO AW11XU using its keyboard
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Challenge: Create or Delete Lines from inside a program

Post by Jeff-20 »

I own a PA cart and Megacart. I think the exercise itself is interesting to me. Renumbering was not a high priority, but sometimes I like to see what can been done with the VIC in its purest form. :lol: However, I really enjoy productions outside or my personal self-imposed limitations!
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Challenge: Create or Delete Lines from inside a program

Post by Mike »

Yet you keep soliciting for help which constantly 'requires' you to think out of the box.

A good deal of your problems turn to non-issues once you'd use a better set of tools.

Sometimes you behave like a strange mechanic who not only insists to tap threads into the bare metal (which is quite usual), but also wants to fabricate the screws himself.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Challenge: Create or Delete Lines from inside a program

Post by Jeff-20 »

Hahaha I love being the crazy mechanic. I see your point, but does that logic apply to all of us? Would Photoshop for Windows make MINIGRAFIK for the VIC irrational?
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Challenge: Create or Delete Lines from inside a program

Post by Mike »

Jeff-20 wrote:Would Photoshop for Windows make MINIGRAFIK for the VIC irrational?
It probably would, if it were not for the fact that Photoshop and its kind do not provide substantial help to actually import images/pictures into the VIC-20.

Given the premise, that all this is still about programs/games/applications intended to run on the VIC-20, regardless what RAM expansion and storage media are being used, I had good reasons to write MINIGRAFIK at the time, and also good reasons to write MINIPAINT as editor for MG bitmaps. They're both good tools within their little scope. There exist at least a few games and applications which make use of them - and I have one WIP which is going to be published in the next two days. :)
Last edited by Mike on Sun Aug 31, 2014 1:15 pm, edited 1 time in total.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Challenge: Create or Delete Lines from inside a program

Post by Jeff-20 »

Mike wrote:I have one WIP which is going to be published in the next two days. :)
And I look forward to it! But you'll have to be more patient with my odd idiosyncrasies. For example, this thread gave me new insight into the GOTO command, and I'm so glad I asked. The fact you work with this computer at all should make you at least a little sympathetic to my fixations. :)
High Scores, Links, and Jeff's Basic Games page.
User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Re: Challenge: Create or Delete Lines from inside a program

Post by Schema »

This same challenge (deleting lines, anyway) was posted in Ahoy! magazine in their "Commodares" section, and they published solutions in their October 1987 issue.

I remember it vividly because I sent in a solution (using the keyboard buffer trick) and got my name published in the magazine. (I was 14.)

Here's the issue as PDF, if you want to see some of the other solutions:
http://www.bombjack.org/commodore/magaz ... 87_Oct.zip
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: Challenge: Create or Delete Lines from inside a program

Post by wimoos »

Below is the renumber program.

Step 0: Make sure your user program is running OK.
Step 1: Append the renumber program to your user program, or load the renumber program before typing in your user program, as follows:

Code: Select all

PRINT PEEK(43) (low byte of Basic start)
PRINT PEEK(44) (high byte of Basic start)
E=PEEK(45)+256*PEEK(46)-2:POKE 43,E AND 255:POKE 44,E/256
LOAD"RENUMBER"
POKE 43, <low byte of Basic start>
POKE 44, <high byte of Basic start>
Step 2: Adjust A (start) and B (incr) in line 60010 to your needs (A and B must both be >0 !)
Step 3: Execute by RUN60000
Step 4: All references that couldn't be found are filled in with 65535, check that (!).
Step 5. Delete lines 60000 and upward, as Mike showed in a previous post

All linenumber references after GOTO, GOSUB and THEN are renumbered as well as the programlines themselves.
Also ON...GOTO and ON...GOSUB statements are properly adjusted
Do not remove line 60000. This line will grow and shrink depending on new linenumbers needing less or more space than old linenumbers. After renumbering this line will possibly come out shorter or longer, so before a next renumbering run re-adjust the length of this line again using colons.
I accept no liability for the use of this program !

Regards,

Wim.

Code: Select all

60000 REM::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
60010 E=6E4:A=10:B=10:DEFFNL(X)=PEEK(X)+256*PEEK(X+1):S=A:P=43
60020 P=FNL(P):IFFNL(P+2)<ETHENS=S+B:ON-(S<E)GOTO60020:STOP
60030 V=P+4:P=43
60040 P=FNL(P):ON-(FNL(P+2)=E)GOTO60150:T=P+4
60050 C=PEEK(T):T=T+1:ON1-SGN(C)GOTO60040:ON1-(C=141)-(C=137)-(C=167)GOTO60050
60060 X$="":M=T
60070 C=PEEK(T):T=T+1:IFC=32OR(C>47ANDC<58)THENX$=X$+CHR$(C):GOTO60070
60080 R=VAL(X$):ON1-SGN(R)GOTO60140:Q=43:S=A
60090 Q=FNL(Q):N=FNL(Q+2):IFN=ETHENS=65535:GOTO60110
60100 IFN-RTHENS=S+B:GOTO60090
60110 Y$=MID$(STR$(S),2):D=LEN(Y$)-LEN(X$):IFD<0THENFORI=MTOV:POKEI,PEEK(I-D):NEXT
60120 IFD>0THENFORI=VTOMSTEP-1:POKEI+D,PEEK(I):NEXT
60130 M=M-1:FORI=1TOLEN(Y$):POKEM+I,ASC(MID$(Y$,I)):NEXT:SYS50483:T=T+D:V=V+D
60140 ON1-(C=44)GOTO60050,60060
60150 S=A:P=43
60160 P=FNL(P):IFFNL(P+2)<ETHENH=INT(S/256):POKEP+2,S-256*H:POKEP+3,H:S=S+B:GOTO60160
Last edited by wimoos on Thu Jul 16, 2015 7:53 am, edited 10 times in total.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Vic20-Ian
Vic 20 Scientist
Posts: 1214
Joined: Sun Aug 24, 2008 1:58 pm

Re: Challenge: Create or Delete Lines from inside a program

Post by Vic20-Ian »

Mike wrote:Yet you keep soliciting for help which constantly 'requires' you to think out of the box.

A good deal of your problems turn to non-issues once you'd use a better set of tools.

Sometimes you behave like a strange mechanic who not only insists to tap threads into the bare metal (which is quite usual), but also wants to fabricate the screws himself.
I found this interesting.

The first statement is a statement of fact with a hint of criticism or a view that innovating is wrong.

The second statement is likely correct in the paradigm that additional tools are available or acceptable.

The second statement implies that innovation of other tools is acceptable within the paradigm of additions.

The first implies innovation is less acceptable in the paradigm without additions when additions exist.

The inconsistent view of of innovation is interesting. It could lead one to to think that there is a bias toward additions vs. raw machine.

i.e. maybe we should recommend to sell the Vic 20 and buy a new console or pc where the problems (e.g. no sprites) are all resolved by someone else with new additions like new graphic processor, more memory etc.

More is not always better.

I prefer Jeff's approach to keep pushing the limits, it seems he treats the Vic like a cryptic crossword to be solved where the solution once revealed is elegant and unexpected.

What progress would there be without innovation of new challenges and solutions ;-)
Vic20-Ian

The best things in life are Vic-20

Upgrade all new gadgets and mobiles to 3583 Bytes Free today! Ready
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Challenge: Create or Delete Lines from inside a program

Post by Jeff-20 »

Thanks, Ian! :D
High Scores, Links, and Jeff's Basic Games page.
Post Reply