 |




|
2004/02/05
Download GetCodeFromArchive.
Grab Code from this Area or the Blitz-CodeArchive or Blitz-Forums.
Wherever you have Problems to grab formatted Code this program changes
a Htm-File with Code into a pure directly usable bb-File.
In InternetExplorer save the file from CodeArchive to your Harddrive.
You'll get a File and a Folder with same name. In that Folder should
be a file called codearcs.htm.
GetCodeFromArchive.exe adds a file named codearcs.bb
2004/02/28
Some useful Routines that handle dynamic String Arrays and
something to make the use of Buttons in Apps very easy and give it a
cool look.
FileList
FileList(Filename$,Sorted,Lowcase)
Attention: The Command looks in every Subdirectory - so it can be
quite a long time if it comes back after sorting and converting to
lowercase.
Default Sorted=False
Default Lowcase=True
Examples:
MyFilelist=FileList("C:\MyPrograms")
ImageFiles=FileList(f$,True)
MyFiles=FileList(f$,True,False)
!!! Very important - When the Filelist is not used anymore you must
use
FreeDynamicStringArray(MyFilelist)
to release the used Memory.
CreateDynamicStringArray
MyStringArray=CreateDynamicStringArray()
No Parameters. Creates a Bank and
initializes a dynamic StringArray. You can have as much StringArrays
as your memory allows.
!!! Very important - When the Array is not used anymore - in most
cases at the end of the Program - you must use
FreeDynamicStringArray(MyStringArray)
to release the used Memorybank.
FreeDynamicStringArray
FreeDynamicStringArray(StringList)
Parameter is the Name you
used with CreateDynamicStringArray
Note: Use this sort of Arrays if you need Strings temporary and want
to free the used Memory immediately. Or when you do not know at
programtime how many Strings you or the user of the program may need
(for instance: Filelists - see above).
PutDynamicStringArray
PutDynamicStringArray(ArrayName,Index,TheString$)
Arrayname is the Name you
used to Create...
Index is an Integer that represents the number at which place the
String shall appear. You can not make gaps - so you have to put in one
String after the other. Or if the number is smaller than the amount of
used Strings, then the String repesenting that Number will be
replaced.
TheString$ is a String of any Size.
The Function needs the Function PokeLongString to function. This is
automatic done by the Precompiler in case you use it.
GetDynamicStringArray
MyString$=GetDynamicStringArray$(ArrayName,Index)
Arrayname is the Name you
used to Create...
Index is an Integer that represents the number at which place the
String comes from. You can not make gaps - and the system does not
check if your program works okay. So you have to care for the error
checking or better produce no error in your code.
This Function needs PeekLongString (see below)
DynamicArrayCounter
Number=DynamicArrayCounter(ArrayName)
Arrayname is the Name you
used to Create...
Returns the number of Strings that have been placed in Memory in that
Array.
CompareDynamicStringArray
Result=CompareDynamicStringArray(ArrayName,Index1,Index2)
Arrayname is the Name you used to Create the Array ...
Index1 is the Number of the first String, Index 2 the Number of the
second String.
Result is -1 if the first String is lower; 1 if the first String is
higher and 0 if both Strings are equal.
SwapDynamicStringArray
SwapDynamicStringArray(ArrayName,Index1,Index2)
Arrayname is the Name you used to Create the Array ...
Index1 is the Number of the first String, Index 2 the Number of the
second String.
As you can imagine, not the Strings will be swapped but the Pointers
to the Banklocations.
PeekLongString
MyString$=PeekLongString$(BankHandle,Position)
For the DynamicStringArrays
you do not know anything about that Function, because its called with
the right parameters.
But you can use it to Peek for Strings in a Bank you created.
And in this case its obvious how to use it anyway.
Position is a Number from 0 to Banksize-1
PokeLongString
PokeLongString(BankHandle,Position,TheString$)
As mentioned above - this
Function is called by DynamicStringArrays. But you can use it to Poke
Strings into a bank, too.
If you have to create a bank for the String keep in mind that the bank
must be 4 bytes longer than the String because the Function puts the
Stringlength as Integer at position 0 and the String will be poked
starting from Position 4 to the end.
InitW3DButtons
InitW3DButtons()
No Parameters. Place this
right after the Graphics3D - Command:
Example:
Global W3DButton_Bank,W3DButton,W3DButtonFlag
Graphics3D 1024,768,32,2
W3DButton=Loadimage("Images/W3DButton.bmp") ;always
after Graphics3D
InitW3DButtons()
CreateW3DButton(Number,XPos,YPos,ButtonText$[,HCentered[,VCentered]])
BTW: The PreCompiler would manage this for you in case you use it.
CreateW3DButton
CreateW3DButton(Number,XPos,YPos,ButtonText$[,HCentered[,VCentered]])
Each - Button gets a number
starting from 1 to infinity.
XPos - Position on Screen either right edge or centerX if HCentered is
True
YPos - Position on Screen either upper edge or centerY if VCentered is
True
ButtonText$ - What is displayed on the Buttonface. Any length - but
should fit into the screen.
HCentered - default is False - changes the horizontal
displayhotspot of the Button.
VCentered - default is False - changes the vertical diaplayhotspot
of the Button.
Needs PokeShortString
Download W3DButton.zip (2
Bitmaps: WindowsXP-Style and Windows98-Style)
or make your own Bitmap 480x23 Pixel - that's 240x23 normal View
and 240x23 for Mouseover View.
ShowAllW3DButtons
ShowAllW3DButtons()
No Parameters must be placed
in the Loop between repeat / Flip() / Until or so
SetBuffer BackBuffer() should be active when the Function is called.
This Function calls ShowW3DButton(ButtonNumber)
ShowW3DButton
ShowW3DButton(ButtonNumber)
Instead of ShowAllButtons
you may display the Buttons you need for special situations. It
is recommended that you better use EmptyW3DButton(ButtonNumber) (see
there for further explanations) in connection with
ShowAllW3DButtons().
TestAllW3DButtons
Result=TestAllW3DButtons()
Returns the selected Buttonnumber or Zero if none is selected.
This Function calls TestW3DButton(ButtonNumber)
TestW3DButton
result=TestW3DButton(ButtonNumber)
Instead of TestAllButtons
you may test only the Buttons you need for special situations. It
is recommended that you better use EmptyW3DButton(ButtonNumber) (see
there for further explanations) in connection with ShowAllW3DButtons()
and TestAllW3DButtons(). Use it as you need it.
EmptyW3DButton
EmptyW3DButton(ButtonNumber)
This Function is useful for
several reasons. When you're working on Program you may change your
screenlayout or certain functions that were connected to a Button will
never be used. Instead of changing all ButtonNumbers and Positions you
can make the Button empty and later change it to CreateButton again.
Another reason is that you want to disable buttons in a special
situation and create them later again.
If ButtonNumber is 1 higher than the last created Button then an Empty
Button will be created.
If its lower or equal, then the Button will be made empty and the
FreeBank is called. So enabling it later, you must use CreateW3DButton
again.
RightW3DButtonPos
XPosition=RightW3DButtonPos(ButtonNumber)
Returns the Position of the
right edge of the requested Button. Very useful, because depending on
which font is used and how long the ButtonText is, this Position
varies. To make your design look clean you give the resulting
XPosition plus an always equal space to the following CreateW3DButton
Command.
Example:
CreateW3DButton(16,RightW3DButtonPos(15)+3,"I am 3 Pixels away
from Button 15")
FreeAllW3DButtons
FreeAllW3DButtons()
Give the Memory back to the
Owner when you do not need it anymore. Makes sure that no unwanted
reactions occur when you closed your program.
Calls FreeW3DButton(ButtonNumber)
FreeW3DButton
FreeW3DButton(ButtonNumber)
Does what is says. You
should let the Command FreeAllW3DButtons() do the job.
PeekShortString
MyString$=PeekShortString$(BankHandle,Position)
For the Button-Commands you do not know anything about that Function, because its called with
the right parameters.
But you can use it to Peek for Strings in a Bank you created.
And in this case its obvious how to use it anyway.
Position is a Number from 0 to Banksize-1
PokeShortString
PokeShortString(BankHandle,Position,TheString$)
As mentioned above - this
Function is called by Button-Commands. But you can use it to Poke
Strings that are shorter than 65535 Bytes into a bank, too.
If you have to create a bank for the String keep in mind that the bank
must be 4 bytes longer than the String because the Function puts the
Stringlength as ShortInt at position 0 and the String will be poked
starting from Position 2 to the end.
|
|