Quote: "Is there a way to produce a function capable of accepting different sets of arguments? Like, for example, BOX can be either (x1,y1,x2,y2) or it can also include four colors. I was wondering if there was a way to do this for other functions."
Yes, but technically no. Here's the cheat:
`MyFunct(param$)
`param$: 1st argument controls functionality, 2nd argument the machine-type, 3rd argument the persona
CLS
PRINT "111 passed"
MyFunct("111")
PRINT ""
PRINT "Press a key..."
WAIT KEY
CLS
PRINT "1 passed"
MyFunct("1")
PRINT ""
PRINT "Press a key..."
WAIT KEY
CLS
PRINT "212 passed"
MyFunct("212")
PRINT ""
PRINT "Press a key..."
WAIT KEY
CLS
PRINT "12 passed"
MyFunct("12")
PRINT ""
PRINT "Press a key..."
WAIT KEY
END
Function MyFunct(param$)
DIM arg$(3)
arg$(1) = MID$(param$, 1)
arg$(2) = MID$(param$, 2)
arg$(3) = MID$(param$, 3)
IF arg$(1) = "1": PRINT "Machine set to manual": ENDIF
IF arg$(1) = "2": PRINT "Machine set to automatic": ENDIF
IF arg$(2) = "1": PRINT "Machine mode: dishwasher": ENDIF
IF arg$(2) = "2": PRINT "Machine mode: toaster": ENDIF
IF arg$(3) = "1": PRINT "Machine persona: male": ENDIF
IF arg$(3) = "2": PRINT "Machine persona: female": ENDIF
EndFunction
Quote: "Also, on the returning end, is it possible to return an array?"
Yes and no again. You can pass pointers if you know how to handle them and make your own data-structures. The example would be a little complicated but along the lines of the above example, only you'd be working with raw data.
Quote: "How would I go about implementing complex data types into a function, if at all possible? I have an idea for a function that returns values for an array, but I would obviously need to use that array as an array, get it's top and bottom indices and dimensions, etc."
Not too sure what you mean there but if you're wanting to have a function modify an array, simply reference the array in the function. Arrays are always global in DarkBasic. There are also DB functions to return an array's index-count etc such as ARRAY COUNT(). Also, arrays in DB are dynamic so you can resize then with DIM, the same way you created them. Expanding an array this way will not erase or displace data, however shrinking will obviously, as will inserting elements.
Quote: "Does anyone have a triangle drawing function? Because I sure could use one :\"
This:
Function Tri(x1, y1, x2, y2, x3, y3)
LINE x1, y1, x2, y2
LINE x2, y2, x3, y3
LINE x3, y3, x1, y1
EndFunction