Jump to content
IGNORED

19 Carrots of Gold


sometimes99er

Recommended Posts

PrescanIt!

 

Yes! Now that you mention the name, that sound familiar. Now I just have to locate it.

 

Sometimes, if you have not yet read it, I HIGHLY suggest you read "Watership Down" for some inspiration. One of my all time favorite books. :)

 

Read about Hazel & Bigwig in that book in 7th grade. I bought it from the Scholastic Book Club. I remember it being a good read. Other than those two names mentioned, that is all I remember.

Link to comment
Share on other sites

Really cool, sometimes99er!!! Hoping for a new Rabbit Trail... One that has a bit of replay value. :D

 

 

A challenge for you, Sinphaltimus... Write your own CALL CLEAR subprogram, and replace it in the following code chunk:

 

 

100 CALL CLEAR

110 PRINT "I CAN WRITE A NEW SUBPROGRAM!!"

120 END

 

 

Replace CALL CLEAR with a SUB of your own design and call it CLR. :D

 

 

Is it really this simple?

 

100 CALL CLR

110 PRINT "I CAN WRITE A NEW SUBPROGRAM!!"

120 END

130 SUB CLR::CALL CLEAR::SUBEND

 

Also, sub/subend are excluded from the prescan. Gosub/return are not excluded from the prescan?

 

In terms of subexit, there can be a condition set within a sub (if/then/else) that uses subexit to leave the sub without needing to hit the subend?

 

For redundancy:

This mock code is the same as the mock code that follows it?

 

10 blah blah blah

20 blah blah blah

30 gosub 100

40-90 blah blah blah

100 do this that and the other thing.

110 if the other thing=this then return else 120

120 if the the other thing = that then return

130 this=that

140 return

 

**********************

 

10 blah blah blah

20 blah blah blah

30 call mock

40-90 blah blah blah

100 sub mock

105 do this that and the other thing.

110 if the other thing=this then subexit else 120

120 if the the other thing = that then subexit

130 this=that

140 subend

Edited by Sinphaltimus
Link to comment
Share on other sites

It can be that simple, yes... But I was hoping you would write a routine that cleared the screen without using CALL CLEAR. :D

 

Hint:

 

You can do it in one multi-statement line using one loop and a graphics command. There are always more than one way to skin a cat, so try to find the fastest method!!!

  • Like 1
Link to comment
Share on other sites

It can be that simple, yes... But I was hoping you would write a routine that cleared the screen without using CALL CLEAR. :D

 

Hint:

 

You can do it in one multi-statement line using one loop and a graphics command. There are always more than one way to skin a cat, so try to find the fastest method!!!

 

I know what you mean. Magelion has generated code that clears the screen in this way (using a call char). I guess I misunderstood the original challenge.

 

Is my understanding correct (mock code examples) - I have so much rewriting to do but I have to stop because I do not know if it is OK to call one subprogram from within another.

Link to comment
Share on other sites

 

I know what you mean. Magelion has generated code that clears the screen in this way (using a call char). I guess I misunderstood the original challenge.

 

Is my understanding correct (mock code examples) - I have so much rewriting to do but I have to stop because I do not know if it is OK to call one subprogram from within another.

 

My fault for derailing the thread... Lets move this topic elsewhere. :)

Link to comment
Share on other sites

Is it OK to call a subprogram from within another subprogram?

 

As far as I know, yes. This local scope feature is particularly interesting for MERGEing program parts because you need not care about variable names. That way I wrote a highscore list and glued it to some Extended Basic programs, for example, to Dive Bomber.

Link to comment
Share on other sites

Is it OK to call a subprogram from within another subprogram?

you can call subs from other subs no problem but you can do no recursion at all. sub a can call sub b which in turn can call sub c etc etc. But you cannot have sub a call sub b which then calls sub a nor can you have a sub call itself.

 

It seems complicated but just remember before a sub can be called a second time, it's subend or subexit statement must have been executed.

 

It's a neat programming concept but a lot limited in this fact. GOSUB allows recursion why not CALL SUBs ?

  • Like 1
Link to comment
Share on other sites

GOSUB allows recursion why not CALL SUBs ?

Yep, the error message is pretty specific: * RECURSIVE SUBPROGRAM CALL IN ...

 

Some of the idea is that CALL SUBs can have local variables. Recursive calls could then have the need for an unspecified number of variables.

 

And I think variables are allocated before running a program (prescan). I think this includes local variables too.

 

:)

Link to comment
Share on other sites

OK, TIMT can now filter out the additional comments; it will only allow a BASIC line without line number when it starts with a ! or REM token and then discard it, hence it will be possible to paste listings with additional non-line comments. For the automatic uppercase translation I'd have to think a bit longer (or you simply stay with uppercase :) ).

 

Works. You can now paste the program as you showed it at the start (without the "run", of course) into a file in a disk image. I found that all unquoted strings are uppercase... Well, not all. ... All except those in DATA lines ... grr. But this can be tested; my BASIC parser knows when a DATA line has started.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
sometimes99er, on 13 Sept 2016 - 01:24 AM, said:

(Classic99 seems to stay in CPU Overdrive when you include RUN in the paste) ;)

 

Hehe, that makes sense. Until the next call to KSCAN, it hasn't detected the end of the paste cycle (so the title bar should still say 'pasting'). I guess it's technically possible to detect being at the end, but I think I'll leave it like this since you've found a nice use case. ;)

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...