how to use FreeBASIC\Examples\windows\variants ?

Windows specific questions.
Loe
Posts: 323
Joined: Apr 30, 2006 14:49

how to use FreeBASIC\Examples\windows\variants ?

Postby Loe » May 12, 2008 3:11

how to use FreeBASIC\Examples\windows\variants ?
I cant find any sample and built library
did I miss something?
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » May 12, 2008 10:38

I was able to create a library that appears to work by copying the MinGW mingw32-make.exe to the libvariant directory, modifying line 21 in the make file:

FBC := fbc

To add the full path to fbc, in my case:

FBC := C:\Program Files\FreeBASIC0.18.2b\fbc

And then executing mingw32-make.exe with no command line arguments.

This simple test worked as I expected, except passing a 64-bit integer caused an access violation:

Code: Select all

#include "variant.bi"

function test( arg as variant ) as variant
  print arg,
  return arg
end function

dim as variant v = -123
dim as byte b = -1
dim as ubyte ub = 1
dim as short s = -2
dim as ushort us = 2
dim as integer i = -4
dim as uinteger ui = 4
dim as longint li = -8
dim as ulongint uli = 8
dim as single sng = 123.123
dim as double dbl = 456.456
dim as string st = "my other brother darryl"

print test( v )
print test( b )
print test( ub )
print test( s )
print test( us )
print test( i )
print test( ui )
'print test( li )
'print test( uli )
print test( sng )
print test( dbl )
print test( st )

sleep
Loe
Posts: 323
Joined: Apr 30, 2006 14:49

Postby Loe » May 13, 2008 7:57

Thank you MichaelW
I should find MinGW mingw32-make.exe (?) to try it
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » May 13, 2008 19:43

Here, I'll compile it for you. Longints indeedhave some sort of problem, but scanning over the code didn't reveal it, as I have 0 knowledge of variants/bstrings...

With debugging info:
http://therealcha0s.net/project/fbc/libvariant.zip
Loe
Posts: 323
Joined: Apr 30, 2006 14:49

Postby Loe » May 14, 2008 3:32

Thank you cha0s
I compiled using MingW32-make 3.81. without debuging info size about 108kb, yours 409kb.

question:
is this Variant Class compatible with Variant API?
because when I use libvariant in my project using variant api it generate errors.
exampe:
dim v as variant
v.vt=vt_byref or vt_i4 'I cant use this,

we need to pass variant as vt_byref when we need return parameter.
corka
Posts: 1
Joined: Jul 01, 2019 3:22

Re:

Postby corka » Jul 01, 2019 3:29

cha0s wrote:Here, I'll compile it for you. Longints indeedhave some sort of problem, but scanning over the code didn't reveal it, as I have 0 knowledge of variants/bstrings...

With debugging info:
http://therealcha0s.net/project/fbc/libvariant.zip


Hi,

The link has been gone, can somebody reupload the file, or even compile a new one (hopefully with newest gcc versions to match FB 1.06) ?
I need the release version (without debugging info).

Thanks in advance
Alfie
Posts: 3
Joined: May 25, 2020 8:48

Re: how to use FreeBASIC\Examples\windows\variants ?

Postby Alfie » Jun 10, 2020 16:40

I know it's free and it's great for some things, but references to "variant.bi" abound throughout the web and it turns out none will work unless you can find the magic bullet that allows you to compile this lib. No one can and no one left instructions, nor did they even leave a note saying "actually, the example we left is not a compiled lib".

So dear curators of FB, if you can't support "variant.bi", please remove all trace from the examples. That would save me and every one like me wasting a day each looking blankly at a screen that just says "linking failed".

Thanks all above. Hope this saves some days of future people's lives. Above all thanks to the FBC providers who I am sure are not even aware of this.

By the way, this is the 3rd forum I have found that has been unable to conclude the affair, and the second that says "here it is" with broken link. This one at least seems to reveal that "it's simply unsupported". Please feel free to prove me wrong. I apologize in advance. :-)
adeyblue
Posts: 22
Joined: Nov 07, 2019 20:08

Re: how to use FreeBASIC\Examples\windows\variants ?

