Search found 21 matches
- Sep 03, 2022 11:43
- Forum: General
- Topic: Terminal ESC sequence '[' versus 'O'
- Replies: 0
- Views: 2768
Terminal ESC sequence '[' versus 'O'
Hi, I wrote a FreeBASIC wrapper over https://github.com/antirez/linenoise - a minimalist readline replacement. You can see it here https://github.com/hacksterous/lined . (Thanks to the help I received here) It works nicely, including the hints and completions. However, I noticed that the terminal es...
- Sep 02, 2022 14:42
- Forum: Beginners
- Topic: Any examples for C callback
- Replies: 6
- Views: 884
Re: Any examples for C callback
Never mind, I got it.
Code: Select all
'define the procedure
sub completion (byval as zstring ptr, byval as myStruct ptr)
end sub
'dim a var for the procedure pointer
dim completionSubPtr as myCallback = @completion
'set the callback
setCallBack(completionSubPtr)
- Sep 02, 2022 12:35
- Forum: Beginners
- Topic: Any examples for C callback
- Replies: 6
- Views: 884
Re: Any examples for C callback
Hi - thanks much.
I am a bit confused. The C setCallBack function takes a function pointer parameter - so shouldn't the FB function also be byval as myCallback ptr
I am a bit confused. The C setCallBack function takes a function pointer parameter - so shouldn't the FB function also be byval as myCallback ptr
Code: Select all
declare sub setCallBack cdecl (byval as myCallback ptr)
- Sep 02, 2022 9:54
- Forum: Beginners
- Topic: Any examples for C callback
- Replies: 6
- Views: 884
Any examples for C callback
Hi, I require an FB interface to a C function setCallBack: typedef void(myCallback)(char *, myStruct *); void setCallBack (myCallback *); Could anyone point me to examples of the FB declaration? I have looked at https://www.freebasic.net/wiki/TutInterfacingWithC but that doesn't show how a function ...
- Aug 30, 2022 9:45
- Forum: Beginners
- Topic: Help with double free (segfault)
- Replies: 2
- Views: 527
Re: Help with double free (segfault)
Hey, thanks. Works now after I added the copy-cons as below: constructor estring(es as estring) print "cons with estring called -- *es.p = "; *es.p if this.p <> null then print "cons with estring param: deallocating "; this.p deallocate(this.p) this.p = null end if this.p = alloc...
- Aug 30, 2022 8:15
- Forum: Beginners
- Topic: Help with double free (segfault)
- Replies: 2
- Views: 527
Help with double free (segfault)
Hi, Thanks very much for helping me this far with FreeBasic. I am trying to understand the examples in the "EXTENDS ZSTRING". The following function code causes a double free segmentation fault. function replaceB (byref s as estring) as estring print "replaceB entered" dim as str...
- Aug 27, 2022 11:05
- Forum: Beginners
- Topic: Using Err programmatically
- Replies: 2
- Views: 480
Using Err programmatically
Hi, I would like to use the Err function and statement to generate an error flag and handle the error afterwards. In the code below, I have set err to 1009 whenever an erroneous input is received. However, this doesn't see to work, as err() always returns 0. I don't want to use the On Error type han...
- Aug 26, 2022 13:32
- Forum: Beginners
- Topic: Variable argument count to functions
- Replies: 12
- Views: 938
Re: Variable argument count to functions
This works very nicely if I directly call the macro. Thanks. However, my requirement is to call a public method of the list UDT. This doesn't compile (error 14: Expected identifier, found '.') #macro pushstrings(parameters...) this._pushstrings(parameters, 0) #endmacro sub mlist.public_pushstrings (...
- Aug 26, 2022 12:38
- Forum: Beginners
- Topic: Variable argument count to functions
- Replies: 12
- Views: 938
Re: Variable argument count to functions
Yeah, right.
Can't the compiler push the argument count first on the stack before the arguments?
It probably needs two passes after seeing the ellipsis... Or it can push an extra null pointer as
the last argument.
Thanks for the answers.
GWBc
Can't the compiler push the argument count first on the stack before the arguments?
It probably needs two passes after seeing the ellipsis... Or it can push an extra null pointer as
the last argument.
Thanks for the answers.
GWBc
- Aug 26, 2022 9:45
- Forum: Beginners
- Topic: Variable argument count to functions
- Replies: 12
- Views: 938
Re: Variable argument count to functions
My list needs to support null "" string as an element!
- Aug 26, 2022 9:26
- Forum: Beginners
- Topic: Variable argument count to functions
- Replies: 12
- Views: 938
Re: Variable argument count to functions
Thanks.
Is there no way around the last 0 in the call?
It's not elegant
Is there no way around the last 0 in the call?
It's not elegant
- Aug 26, 2022 9:05
- Forum: Beginners
- Topic: Variable argument count to functions
- Replies: 12
- Views: 938
Variable argument count to functions
Hi All, I have a linked list UDT with a push method that takes in one string argument. I am trying to use varargs to send a list of strings to a sub that iterates over the list and calls the UDT's push method for each string. I cannot use the first argument as an argument count. I could use the __FB...
- Aug 21, 2022 11:05
- Forum: Beginners
- Topic: UDT - can't redefine abs math function
- Replies: 12
- Views: 1045
Re: UDT - can't redefine abs math function
Thanks for the replies. One other inconsistency I found: Neither +=, nor << are FreeBASIC or BASIC operators, but I can define += (and -=, *= etc.) as type members, but trying to declare << as type member give: rror 153: Operator cannot be a member function (TODO), before '<' in 'declare operator <<...
- Aug 21, 2022 5:24
- Forum: Beginners
- Topic: UDT - can't redefine abs math function
- Replies: 12
- Views: 1045
Re: UDT - can't redefine abs math function
Yes, #undef abs works. Thanks. Funnily, a new definition of abs as an operator does not work now (error 157: Expected operator, found 'abs' in 'operator abs ...'), but log works outside (not a member of UDT). But, log only works as an operator, trying to define it as a function gives -- error 4: Dup...
- Aug 21, 2022 5:09
- Forum: Beginners
- Topic: UDT - can't redefine abs math function
- Replies: 12
- Views: 1045
Re: UDT - can't redefine abs math function
Yes, I found ABS works as an operator, but the operator cannot be member of the UDT. operator abs (A as cplx) as cplx What is the difference between an "FB" and "non-FB" command? From ABS documentation, I see Dialect Differences: In the -lang qb dialect, this operator cannot be o...