Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CommonStatements.bi: Useful Defines for Programming
#1
Hi People all over the world!

You know these statements which appear in every code quite often, such as "Dim As Integer". You type them time for time, and get anoyed, because you type the wrong letter very often.
Now, why can't these words be shorter?

They can!
I've collected some of these most-used words, created two .BI-Files.

Now, there they are:
http://nopaste.freebasic.de/index.php?view=334
http://nopaste.freebasic.de/index.php?view=335

The first one is the basic one, containig quite a lot of defines such as this one:
#define DInt Dim As Integer
, a few Constants like
#define CL32_Red &HFF0000
#define CL8_Red 40
, some useful macros and functions and some more stuff like that.

The second one provides an extension of DRAW STRING: There's an extension that enables you to output bold and/or underlined text, to add an line break by just adding an Chr(13) in your string, an Input-Version that can FULLY replace the dirty Input in Gfx-modes, and a few text-analyzing-funcs.

I think, many people allready wrote routines like that, but unless I didn't find something like that, I think it's time to publicate.


Hope, some of you will use that
If there are any questions, just contact me. You'll get the fastest answer, if you wrote an eMail, but just posting here should be enough 8)


Have a nice day
Ciao
Dusky_Joe
ometimes, i think it is not logical to say
x = x + 1


This post is fully recycleable
Reply
#2
Nice stuff.

PS. I love your avatar.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
Thanks. As there are 77 views (unless now), do you think, anybody is going to use this collection?

However:
Yeah, the avatar...
I didn't even know, that I'm still using that one here, because I had to use it... well, I lost a bet...
Now, it wasn't the worst pic that I could chose Wink
ometimes, i think it is not logical to say
x = x + 1


This post is fully recycleable
Reply
#4
i don't mean to bring you down, but in my opinion that extensive (ab)use of macros is a really bad practice... it sort of turned me off when i saw that.
Reply
#5
Im not sure about what you mean. In fact there are only 7 macros. Or did you mean the defines for constants and short words? Well, in fact, there are lots of. But, is this an disadvantage?
Ok, there are lot's of variable descriptors that you can't use anymore, but in about eight years of programming experience i never needed to call an V. DInt or ABytPtr.
And there isn't even an speed-down, as the short words are replaced before compilation, so in programm, it's like using the original word.


However, you'll surely can show me something new, if you explained me more exactly, why using so many def's is bad practice

However, thanks for looking at these files.


Have a nice day
Ciao
ometimes, i think it is not logical to say
x = x + 1


This post is fully recycleable
Reply
#6
the compiler doesnt reoprt errors until after the macros are expanded, so if you have deep nested typos in your prog, the compiler might spit you an error you're not expecting, because it looks different after preprocessing those macros.

i just don't understand the need for a shortcut... i've written sooo many damn lines of code in fb that "dim as integer" takes me about .1 seconds now anyways ;p

ah, i don't mean to antagonize you, just saying...
Reply
#7
I agree in part that some of this is probably counter productive, but some of the ones like the colours might be handy. I noticed you have a memcpy substitute in there. I would recommend using the memcpy from crt. It has built in handling for when data falls on intervals that are not multiples of 32. If you do insist on writing your own, it is better to copy all 32bit chunks first then copy remaining bytes. Copying one byte at a time will be slow.

Heres one i wrote just for practise, to see how fast a memcopy i could write, this seemed fastest i could write without getting into the whole 32 bit alignment business.

Code:
Function memcpy cdecl (ByVal dest As Any ptr, ByVal source As Any ptr, ByVal n As uInteger) As Any ptr
  ASM
    mov    edi, [dest]   'edi = dest
    mov    esi, [source] 'esi = source
    mov    ecx, [n]      'ecx = n
    mov    edx, ecx      'edx = n
    shr    ecx, 2        'ecx = n \ 4
    and    edx, 3        'edx = n mod 4
    rep movsd         'copy 4 bytes at a time
    mov ecx, edx      'ecx = n mod 4
    rep movsb         'copy remaining bytes
  End ASM
End Function
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)