Author Topic: Basic Subroutines  (Read 4450 times)

0 Members and 1 Guest are viewing this topic.

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Basic Subroutines
« on: April 14, 2011, 11:32:41 am »
I was writing a program, and I decided it would be easier to write with subroutines, so I came up with
Code: [Select]
.Sub call to 0
1→N
While N
If Ans:Goto 0
0→N
End

Lbl 0
.Sub Code
0:End

But the sub call being still like 3 lines when it's "compressed" onto one line is almost as long as the code I wanted to put in the subroutine.  Can anyone think of a smaller way to create a subroutine call in basic?
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Basic Subroutines
« Reply #1 on: April 14, 2011, 11:36:18 am »
Hm, that's an interesting way to do it. Very nice. I don't think you'll get it much smaller though.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Basic Subroutines
« Reply #2 on: April 15, 2011, 11:11:52 am »
You don't think so? :(
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Basic Subroutines
« Reply #3 on: April 15, 2011, 12:07:37 pm »
Wow thats cool

EDIT:
Code: [Select]
For(A,1,4,3)
sub("ABCDEF",A,3)->Str1
1->N
While N
If Ans:Goto 0
0->N
End
End
Return

Lbl 0
Disp Str1
0:End

I didnt know you could do that ;D
« Last Edit: April 15, 2011, 12:12:25 pm by Broseph Radson »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Basic Subroutines
« Reply #4 on: April 15, 2011, 05:23:31 pm »
Wat? O.o

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Basic Subroutines
« Reply #5 on: April 19, 2011, 11:48:59 am »
It stores the first half of "ABCDEF" to Str1 then calls the subroutine to display it, then it stores the second half of "ABCDEF" to Str1 and does the same thing.

Produces the output:
Code: [Select]
ABC
DEF
              Done
« Last Edit: April 19, 2011, 11:50:02 am by Broseph Radson »

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Basic Subroutines
« Reply #6 on: April 19, 2011, 02:03:27 pm »
I don't think he was talking about yours. I think there was a post between yours and his that got deleted, if I remember correctly, that was kind of odd.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Basic Subroutines
« Reply #7 on: April 20, 2011, 01:42:27 pm »
Oh heh

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Basic Subroutines
« Reply #8 on: April 20, 2011, 03:19:25 pm »
Good idea, however I believe due to a bug in the way TI-BASIC functions, that will cause a huge memory leak...
There's something about Tuesday...


Pushpins 'n' stuff...


Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Basic Subroutines
« Reply #9 on: April 22, 2011, 10:25:15 am »
Oh... :(

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Basic Subroutines
« Reply #10 on: April 22, 2011, 10:30:25 am »
Broseph Radsons code will not produce a memory leak, he correctly matches both sets of Ends to their corresponding starting loops, and if he ever exits a loop with a Goto, he uses a carefully placed End to make sure the code returns to the same scope of the program, preventing the memory leak from growing.  In essence, he actually exploits the memory leak you talk about, and accounts for it such that it doesn't build up :)

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Basic Subroutines
« Reply #11 on: April 22, 2011, 10:46:53 am »
Cool ;D