To pass parameters to the functions, you just do it the normal way. The only thing is that all functions in your array must accept and return the same parameters.Code: BlitzMaxSuperStrict Local f:String(n:Int)[10] f[0] = Func0f[1] = Func1f[2] = Func2 Print f[0](10)Print f[1](20)Print f[2](30) Function Func0:String(n:Int) Return "You passed "+n+" into Func0"End Function Function Func1:String(n:Int) Return "You passed "+n+" into Func1"End Function Function Func2:String(n:Int) Return "You passed "+n+" into Func2"End Function For some odd reason, I cannot get this example to work with the NG version of BlitzMax. Works fine with the original "vanilla" BlitzMax
Could also be written asLongTextString :+ "_" + (RSet(i, 3).Replace(" ", "0"))If i = 255 Then LongTextString :+ "]"(just wrote it to make you aware of ":+" to skip "text = text + x")
Hi Tom, Ive run your code and ive realised that to use The functions in the way im trying. They must be declared as a string!? Thankyou Im glad ive leart how to automate the writting of Blitz code, as it wont be to hard to alter now.I do beleive that im indeed running "Vanilla Blitzmax version 1.50". Not getting on with "NG" it just throws to many errors Thankyou all again.Kind Regards Baggey
Quote from: Baggey on February 05, 2021, 05:30:32 PMHi Tom, Ive run your code and ive realised that to use The functions in the way im trying. They must be declared as a string!? Thankyou Im glad ive leart how to automate the writting of Blitz code, as it wont be to hard to alter now.I do beleive that im indeed running "Vanilla Blitzmax version 1.50". Not getting on with "NG" it just throws to many errors Thankyou all again.Kind Regards BaggeyNo. I am only using String and Int as an example on how to pass and return values. You use whatever type your program needs instead.
SuperStrict Global OO:Byte(n:Int)[]=[_000,_001,_002] Print OO[0](10) Print OO[1](20) Print OO[2](30) Function _000:Byte(n:Int) Return "You passed "+n+" into Func0" End Function Function _001:Byte(n:Int) Return "You passed "+n+" into Func1" End Function Function _002:Byte(n:Int) Return "You passed "+n+" into Func2" End Function
SuperStrict Global OO:String(n:Int)[]=[_000,_001,_002] Print OO[0](10) Print OO[1](20) Print OO[2](30) Function _000:String(n:Int) Return "You passed "+n+" into Func0" End Function Function _001:String(n:Int) Return "You passed "+n+" into Func1" End Function Function _002:String(n:Int) Return "You passed "+n+" into Func2" End Function
SuperStrict Global OO:Object(n:Int)[]=[_000,_001,_002] Print String(OO[0](10)) Print String(OO[1](20)) Print String(OO[2](30)) Function _000:Object(n:Int) Return "You passed "+n+" into Func0" End Function Function _001:Object(n:Int) Return "You passed "+n+" into Func1" End Function Function _002:Object(n:Int) Return "You passed "+n+" into Func2" End Function
SuperStrictType TType Field x:Int Field str:StringEndTypeGlobal OO:TType(n:Int)[]=[_000,_001,_002] Print TType((OO[0](10))).strPrint TType((OO[1](20))).xPrint TType(OO[2](30)).str Function _000:TType(n:Int) Local newtype:TType = New TType newType.str = "You passed "+n+" into Func0" Return newTypeEnd Function Function _001:TType(n:Int) Local newtype:TType = New TType newType.x = n Return newTypeEnd Function Function _002:TType(n:Int) Local newtype:TType = New TType newType.str = "You passed "+n+" into Func2" Return newTypeEnd Function
anInt:Int = 1aString:String = "Hello"Print IsString(anInt)Print IsString(aString)Function IsString(obj:Object) If String(obj) Return True Return FalseEnd Function
Print "HELLO".tolower()