Search found 1564 matches
- Tuesday 12th July 2022 11:47am
- Forum: General
- Topic: Maximum value in an array
- Replies: 6
- Views: 1532
Re: Maximum value in an array
Of course! I spotted my mistake earlier and found that this works:- fTemp = MyArrayOfNumbers.Copy(0, MyArrayOfNumbers.Max) fTemp.Sort() Print fTemp[0];; fTemp[fTemp.Max] But your solution using MinVal = MyArrayOfNumbers[0] works fine and as you say, iteration is quicker than .Copy. Thanks for your ...
- Tuesday 12th July 2022 9:28am
- Forum: General
- Topic: Maximum value in an array
- Replies: 6
- Views: 1532
Re: Maximum value in an array
Thanks Bruce, That's a nice idea but MinVal is always zero! Also, copying the array of values into a temporary array then sorting it strangely sorts the original array. Dim MyArrayOfNumbers As Integer[] = [99, 91, 93, 92, 95, 90, 95, 100, 90, 90, 99] Dim fTemp As Integer[] fTemp = MyArrayOfNumbers ...
- Monday 11th July 2022 3:07pm
- Forum: Beginners
- Topic: start method in class
- Replies: 17
- Views: 4200
Re: start method in class
It makes more sense for your startup class/module to not really do much except initiate/run your other class files like vuott says.
- Monday 11th July 2022 3:01pm
- Forum: Beginners
- Topic: start method in class
- Replies: 17
- Views: 4200
Re: start method in class
I'm guessing the whole class should then have to be static too? and any global variables referenced from Main() would need to be declared as static too. ' Gambas class file Create Static Static $myGlobalInteger As Integer Static Public Sub Main() $myGlobalInteger = 5 End But i could well be wrong ab...
- Monday 11th July 2022 11:55am
- Forum: General
- Topic: Maximum value in an array
- Replies: 6
- Views: 1532
Re: Maximum value in an array
What is the best way to determine the max or min value in array? At the moment I'm copying the array to a temporary array, sorting it then using array.max I should think just itterate through it.. Dim MinVal, MaxVal As Integer For Each CurVal As Integer in MyArrayOfNumbers MaxVal=Max(CurVal, MaxVal...
- Monday 11th July 2022 11:48am
- Forum: Beginners
- Topic: start method in class
- Replies: 17
- Views: 4200
Re: start method in class
Benoit provided the simple answer on the mailing list (bless him)...
Main() must be static
Main() must be static
Static Public Sub Main()
End
- Monday 11th July 2022 11:19am
- Forum: Beginners
- Topic: start method in class
- Replies: 17
- Views: 4200
Re: start method in class
It's kinda badly named isn't it ?
Setting the "Startup class"
(but sorry you can't use a class just a module ! lol)
Setting the "Startup class"
(but sorry you can't use a class just a module ! lol)
- Monday 11th July 2022 11:17am
- Forum: Beginners
- Topic: start method in class
- Replies: 17
- Views: 4200
Re: start method in class
Why does your class HAVE to be the startup ?
Can you not just make a Startup.module then have it load the class?
Can you not just make a Startup.module then have it load the class?
' Gambas module file
Public Sub Main()
Class.Load("MyStartingClass")
End
Or...
' Gambas module file
Public Sub Main()
MyStartingClass.Run
End
- Monday 11th July 2022 10:50am
- Forum: Lounge
- Topic: Renting a VPS
- Replies: 7
- Views: 10885
Re: Renting a VPS
Charlie, do you know much about the digital ocean droplets, ie can all non-gui gambas components be used or at least the web components? The cost for me is about $6.00 a month for a "droplet" (£5.00), this depends on usage. As far as I know, all Gambas non-GUI components will work, not su...
- Sunday 10th July 2022 7:45pm
- Forum: Beginners
- Topic: start method in class
- Replies: 17
- Views: 4200
Re: start method in class
Don't use Main() for a class.
Use _init() or _new()
Use _init() or _new()