|
Post by James :) (aka Madcow) on Dec 30, 2007 12:51:25 GMT -5
anything else gonna be added or are you just waiting for this to be completed tom.
|
|
|
Post by Tom Mulgrew on Dec 30, 2007 18:11:08 GMT -5
The only other thing I'm planning to add to this release is "forward declarations" of functions, using the "declare" keyword (like QBasic etc).
I also have a little bit of under-the-hood work to ensure it doesn't "leak" memory every time a text string is passed to/from a function.
Besides that I haven't planned anything else for the next version. Getting this version properly released (with working standalone exes and up-to-date documentation) is highest priority at the moment.
-Tom
|
|
|
Post by Nicky Peter Hollyoake on Dec 30, 2007 18:16:41 GMT -5
Are thy anyway to do something like this ...
Function Number(Num) Return Num EndFunction
Dim Array(3)
Array = Number(3)
(just an exemple)
I want all the array to return 3 in this exemple.
|
|
|
Post by Tom Mulgrew on Dec 30, 2007 18:21:14 GMT -5
I think i'm not rushing by saying this is the final touch to making bagel a complete language and anything added after this feature is extra... (now why would we need classes and other complications people? don't try and make everything look like cpp!) The only omission I can still think of is proper memory management. Currently when you DIM/allocate a variable or array, there's no way to get the memory back. But yeah.. I'm quite pleased with it where it stands. (And can finally say its a "procedural language"). -Tom
|
|
|
Post by Tom Mulgrew on Dec 30, 2007 20:17:32 GMT -5
|
|
|
Post by Tom Mulgrew on Dec 30, 2007 20:21:04 GMT -5
I want all the array to return 3 in this exemple. You want a function that returns an array where every element is set to 3? function FillArray(size, value) () dim array(size), i for i = 0 to size array(i) = value next return array end function
dim a(10) a = FillArray(10, 3)
|
|
|
Post by Nicky Peter Hollyoake on Dec 31, 2007 16:41:45 GMT -5
Last thing i'm interested they any possible way to do this ... Function Number(Num) () Dim Array(10) Dim i
For i = 0 To 10 Array(i) = Num Next
Return Array EndFunction
Dim &Array()
Array = Number(4) Get the array inside the function, and set the pointer with the same amount of elements inside the array thats in function, and add its same values. EDIT:Nevermind I got it  'Folder search function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function &FolderSearch$(File$) ()
Dim Search AS String Dim FileCount
Search = FindFirstFile(File$)
Dim i
FileCount = 0 Do Until Search = ""
if Search <> "" Then FileCount = (FileCount + 1) Endif
Search = FindNextFile() Loop
Search = FindFirstFile(File$)
Dim &File() AS String
Alloc File, FileCount - 1
For i = 0 To (FileCount - 1) File(i) = Search Search = FindNextFile() Next
Return &File EndFunction ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim &File$() Dim i
&File$ = FolderSearch$("*.GB")
For i = 0 To ArrayMax(File$) Printr File$(i) Sleep(500) Next Anone wanna use it for there own needs they can, can be pretty useful function.  [glow=red,2,300]Nicky[/glow]
|
|
|
Post by Tom Mulgrew on Dec 31, 2007 20:10:20 GMT -5
|
|
|
Post by James :) (aka Madcow) on Jan 1, 2008 15:30:48 GMT -5
the user acount activation thread can be unsticked from the off topic section
|
|
|
Post by Tom Mulgrew on Jan 1, 2008 20:22:44 GMT -5
'nuther new version, same place: www.basic4gl.net/unofficial/B4GLFunctionTest.zipThis one supports forward declaration of functions/subroutines. You may have noticed that you have to put the function/sub before the code that calls it in a program. E.g. this works: ' Implement sub sub MySub(): print "Hello": end sub ' Call sub MySub() But this doesn't: ' Call sub MySub()
' Implement sub sub MySub(): print "Hello": end sub However, you can now "forward declare" the function/sub with the "declare" keyword. So this works: ' Declare sub declare sub MySub()
' Call sub MySub()
' Implement sub sub MySub(): print "Hello": end sub The declare keyword tells the compiler that "MySub" is a subroutine, and tells it what parameters it has. If we were using parameters, we would declare them like this: ' Declare sub declare sub MySub(x, y, text$)
' Call sub MySub(20, 10, "Hello")
' Implement sub sub MySub(x, y, text$): locate x, y: print text$: end sub You can usually get away without using forward declarations (although there are a few situations where you can't, like some recursive functions for drawing Sierpensky shapes), but they are useful for organising your code and freeing you from restrictions on what order your functions/subroutines can appear in. -Tom
|
|
cameron
Posts