Postby adeyblue » Jun 10, 2020 21:25

Alfie wrote:it turns out none will work unless you can find the magic bullet that allows you to compile this lib. No one can and no one left instructions

The entire instructions to build it are in the second post. If you need something less involved/more explicit:

Code: Select all

C:\freebasic\examples\win32\variants\libvariant>c:\freebasic\fbc.exe -d VARIANT_ISBUILDING -i ..\ -lib *.bas -x libvariant.a


I'll leave it to posterity to fix variant.bi to define VARIANT_ as tagVARIANT in the building case, since that seems to be required now
Alfie
Posts: 3
Joined: May 25, 2020 8:48

Re: how to use FreeBASIC\Examples\windows\variants ?

Postby Alfie » Jun 12, 2020 13:43

adeyblue wrote:

Code: Select all

C:\freebasic\examples\win32\variants\libvariant>c:\freebasic\fbc.exe -d VARIANT_ISBUILDING -i ..\ -lib *.bas -x libvariant.a

Thanks so much .. .we're infinitely closer than "executing mingw32-make.exe" from our friend in post 2 which, for me, was just baffling.
We're not quite there yet though.. (below is my result on W10 64b with WinFBe installed)..

Code: Select all

C:\>cd C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\libvariant

C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\libvariant>C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\fbc32.exe -d VARIANT_ISBUILDING -i ..\ -lib *.bas -x libvariant.a
(and I got)
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(26) error 14: Expected identifier, found 'VARIANT_' in 'as VARIANT_ var_'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(31) error 59: Illegal specification, at parameter 1 (rhs) of VARIANT.constructor stdcall() in 'declare constructor ( byref rhs as VARIANT_ )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(32) error 59: Illegal specification, at parameter 1 (rhs) of VARIANT.constructor stdcall() in 'declare constructor ( byref rhs as VARIANT_, byval deep_copy as integer )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(33) error 4: Duplicated definition in 'declare constructor ( byval rhs as integer )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(59) error 14: Expected identifier, found 'VARIANT_' in 'declare operator cast ( ) as VARIANT_'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(70) error 59: Illegal specification, at parameter 1 (rhs) of VARIANT.operator.() in 'declare operator += ( byref rhs as VARIANT_ )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(71) error 4: Duplicated definition in 'declare operator += ( byval rhs as integer )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(81) error 59: Illegal specification, at parameter 1 (rhs) of VARIANT.operator.() in 'declare operator -= ( byref rhs as VARIANT_ )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(82) error 4: Duplicated definition in 'declare operator -= ( byval rhs as integer )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(90) error 59: Illegal specification, at parameter 1 (rhs) of VARIANT.operator.() in 'declare operator *= ( byref rhs as VARIANT_ )'
C:\Ware\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\examples\win32\variants\variant.bi(90) error 133: Too many errors, exiting

The folder I was in has the following files in it.. "intern.bi", "Makefile", "variant*.bas" (about 55x variant*.bas)
The folder above it has variant.bi in it.
Sorry to be a pain, but could you advise?
Josep Roca
Posts: 501
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: how to use FreeBASIC\Examples\windows\variants ?

Postby Josep Roca » Jun 12, 2020 15:45

If you're using WinFBE, you already have my WinFBX framework with it, so maybe you will find useful to look at the CVAR class.
See: https://github.com/JoseRoca/WinFBX/blob ... 20Class.md

It is easy to use, e.g.

Code: Select all

'#CONSOLE ON
#INCLUDE ONCE "Afx/CVar.inc"
USING Afx

DIM s AS STRING = " Ansi FB string"
DIM ws AS WSTRING * 20 = " Unicode FB string"
DIM cv AS CVAR = s & ws & " literal string "
cv += "Сергей Сергеевич Прокофьев"
print cv
Alfie
Posts: 3
Joined: May 25, 2020 8:48

Re: how to use FreeBASIC\Examples\windows\variants ?

Postby Alfie » Jun 13, 2020 14:20

That looks great Josep. Thanks so much! Ps: Yes, I have seen your name in many a file...

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest