Post 'em up here, like this:

Routine Title
Details about routine, including inputs, outputs, comments, destroyed, etc.

Code:
:Here you have
:The code to your
:fragment or routine




A compiled list of routines:
Filled Circle
X=x-coordinate of center
Y=y-coordinate of center
R=radius


Code:
:For(F,0,R,[deltax]
:sqrt(R^2-F^2
:Line(X+F,Y+Ans,X+F,Y-Ans
:Line(X-F,Y+Ans,X-F,Y-Ans
:End

Calc84Maniac

Fraction Parts
Input: Ans=a number
Output: Ans={numerator,denominator}


Code:
:{Ans,1,fpart(abs(Ans
:While e-9<Ans(3
:{Ans(1),Ans(3),Ans(3)fpart(Ans(2)/Ans(3
:End
:round({Ans(1),1}/Ans(2),0

Calc84Maniac

Graph Mode
Inputs: none
Output: Ans=
0:FUNC
1:PAR
2:POL
3:SEQ
Destroys:GDBn


Code:
:StoreGDB n
:1->Tmin
:1->[thetamin]
:2->nMin
:ZStandard
:not(Tmin)+2not([thetamin])+3(nMin=1
:RecallGDB n
:Delvar GDBn

Calc84Maniac

Counting List Matches
Returns how many times A appears in LIST

Code:
:sum(LIST=A

Returns how many corresponding elements of LIST1 and LIST2 are equal
Note: dim(LIST1) must equal dim(LIST2)


Code:
:sum(LIST1=LIST2

Calc84Maniac

Mode of List
Inputs: LIST
Outputs: D=mode(LIST
E=1 if no unique mode, otherwise E=0


Code:
:0->B
:For(A,1,dim(LIST
:sum(LIST=LIST(A->C
:If C=B and D/=LIST(A
:1->E
:If C>B
:LIST(A->D
:Delvar EC->B
:End
:End

Calc84Maniac

Most efficient getkey

input: none
output: the key pressed in k (or you can change it)


Code:
Repeat Ans
getkey
end
Ans->K

Harq

Text to List
Input: List, Str1, Str2
Output: none
Takes text entered from input and changes it into list

Code:

:DelVar L1
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ? .→Str1
:ClrHome
:Input "NAME:",Str2
:For(A,1,length(Str2
:inString(Str1,sub(Str2,A,1→L1(A
:End

Lafferjm

List To Text
Input: None
Output: List changed into text
Takes numbers in list from List to text and changes it into a word on the screen

Code:

:ClrHome
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ? .→Str1
:For(A,1,dim(L1
:Output(1,A,sub(Str1,L1(A),1
:End

Lafferjm

Shuffle Elements of List
Shuffles LIST1
Destroys LIST2


Code:
:rand(dim(LIST1->LIST2
:SortA(LIST2,LIST1

Note: If you know what dim(LIST1) will be, replace it with a number.
Calc84Maniac

Formatted Text on a graph Screen

Clears the graph screen
Uses Str1 as input string


Code:
:ClrDraw
:length(Str1->A
:For(J,1,1+iPart(A/23
:For(I,1,23
:If 23J-24+I<A:Text(7J-7,4I-4,sub(Str1,23J-23+I,1
:End
:End


B-flat, KermMartian, and Calc84Maniac

Modulo division
Input:
A=Dividend
B=Divisor

Code:
:Round(BfPart(A/B),0

The Round( is in there in case of an infinitely repeating decimal (like 1/3).
The Tari, Something1990, and Calc84Maniac

Matrix to List
Input: Matrix A
Output: Lsave
Converts any size matrix to a list


Code:

:ClrHome
:1→dim(L2
:dim([A]→L1
:L1(1→A
:L1(2→B
:For(C,1,A
:For(D,1,B
:[A](C,D→L2(dim(L2)+1
:End
:End
:For(A,2,dim(L2)
:L2(A)→∟SAVE(A-1
:End
:DelVar L1DelVar L2DelVar [A]DelVar BDelVar CDelVar ADelVar DOutput(1,1,"
:0

Lafferjm

List to Matrix
Inputs: Lsave
output:Matrix [A]
Takes any size list and stores it into a matrix

Code:

:ClrHome
:Input "ROWS:",F
:ClrHome
:dim(∟SAVE)/F→G
:{F,G→dim([A]
:1→A
:1→B
:G→C
:0→D
:Repeat A=F+1
:For(E,1,G
:D+1→D
:∟SAVE(D→[A](A,E
:End
:A+1→A
:C+1→B
:C+G→C
:End
:DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GOutput(1,1,"
:0

Lafferjm

Convert A to a String [optimized]

Code:

{A,A->L2
{0,1->L1
LinReg(a+bx) Y1
Equ>String(Y1,Str1
sub(Str1,1,length(Str1)-3->Str1

Weregoose

Chop off first element of list
Input: Ans
Output: Ans

Input and output variables can be changed to whatever.

Code:
ΔList(cumSum(Ans

Calc84Maniac

Rotate a 3x3 matrix 90°
Input: Ans
Output: Ans


Code:
rowSwap(Ans<superscript T thing>,1,3

HaveACalc

Find where a number occurs in a list
Inputs:
A = A number
Output: the position of the last occurrence of A in L1


Code:
:max(seq(X(A=L1(X)),X,1,dim(L1

Ed H

Find where a number occurs in a list (Within index)
Inputs:
A = A number
B = Where it begins looking
C = Where it ends looking
Output: The position of the last occurrence of A in the portion of L1 starting from element B and ending with element C


Code:
:max(seq(X(A=L1(X)),X,B,C

Ed H

Convert Base10 to any base from 2 to 16
Inputs:
A = Number to convert
B = Base to convert to
Outputs: Str0


Code:
:"_
:For(I,1,1+ln(A)/ln(B
:Ans+sub("0123456789ABCDEF",1+int(BfPart(AB^-I)),1
:End

RthProg

Change Case of a String
Inputs:
A = (1) Change to uppercase
Str1 = String to convert
Outputs:
Str1 = Converted string


Code:
:not(A)-->A
:length(Str1)->B
:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"->Str2
:For(N,1,B
:inString(sub(Str2,26A + 1, 26),sub(Str1,N,1)
:Str1 + sub(sub(Str1,N,1) +sub(sub(Str2,26,26)+sub(Str2,1,26),26A+1,26),Ans+1,1)-->Str1
:End
:sub(Str1,B+1,B)-->Str1

RthProg and Ed H

Number to Roman Numeral
Inputs:
N = Number to convert
Outputs:
Ans & Str0 = Converted number


Code:
:" →Str0
:For(X,0,log(N
:10fPart(.1N→Z
:While Z
:sum({4.1,4.1,9.2}(Z={4,5,9→T
:sub("IVXLCDMvxlcdmni",2X+10fPart(T)+1,1)+Str0→Str0
:abs(Z-1-int(T→Z
:End
:int(.1N→N
:End
:Str0

Ed H

Find Unique Elements in Two Lists
Input L1 and L2
Output L3 (All elements that are in L1 but not L2, and elements that are in L2 but not L2.
Conditions: "0" is not a unique element, and no element is repeated within an individual list



Code:
:augment(L1,L2-->L3
:L3*seq((1=sum(not(L3-L3(X)))),X,1,dim(L3))-->L3
:SortD(L3
:sum(L3!=0)-->dim(L3

RthProg

Get Letter Routine
Inputs:
None
Outputs:
Ans = Letter (or '?' if not a letter)


Code:
:Repeat Ans
:GetKey
:End
:sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZθ   :?",Ans-5iPart(.1Ans+4),1

_Player1537 and RthProg

8X8 Sprite to Hex
Inputs:
X- x position of sprite
Y- y position of sprite


Code:
"                                       .one space
For(A,0,15
Ans+sub("0123456789ABCDEF",sum(seq(2^(3-B)pxl-Test(Y+iPart(A/2),X+B+8fPart(A/2)),B,0,3))+1,1
End
sub(Ans,2,16

RthProg

Resistor Value to Color Code
Inputs:
X = Ohm value (such as 5700)
Outputs:
A,B,C = Color code (5,7,2 = 57*10^2)


Code:
X/10^(int(log(X->A
int(10fPart(A->B
int(A->A
int(log(.1X->C

KermMartian

Check Code Speed
Inputs:
None
Outputs:
Ans = Time it took to run once


Code:
Repeat Ans=2
CheckTimer(K
End
For(A,1,Iterations
YOUR CODE TO TEST HERE
End
CheckTimer(K
(Ans-2)/Iterations

_Player1537 and MufinMcFlufin

Base-N to Decimal Converter
Inputs:
N = Base to convert from
Str1 = Number to convert
Outputs:
Ans = Converted number


Code:
sum(seq(inString(sub("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",1,N),sub(Str1,A,1)),A,1,length(Str1))seq(N^A,A,length(Str1)-1,0,~1->B

MufinMcFlufin

Base-N to Base-M converter
Inputs:
N = Base to convert from
M = Base to convert to
Str1 = Number to convert
Outputs:
Str1 & Ans = Converted number[i]

Code:
sum(seq(N^A,A,length(Str1)-1,0,~1)seq(inString(sub("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",1,N),sub(Str1,A,1)),A,1,length(Str1->B
Pause B
seq(0,A,1,int(log(B)/log(M->L1
While B
int(log(B)/log(M->C
int(BM^~Ans->L1(dim(L1)-Ans+1
B-AnsM^C->B
End
" ->Str1
For(A,1,dim(L1
Str1+sub("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",1+L1(A),1->Str1
End
DelVar L1sub(Str1,2,length(Str1)-1->Str1

[i]MufinMcFlufin
Filled Circle
X=x-coordinate of center
Y=y-coordinate of center
R=radius


Code:
:For(F,0,R,[deltax]
:sqrt(R^2-F^2
:Line(X+F,Y+Ans,X+F,Y-Ans
:Line(X-F,Y+Ans,X-F,Y-Ans
:End
Fraction Parts
Input: Ans=a number
Output: Ans={numerator,denominator}


Code:
:{Ans,1,fpart(abs(Ans
:While e-9<Ans(3
:{Ans(1),Ans(3),Ans(3)fpart(Ans(2)/Ans(3
:End
:round({Ans(1),1}/Ans(2),0
Graph Mode
Inputs: none
Output: Ans=
0:FUNC
1:PAR
2:POL
3:SEQ
Destroys:GDBn


Code:
:StoreGDB n
:1->Tmin
:1->[thetamin]
:2->nMin
:ZStandard
:not(Tmin)+2not([thetamin])+3(nMin=1
:RecallGDB n
:Delvar GDBn
Counting List Matches
Returns how many times A appears in LIST

Code:
:sum(LIST=A

Returns how many corresponding elements of LIST1 and LIST2 are equal
Note: dim(LIST1) must equal dim(LIST2)


Code:
:sum(LIST1=LIST2
Mode of List
Inputs: LIST
Outputs: D=mode(LIST
E=1 if no unique mode, otherwise E=0


Code:
:0->B
:For(A,1,dim(LIST
:sum(LIST=LIST(A->C
:If C=B and D/=LIST(A
:1->E
:If C>B
:LIST(A->D
:Delvar EC->B
:End
:End
Most efficient getkey

input: none
output: the key pressed in k (or you can change it)


Code:
Repeat Ans
getkey
end
Ans->K


P.S. Simple, but there really is a slight difference in performance between this and some other similar methods.
Text to List
Input: List, Str1, Str2
Output: none
Takes text entered from input and changes it into list

Code:

:DelVar L1
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ? .→Str1
:ClrHome
:Input "NAME:",Str2
:For(A,1,length(Str2
:inString(Str1,sub(Str2,A,1→L1(A
:End
[/i][/b]
List To Text
Input: None
Output: List changed into text
Takes numbers in list from List to text and changes it into a word on the screen

Code:

:ClrHome
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ? .→Str1
:For(A,1,dim(L1
:Output(1,A,sub(Str1,L1(A),1
:End
Shuffle Elements of List
Shuffles LIST1
Destroys LIST2


Code:
:rand(dim(LIST1->LIST2
:SortA(LIST2,LIST1

Note: If you know what dim(LIST1) will be, replace it with a number.
Scrolling text on the home screen
Uses str1
and str3


This is kind of long, but it could probably be modified to make it shorter.


Code:
:length(Str1->A
:sub(Str1,A-16,16->Str3
:DelVar BDelVar C75->S
:While 1
:1+B+B->B
:If B>=A-16
:Then
:sub(Str3,2,15)+sub(Str1,B-A+18,1->Str3
:Output(1,1,Str3
:1+C->C
:Else
:Output(1,1,sub(Str1,B,16
:End
:If C=15
:Then
:Delvar CDelVarBsub(Str1,A-16,16->Str3
:End
:For(I,1,S
:End
:End


S is the speed at which the text moves accross the screen. Use about 75 for normal speed, 50 for fast, and 100 for slower.

Note that this was written at night when I was really tired, so it probably isn't the most efficient code. Also, I am the founder of Penguin Studios, so give credit if you use it.
A slight improvement on the preceeding routine.

Scrolling text on the home screen
Uses str1
and str3


This is kind of long, but it could probably be modified to make it shorter.


Code:
:length(Str1->A
:sub(Str1,A-16,16->Str3
:DelVar BDelVar C75->S
:While 1
:1+2B->B
:If B>=A-16
:Then
:sub(Str3,2,15)+sub(Str1,B-A+18,1->Str3
:Output(1,1,Str3
:1+C->C
:Else
:Output(1,1,sub(Str1,B,16
:End
:If C=15
:Then
:Delvar CDelVarBsub(Str1,A-16,16->Str3
:End
:rand(S
:End


This one uses values for S that are about 1/3 the values for the original.
KermMartian wrote:
A slight improvement on the preceeding routine.

Scrolling text on the home screen
Uses str1
and str3


This is kind of long, but it could probably be modified to make it shorter.


Code:
:length(Str1->A
:sub(Str1,A-16,16->Str3
:DelVar BDelVar C75->S
:While 1
:1+2B->B
:If B>=A-16
:Then
:sub(Str3,2,15)+sub(Str1,B-A+18,1->Str3
:Output(1,1,Str3
:1+C->C
:Else
:Output(1,1,sub(Str1,B,16
:End
:If C=15
:Then
:Delvar CDelVarBsub(Str1,A-16,16->Str3
:End
:rand(S
:End


This one uses values for S that are about 1/3 the values for the original.


Ok, I hadn't thought about using multiple random values to slow the string down. Thanks for the improvement.

Also, for me, I would use about 1/8 of the original value to get the same speed. I am using a TI-84+ SE. 1/3 seemed a lot slower to me, but maybe the time it takes to generate random numbers on different calculators varies a lot...
Ah, that's because of an issue with one of the routines in the 84 OS. You're right, it should be 1/8 for those calcs.
Formatted Text on a graph Screen

Clears the graph screen
Uses Str1 as input string


This program displays a string on the graph screen, one character at a time. I have a variation that puts it all up at the same time and one that creates a dialogue box that I can post if anyone wants. Originally, the dialogue one was for a WindowsME program I created that had four different borders around the message.

NOTE: Make sure the string is entered correctly and is not too long for the program!!!


Code:
:ClrDraw
:length(Str1->A
:For(J,1,1+iPart(A/23
:For(I,1,23
:If 23J-24+I<A:Text(7J-7,4I-4,sub(Str1,23J-23+I,1
:End
:End


I am developing a scrolling program that can display scrolling strings of any size. Also, this is just the fast version, so you can obviously slow it down or add a Pause at the end.

Penguin Studios
For your second thing:
http://www.ticalc.org/archives/files/fileinfo/312/31206.html
Oh, what I meant was a program that created a text window with a scroll bar of any size, where the user moves up and down at their own pace. The goal I am ultimately trying to reach is an interface more like a GUI.

I have a lot of other programs, but some of them were deleted when I got my calculator replaced.

Some programs I have created:
A simple cave game
falldown (two versions)
Stick RPG, which is probably one of my best pograms - it is almost exactly the same as the game on the internet, but slightly modified to my likening.
Math program, now on version 2.1, which is my other best program that includes a whole list of functions, all programmed by me. Example functions are prime factorization, a program to convert roman numerals to decimals, a clock drawing program (also finds the number of degrees between hands), a radical simplifier, and a bunch of other stuff.

This program requires a list of the first 999 primes (I can post the code to the program I used to get it, if anyone wants), but that is it. Due to this, it only guarentees correct results for numbers up to 64,000,000, and will fail on numbers that have all prime factors greater than 7907. I am writing another program that will have guarenteed correctness to quite a bit higher.

Also, none of the programs I write contain labels Very Happy
If you feel like learning ASM, I made exactly that for Doors CS 6 ASM programs. You do things like push windows, text, input boxes, buttons, scrollbars, etc onto a stack and then call rendering and mouse routines.
Here is an improved version of b-flat's routine that uses Ans.

Code:
:ClrDraw
:"THIS IS THE TEXT
:For(J,0,length(Ans)/23
:For(I,0,22
:If 23J+I<length(Ans
:Text(7J,4I,sub(Ans,23J+I+1,1
:End
:End
Well, I have my routine use a string so that in programs heavy in "talking" such as RPGs, the program can be executed many times to save a lot of memory.

This isn't exactly a routine, but it is a program that makes making custom menus very easy. Just store to y the furthest down you want the menu to go. Note that the top and bottom line are reserved for standard text, but the code can easily be edited to include those lines. You can make menus that you press right or left to move to another menu in this way.


Code:
:2->x
:Repeat K=45 or K=24 or K=26 or K=21 or K=105
:getkey->K
:x-(K=25 and X>2)+(K=34 and X<7->7
:Output(x,1,"}
:If x>2:Output(x-1,1," "
:If x>7:Output(x+1,1," "
:End
:Return


This code was what I used to create my math program and does not produce any memory errors, no matter how much it is used.

Penguin Studios (I should probably add this to my signature instead of typing it over each time, but oh well)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page 1, 2, 3 ... 13, 14, 15  Next
» View previous topic :: View next topic  
Page 1 of 15
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement