Search found 12397 matches

by fxm
Apr 16, 2025 8:50
Forum: Beginners
Topic: Sorting output of Dir()
Replies: 44
Views: 3173

Re: Sorting output of Dir()

This is not a bug but rather a deficiency well-specified in the documentation: Note: Wstring is not supported with Var , due to the fact that there is no var-len Wstring type. This isn't likely to change, due to the complexities involved with handling Unicode. Otherwise this below compiles:  var ...
by fxm
Apr 15, 2025 20:20
Forum: Documentation
Topic: wiki/ProPgLabels
Replies: 1
Views: 196

Re: wiki/ProPgLabels

Done:
ProPgLabels → fxm [added label usage for 'Restore' keyword]
by fxm
Apr 15, 2025 12:03
Forum: Beginners
Topic: How do I pass a pointer to an array as a sub() parameter?
Replies: 4
Views: 624

Re: How do I pass a pointer to an array as a sub() parameter?

Thanks folks! I either have to change my subs by adding a index parameter or change to handling byte pointers instead of arrays as parameters. A hacking solution would be to modify the array descriptor before passing it to the procedure, in order to apply an offset to the array data relative to its...
by fxm
Apr 14, 2025 5:38
Forum: Beginners
Topic: How do I pass a pointer to an array as a sub() parameter?
Replies: 4
Views: 624

Re: How do I pass a pointer to an array as a sub() parameter?

Example for a Ubyte array: Sub mySub(Byval bytePtr As Ubyte Ptr) '' pass a Ubyte pointer (an address) to the sub Print "From the passed element address:" For I As Integer = 0 To 5 Print " +" & I & ": " & bytePtr[I] '' print the Ith element from the passed ad...
by fxm
Apr 13, 2025 10:59
Forum: Beginners
Topic: Sorting output of Dir()
Replies: 44
Views: 3173

Re: Sorting output of Dir()

Var s1 = "FreeBASIC" '' ok Var s2 = Str("FreeBASIC") '' ok Var s3 = Wstr("FreeBASIC") '' error 24: Invalid data types in 'Var s3 = Wstr("FreeBASIC")' You didn't check, I think, the example Var s1 = "FreeBASIC" with the UTF8 (BOM) file format. Yes.
by fxm
Apr 13, 2025 9:21
Forum: Beginners
Topic: Sorting output of Dir()
Replies: 44
Views: 3173

Re: Sorting output of Dir()

Code: Select all

Var s1 = "FreeBASIC"        '' ok
Var s2 = Str("FreeBASIC")   '' ok
Var s3 = Wstr("FreeBASIC")  '' error 24: Invalid data types in 'Var s3 = Wstr("FreeBASIC")'
by fxm
Apr 12, 2025 13:54
Forum: General
Topic: When transmitting a string from an array, is it transmitted by value?
Replies: 4
Views: 635

Re: When transmitting a string from an array, is it transmitted by value?

Lost Zergling wrote: Apr 12, 2025 13:42 Meaning wanting to avoid a string copy would be to use rather a strptr instead bref ?
Or:

Code: Select all

sub test(byref z as zstring)
	z = "null"
End Sub
by fxm
Apr 12, 2025 12:52
Forum: Beginners
Topic: UNION problem?
Replies: 3
Views: 384

Re: UNION problem?

Example of initializing for any field of Union: type vtype vtype as ushort namelen as ubyte name as string * 15 union i8 as byte i16 as short i32 as long flt as double spt as any ptr end union declare constructor() declare constructor(byval _vtype as ushort, byval _namelen as ubyte, byref _name as s...
by fxm
Apr 12, 2025 5:30
Forum: General
Topic: When transmitting a string from an array, is it transmitted by value?
Replies: 4
Views: 635

Re: When transmitting a string from an array, is it transmitted by value?

When a fix-len string is passed 'Byref As String' to a procedure, a temporary var-len string copy of this fix-len string is used in the procedure body. If this temporary var-len string is modified in the procedure body: - before fbc 1.20.0, the initial fix-len string is not modified. - since fbc 1.2...
by fxm
Apr 11, 2025 19:20
Forum: Community Discussion
Topic: Freebasic 1.20.0 Development
Replies: 319
Views: 85659

Re: Freebasic 1.20.0 Development

About the new fix-len string ( 'String * N' ) definition since fbc version 1.20.0 ( 'String * N' now occupies N bytes and has no terminating null character) Bug to initialize a structure mixing such fix-len string with numeric data. Example using a temporary type as initializer: Type UDT0 Dim As St...
by fxm
Apr 11, 2025 18:21
Forum: Beginners
Topic: UNION problem?
Replies: 3
Views: 384

Re: UNION problem?

Initialize implicitly an union field structure is not always safe. Generally, the first declared data of the union structure is initialized, but this is a bite daring. If one defines specific constructors, no more problem. For example to initialize the first declared data of the union structure: typ...
by fxm
Apr 11, 2025 18:02
Forum: Beginners
Topic: UNION problem?
Replies: 3
Views: 384

Re: UNION problem?

No warning with gas (32-bit) and gas64 (64-bit).
Warning with only gcc (32-bit and 64 bit).
by fxm
Apr 10, 2025 19:38
Forum: Beginners
Topic: Class example questions
Replies: 9
Views: 909

Re: Class example questions

The second 'user_right.Destructor()' is hidden from the console because the corresponding destructor is called at the end of the program (after 'Sleep' ). To see it, also include the second part of the program in a [Scope...End Scope] block with 'Sleep' after 'End Scope' . (The destructor is called ...
by fxm
Apr 07, 2025 20:32
Forum: Documentation
Topic: /wiki/CompilerOptfpmode
Replies: 3
Views: 920

Re: /wiki/CompilerOptfpmode

That doesn't make sense because this entire line just isn't true (any more) Using -fpmode PRECISE is dependent on the -fpu SSE command line option. Using -fpmode PRECISE without using -fpu SSE will generate an error. Try it. fbc32 -fpmode PRECISE -fpu x87 whatever.bas No problems. I found this rece...
by fxm
Apr 07, 2025 19:22
Forum: Beginners
Topic: Class example questions
Replies: 9
Views: 909

Re: Class example questions

Another variation: type vec4a as Single wa,xa,ya,za Declare Constructor () declare constructor ( wa As Single, xa as single, ya as single, za as single) end type constructor vec4a ( wa As Single, xa as Single, ya as Single, za as Single ) with this .wa = wa .xa = xa .ya = ya .za = za end with end co...