A new take on the old ASCII smiley face, because thats how you feel after 16 hours of coding.
Posts: 70
|
Post by cameron on Jan 2, 2008 9:00:42 GMT -5
OMG, I've just been browsing and it sounds like people haven't ever seen a Function statement for BASIC, OMG... Game Devs who haven't seen a Subroutine... FK... Bring Back DOS please bring back DOS... QuickBASIC, QuickBASIC PDS, VB for DOS oh I miss my DOS-ee programs... Nothing beats 16-bit OpCodes and OperRands, Singular Program Execution and Complete Memory OWNAGE, oh yes, now its all 32-bit and 'the 64-bit' pipe dream - I'll smoke'n'shoot to that.
|
|
|
Post by James :) (aka Madcow) on Jan 2, 2008 14:54:43 GMT -5
tom one last request. could you add a function that returns how big an array is.
|
|
|
Post by Tom Mulgrew on Jan 2, 2008 17:33:19 GMT -5
tom one last request. could you add a function that returns how big an array is. Done already: I've also added a function called "arraymax", which returns the maximum element of an array. So looping from 0 to arraymax(array) will visit every element in "array". For example: sub PrintArray(array#()) dim i for i = 0 to arraymax(array#): print array#(i); " ": next printr end sub
PrintArray(vec2(1,2)) PrintArray(vec3(3,4,5)) PrintArray(vec4(6,7,8,9))
|
|
|
Post by James :) (aka Madcow) on Jan 2, 2008 19:13:27 GMT -5
you know the vec2, vec 3, vec4 etc commands
could you make one unified command that can change arrays as big as infinty not just 4.
or maybe you could do this:
array()=["hi","hi"]
or
array("hi","hi")
|
|
|
Post by DJLinux on Jan 7, 2008 4:41:36 GMT -5
hello Tom can you add the static keyword please? I's not so nice to work with global vars if we don't need gosub anymore. And let me say good job i made many tests. Joshy sub DrawSolidBox() static _ListSolidBox if _ListSolidBox=0 then _ListSolidBox=glGenLists(1) glNewList(_ListSolidBox,GL_COMPILE) glBegin(GL_QUADS) glNormal3f(0,0,1) glVertex3f(-0.5, 0.5, 0.5):glVertex3f(-0.5,-0.5, 0.5) glVertex3f( 0.5,-0.5, 0.5):glVertex3f( 0.5, 0.5, 0.5) glNormal3f(1,0,0) glVertex3f( 0.5, 0.5, 0.5):glVertex3f( 0.5,-0.5, 0.5) glVertex3f( 0.5,-0.5,-0.5):glVertex3f( 0.5, 0.5,-0.5) glNormal3f (0,0,-1) glVertex3f( 0.5, 0.5,-0.5):glVertex3f( 0.5,-0.5,-0.5) glVertex3f(-0.5,-0.5,-0.5):glVertex3f(-0.5, 0.5,-0.5) glNormal3f(-1,0,0) glVertex3f(-0.5, 0.5,-0.5):glVertex3f(-0.5,-0.5,-0.5) glVertex3f(-0.5,-0.5, 0.5):glVertex3f(-0.5, 0.5, 0.5) glNormal3f(0,1,0) glVertex3f(-0.5, 0.5,-0.5):glVertex3f(-0.5, 0.5, 0.5) glVertex3f( 0.5, 0.5, 0.5):glVertex3f( 0.5, 0.5,-0.5) glNormal3f(0,-1,0) glVertex3f(-0.5,-0.5, 0.5):glVertex3f(-0.5,-0.5,-0.5) glVertex3f( 0.5,-0.5,-0.5):glVertex3f( 0.5,-0.5, 0.5) glEnd() glEndList() endif glCallList(_ListSolidBox) end sub
|
|