freebasic.net Forum Index
FreeBASIC's Official Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in

Small Function Library
Goto page 1, 2  Next
 
Post new topic   Reply to topic    freebasic.net Forum Index -> Projects
View previous topic :: View next topic  
Author Message
Pritchard
Guru
PostPosted: Apr 03, 2006 11:35    Post subject: Small Function Library Reply with quote

EDIT: Here's the updated lib, release in a proper manner with a .a and everything. Sorry it was such a crap release before guys.

Download the library here (6.6kb):
http://fileanchor.com/26612-d

Commands:

SNO_LARGE - Prints a number to screen without e- or e+
SNO_FLOAT - Prints a decimal number to screen without e- or e+ (has a decimal point)

EXENAME - Give the name of the EXE (Added because FB only has EXEPATH)

IS_EVEN(expr) - Is the expression even?
IS_ODD(Expr) - Is the expression odd?

Wheel_PSET - Draws a wheel using PSET
Wheel_Line - Draws a wheel using Line
Wheel_Image - Draws a wheel using an image in PSET mode
Wheel_Alpha - Draws a wheel using an image in Alpha mode

Download the library here (6.6kb):
http://fileanchor.com/26612-d


Last edited by Pritchard on May 15, 2006 1:01; edited 16 times in total
 
Back to top
View user's profile Send e-mail
badmrbox
Sr. Member
PostPosted: Apr 03, 2006 14:51    Post subject: Reply with quote

I have trouble downloading both the rar and the zip :/
 
Back to top
View user's profile Visit poster's website
Pritchard
Guru
PostPosted: Apr 03, 2006 15:01    Post subject: Reply with quote

Are you serious? Let me see what's going on. I just switched to my Apache server so I might be doing something wrong...

EDIT: It *should* be fixed...I was beginning to wonder why the only logs were from me.
 
Back to top
View user's profile Send e-mail
Pritchard
Guru
PostPosted: Apr 03, 2006 16:09    Post subject: Reply with quote

Alright. I fixed it. How? Fileanchor baby!
 
Back to top
View user's profile Send e-mail
MystikShadows
Sr. Member
PostPosted: Apr 03, 2006 16:26    Post subject: Reply with quote

Yup, they both worked fine for me. Interesting code by the way :-)...seems to work good :-)..
 
Back to top
View user's profile Send e-mail Visit poster's website MSN Messenger
badmrbox
Sr. Member
PostPosted: Apr 03, 2006 17:44    Post subject: Reply with quote

It has now been downloaded :)
 
Back to top
View user's profile Visit poster's website
Pritchard
Guru
PostPosted: Apr 03, 2006 17:52    Post subject: Reply with quote

@Both:

Hurray! Lol. I hope someone besides me can find a use for it. I know I could use it for intro-scenes or little movies on a game.

Animations for attacks are just one of a few things I plan to use this for ^_^;;

Maybe I'll make a Sonic the Hedgehog thing where he's a theif lol. You hit him all of everyone's jewelery comes out ^_~
 
Back to top
View user's profile Send e-mail
Pritchard
Guru
PostPosted: May 10, 2006 17:39    Post subject: Reply with quote

Updated:

Redid most of the lib. It's only 6.41 kb now (Although on your disk, that will take up 8kb ^_~)

Added EXENAME - Like EXEPATH, but this prints only the exename + extenion.

Changed SNO_PRINT:

SNO_LARGE prints very large numbers without an e+, no decimal point

SNO_FLOAT print a number with a decimal point, and then the digits after it, without the e-
 
Back to top
View user's profile Send e-mail
ytwinky

PostPosted: May 10, 2006 20:05    Post subject: Reply with quote

The Sources for IsEven() and IsOdd()
..working on the others now(exept for wheel_xy) ;)
regards
ytwinky
 
Back to top
View user's profile
Pritchard
Guru
PostPosted: May 10, 2006 20:08    Post subject: Reply with quote

ytwinky wrote:
The Sources for IsEven() and IsOdd()
..working on the others now(exept for wheel_xy) ;)
regards
ytwinky
^_^;; Working on the others? They're not too hard to figure out.

EXENAME is done like so:

