Jump to content
sometimes99er

19 Carrots of Gold

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

The good thing about subprograms is that their variables have local scope - unlike subroutines (GOSUB) whose variables have global scope.

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

You could go the simple route, use PRINT " " and keep executing the command on that line number up to 24, then exit the routine and reset the counter with something like COUNT=0

Share this post


Link to post
Share on other sites

 

Actually I will. ;)

magician_pulling_a_rabbit_out_of_his_hat

 

Epic book. When read as a child, it means one thing. When read as an adult, it takes on an entirely different meaning.

 

You will never see rabbits the same way again, my friend. :)

Share this post


Link to post
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. :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

This is the easiest and most simple method that I've found, but I have to ask, why would a person NOT use call clear?

 

10 A=0
20 IF A>24 THEN 60
30 PRINT " "
40 A=A+1
50 GOTO 20
60 A=0
70 PRINT "SCREEN CLEARED"
80 END

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

... but I have to ask, why would a person NOT use call clear?

As you demonstrate yourself, maybe one would like to have an effect while clearing and/or only clear part of the screen.

 

Here are some swipe effect demos:

 






Edited  by sometimes99er

Share this post


Link to post
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.

 

:)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I can't seem to paste into js99er from my cell. Grrr. I wanna bunny!

 

Ha ha, got it. Nice!

Edited by Sinphaltimus
  • Like 1

Share this post


Link to post
Share on other sites

From the Tiny Toon Adventures. Here's a Sylvester demo, an old Daffy Duck demo and this 21 Carrots with Bugs Bunny (Classic99 seems to stay in CPU Overdrive when you include RUN in the paste) ;)

 

tinytoon.gif

Edited by sometimes99er
  • Like 5

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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.

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...