If you have some trick or function to share post it here, if you want. Have a happy day.
I want to make an index for organizing this thread. Page one Post #2: *_Function to trim leading spaces from a string. *_Function for an int. *_If you need pi. *_Number odd or even? Post #3: *_Function 5 stars Post #4: Post #5: *_Reference Object Variable Post #6: *_Function Return array. *_Set print decimals to ,,,(comma). *_Interrupt Timer. *_Print command. Is there a trick to display horizontally? Post #7: *_Function called "Cartman as Roadrunner" Post #8: *_This is a function to print large numbers. Post #9: *_Tutorial Basic! online. Post #10: *_Function will sort a 2D Numeric Array.
Page two Post #1 #2: *_Some Date Functions Post #3 #4: Post #5: *_Basic Formula-parser Post #6: *_Function for drawing round rectangles, *_Rounded-bicolor button Post #7: *_Function allows to transform a number into a string Post #8: *_Function to create a pie chart Post #9: *_WAIT Command, *_ Put more entries with the INPUT command Post #10: *_Copy Files and Directories, *_Copy a directory full of files
Page three Post #: Post #: Post #: Post #: Post #: Post #: Post #: Post #:
Last edited by IAO on Thu Apr 10, 2014 7:23 am, edited 27 times in total.
GR.OPEN 255,0,0,0,0,1 PAUSE 1000 GR.COLOR 255,255,255,0,0 Left=0 Top=0 FOR i=1 TO 5 Pointer=Build(Left,Top) LIST.ADD Pointers,Pointer NEXT i
LIST.SIZE Pointers,Lsize FOR i=1 TO Lsize newTop=i*5 newLeft=i*10 newRight=200-i*5 newBottom=50-i*3 LIST.GET Pointers,i, objectP GR.MODIFY objectP,"left",newLeft GR.MODIFY objectP,"top",newTop GR.MODIFY objectP,"right",newRight GR.MODIFY objectP,"bottom",newBottom NEXT i GR.RENDER DO UNTIL 0
Last edited by IAO on Tue Oct 30, 2012 7:19 am, edited 1 time in total.
My newest function is called "Cartman as Roadrunner" You've seen how Roadrunner moves:
! CartmanAsRoadrunner ! by tony_gr ! basic! v1.69
FN.DEF CartmanAsRoadrunner (x,y,r) GR.BITMAP.LOAD cc,"cartman.png" AUDIO.LOAD au,"whee.mp3" GR.BITMAP.DRAW c,cc,x+r,y GR.RENDER PAUSE 500 FOR k=1 TO 5 FOR i=0 TO 2*3.14159 STEP 0.25 myX=(x+r*COS(i)) myY=(y+r*SIN(i)) GR.MODIFY c,"x", myX GR.MODIFY c,"y", myY GR.RENDER PAUSE 10 NEXT i NEXT k AUDIO.PLAY au FOR l=MyX TO 880 STEP 25 GR.MODIFY c,"x", l GR.RENDER NEXT FN.END
This is a function to print large numbers. It is a beta function. I'm improving it. If someone has something better is welcome.
I was thinking about this. It's useful not only in math programs, but also in games. Consider a player that has more than 999999999 points. What to tell him, that he has 1E07 points? I wrote a more generic and elegant function to display big numbers:
! big numbers by tony_gr ! basic! v1.71
FN.DEF bigNumbers$(number) a$=FORMAT$("#####################.################",number) a$=REPLACE$(a$," ","") % trim leading spaces ! trim ending 0s of decimal numbers a=IS_IN(".", a$) IF a>0 THEN l=LEN(a$) DO d$=MID$(a$,l,1) IF d$="0" THEN a$=LEFT$(a$,l-1) l=l-1 UNTIL MID$(a$,l,1)<>"0" IF ABS(number)<1 THEN a$=REPLACE$(a$,".","0.") ENDIF FN.RTN a$ FN.END
! test num= 1234567890123.0123456 PRINT num s$= bigNumbers$(num) PRINT s$
num= -0.0123456 PRINT num s$= bigNumbers$(num) PRINT s$ END
And before having any objections on basic!s arithmetics please take a look at the "Numbers" section in the manual...
_________________ Check out my RFO Basic! apps & games: , onGoogle Play Store! Slide me!, Amazon, or AppsLib!
Fn.Def QuickSort(A, SCol, ACols, ARows, D] !SCol is Column to be sorted on !ACols is number of Columns in Array !ARows is number of Rows in Array !D is Sort Direction 0 = Desc, 1 = Asc
I = 1 J = ARows X = A[(1 + ARows) / 2, SCol] If D Then While (I <= J) While (A[I, SCol] < X & I < ARows) I = I + 1 Repeat While (X < A[J, SCol] & J > 1) J = J - 1 Repeat If (I <= J) Then For C = 1 To ACols Y = A[I, C] A[I, C] = A[J, C] A[J, C] = Y Next I = I + 1 J = J - 1 End If Repeat Else While (I <= J) While (A[I, SCol] > X & I < ARows) I = I + 1 Repeat While (X > A[J, SCol] & J > 1) J = J - 1 Repeat If (I <= J) Then For C = 1 To ACols Y = A[I, C] A[I, C] = A[J, C] A[J, C] = Y Next I = I + 1 J = J - 1 End If Repeat End If If (J > 1) Then Call QuickSort(A, SCol, 1, J, D) If (ARows > I) Then Call QuickSort(A, SCol, I, ARows, D) Fn.End
Users browsing this forum: No registered users and 1 guest
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 post attachments in this forum