Print (dir(Command$(0)))

SNO_LARGE is done like so:

#define SNO_LARGE(expression) Print Format(expression, "################")

SNO_FLOAT is done like so:

#Define SNO_FLOAT(Expression) Print Format(expression, "#.################")
 
Back to top
View user's profile Send e-mail
ytwinky

PostPosted: May 10, 2006 20:11    Post subject: Reply with quote

thank you for your hint ;))
Do you play with logarithms to get the digits for SNO_.. ?
[Edit]
You see, I mean without including vbcompat.bi..
ytwinky


Last edited by ytwinky on May 10, 2006 20:14; edited 1 time in total
 
Back to top
View user's profile
Pritchard
Guru
PostPosted: May 10, 2006 20:13    Post subject: Reply with quote

No. Format is a command that comes with VBcompat.bi, which comes with FB:
Code:

#Include "vbcompat.bi"

Dim test_num As Double
test_num = 1/44

Print format(test_num, "#.###############")
Sleep
 
Back to top
View user's profile Send e-mail
ytwinky

PostPosted: May 10, 2006 20:55    Post subject: Reply with quote

hihi, I do know the Format[$]-Command, I translated the description to german..
Concerning ExeName: Don't you think that
Code:
Mid(Command$(0), Len(Curdir$)+2)
is a bit faster than
Code:
Dir(Command$(0))
?
regards
ytwinky
 
Back to top
View user's profile
Pritchard
Guru
PostPosted: May 10, 2006 21:11    Post subject: Reply with quote

I just did some tests, and niether proves *much* faster than the other on my computer.

The tests vary too much. Sometimes MID is faster, and sometimes my method's faster. I've never used MID myself, so I don't know the mechanics and why it may or may not be faster in some cases.

1001 uses of each, profile results:

Quote:
USING_PRITCHMETHOD 10.53777 47.43% 47.43%
USING_YTWINKYMETHOD 10.33171 46.50% 46.50%
 
Back to top
View user's profile Send e-mail
Zippy
Master
PostPosted: May 11, 2006 0:04    Post subject: Reply with quote

ytwinky wrote:
hihi, I do know the Format[$]-Command, I translated the description to german..
Concerning ExeName: Don't you think that
Code:
Mid(Command$(0), Len(Curdir$)+2)
is a bit faster than
Code:
Dir(Command$(0))
?
regards
ytwinky

@ytwinky - I'm not picking on you here. I am being picky.. And I cannot address the Linux side of this.

There are problems with both methods in Windoze (?elsewhere?). Try this code compiled and executed from the exe dir, then try it from another console from another dir:

Code:

Option Explicit
Print "Command0: ";command(0)
Print "CurDir:   ";curdir
Print
print "Method1:  ";Mid(Command$(0), Len(Curdir$)+2)
Print "Method2:  ";Dir(Command$(0))

Dim p As Integer
p=Len(Command(0)):While Mid(Command(0),p,1)<>"\":p-=1:Wend
Print "Method3:  ";mid(Command(0),p+1,255)
Sleep


 

Method1 fails when invoked from another dir. Both fail when ".exe" is not part of the call (dirty little trick in Windoze - if the filename extension is known then it need not be specified, and there is no way to otherwise chmod a file as executable).

Output from other dir:
Quote:

C:\>e:\freebfiles\onkey\exename-01.exe
Command0: e:\freebfiles\onkey\exename-01.exe
CurDir: C:\

Method1: reebfiles\onkey\exename-01.exe
Method2: exename-01.exe
Method3: exename-01.exe

C:\>e:\freebfiles\onkey\exename-01
Command0: e:\freebfiles\onkey\exename-01
CurDir: C:\

Method1: reebfiles\onkey\exename-01
Method2:
Method3: exename-01


Method3 fails, sorta, you still have to check for that missing ".exe" on Windoze. I'd rather use regexp but am having diff with the Windoze version (my fault, surely). Method3 can't work on (shudder) Linux without slash-mod.

Method1 and Method2 work when the exe is invoked using "Start Run" or from Explorer, which is what normal users.. use. I don't mean to pick.
 
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    freebasic.net Forum Index -> Projects All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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



sf.net phatcode