Search found 11991 matches

by fxm
Apr 20, 2024 12:29
Forum: Beginners
Topic: Constructor Copy
Replies: 1
Views: 19

Re: Constructor Copy

- Instead of defining a 'cleanup()' method, you can define a 'destructor()' which will be automatically called before the object is destroyed. - The 'calculate()' method does not use any member fields. So you can declare it as static and simply call it on the type name and not necessarily on the nam...
by fxm
Apr 20, 2024 5:35
Forum: General
Topic: Const error (Expected End-of-Line)
Replies: 8
Views: 323

Re: Const error (Expected End-of-Line)

New update: Operator [] (String index) ..... Usage: result = lhs [ rhs ] ..... Parameters: lhs : The string (a string reference, not a string returned as local copy) lhs : The string variable or a string reference (not for example a constant or a string returned as a local copy). rhs : A zero-based ...
by fxm
Apr 20, 2024 4:56
Forum: Beginners
Topic: UDT Constructor with Param
Replies: 2
Views: 74

Re: UDT Constructor with Param

Look at the CONSTRUCTOR manual page with the examples.
You can also consult the Programmer's Guide, first on the Constructors and Destructors (basics) page.
by fxm
Apr 19, 2024 13:50
Forum: General
Topic: Const error (Expected End-of-Line)
Replies: 8
Views: 323

Re: Const error (Expected End-of-Line)

a string reference, not a string returned as local copy The explanation in the help for this case is not very clear. But after you explained, it is now clear. Small update: Operator [] (String index) ..... Usage: result = lhs [ rhs ] ..... Parameters: lhs : The string (a string reference, not a str...
by fxm
Apr 19, 2024 9:19
Forum: General
Topic: Const error (Expected End-of-Line)
Replies: 8
Views: 323

Re: Const error (Expected End-of-Line)

Operator [] (String index) ..... Usage: result = lhs [ rhs ] ..... Parameters: lhs : The string ( a string reference, not a string returned as local copy ). rhs : A zero-based offset from the first character. ..... Example: Function returnByval(Byref s As String) As String Return s End Function Fun...
by fxm
Apr 19, 2024 5:38
Forum: General
Topic: Const error (Expected End-of-Line)
Replies: 8
Views: 323

Re: Const error (Expected End-of-Line)

The string index operator ('[]') applies only to references.
Otherwise in your case, instead of:
s[n]
you can use:
asc(s, n+1)

See the Operator [] (String index) documentation page.
by fxm
Apr 16, 2024 7:59
Forum: Community Discussion
Topic: Freebasic 1.20.0 Development
Replies: 269
Views: 24802

Re: Freebasic 1.20.0 Development

Should we now disallow 'SIZEOF(array_name)' and even more so 'LEN(array_name)' ? ..... Also remember to take into account at the same time the bug report: #821 LEN() and SIZEOF() should not be allowed when used with bitfields Example grouping together all these cases of inconsistent LEN/SIZEOF valu...
by fxm
Apr 14, 2024 11:23
Forum: General
Topic: Is this a bug in FreeBasic graphics?
Replies: 5
Views: 591

Re: Is this a bug in FreeBasic graphics?

How to optimize the size of image buffers: Screenres 640, 480, 32 Dim As Integer x, y, i x = 37: y = 37 Dim As Any Ptr DrawBall = ImageCreate( 75, 75, RGB(255, 255, 255)) '' 75*75 pixels from index : 0 to 74 CIRCLE DrawBall, (x, y), 37, RGB(0, 255, 0),,,,F ' Green '' circle from index : 37-37=0 to 3...
by fxm
Apr 14, 2024 7:36
Forum: General
Topic: Is this a bug in FreeBasic graphics?
Replies: 5
Views: 591

Re: Is this a bug in FreeBasic graphics?

Minimum code without 'Put' : Dim As Integer x = 40, y = 40 Screenres 640, 480, 32 For i As Integer = 1 To 140 ScreenLock CIRCLE (x, y), 37, RGB(0, 0, 0),,,,F '' erase the previous ball x += 4 '' move the ball 4 pixels at a time CIRCLE (x, y), 37, RGB(0, 255, 0),,,,F '' draw the ball ScreenUnlock Sle...
by fxm
Apr 14, 2024 5:30
Forum: General
Topic: Is this a bug in FreeBasic graphics?
Replies: 5
Views: 591

Re: Is this a bug in FreeBasic graphics?

With 'Put', the default method used to draw the image to the destination buffer is XOR.
To erase the ball, use rather:
put(x, y),EraseBall, Pset
by fxm
Apr 13, 2024 11:15
Forum: General
Topic: Property Definition does not allow STATIC
Replies: 6
Views: 450

Re: Property Definition does not allow STATIC

Alternatively, you can use a non-static member property (which accesses the static integer member) and call it on any instance opportunity, or on a null pointer or null reference to the 'Type' (provided the property body does not use 'This' ). Type Gobject Public: Declare Property Prop1(Byval I As ...
by fxm
Apr 12, 2024 11:51
Forum: General
Topic: Property Definition does not allow STATIC
Replies: 6
Views: 450

Re: Property Definition does not allow STATIC

Alternatively, you can use a non-static member property (which accesses the static integer member) and call it on any instance opportunity, or on a null pointer or null reference to the 'Type' (provided the property body does not use 'This' ). Type Gobject Public: Declare Property Prop1(Byval I As I...
by fxm
Apr 12, 2024 10:59
Forum: General
Topic: Property Definition does not allow STATIC
Replies: 6
Views: 450

Re: Property Definition does not allow STATIC

But this new feature seems to be not very easy, mainly because of a parser problem. Example of the parser syntax problem for STATIC PROPERTIES without index parameter: There is a syntax ambiguity between one of property result assignment syntaxes inside the get-property body and the set-property cal...
by fxm
Apr 12, 2024 5:29
Forum: General
Topic: Property Definition does not allow STATIC
Replies: 6
Views: 450

Re: Property Definition does not allow STATIC

A "feature request" is already filled in since 2013:
#279 Add the static properties feature
by fxm
Apr 11, 2024 5:13
Forum: Sources, Examples, Tips and Tricks
Topic: Simple 2D Ball Collision Demo
Replies: 10
Views: 724

Re: Simple 2D Ball Collision Demo

neil wrote: Apr 10, 2024 22:36 The FB Gfx lib: version won't compile because of this line.

Line 103 .x -= t1Sleep (1)
easy (stuttering):
.x -= t1