Unlikely, since I'm compiling with the same 'official' version (portable), with the 'vanilla' toolchain (GCC 5). Tested with both gcc and gas, 32 and 64-bit, no switches.jj2007 wrote:...
Under the hood it becomes clear that there are no nullbytes around. Probably I just have a very old version: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
...
openfilename
Re: openfilename
Re: openfilename
So it remains a mystery why the same code with the same compiler produces different results on different machines.
Btw a Google search for site:freebasic.net string null embedded finds only 329 hits, so it's apparently not a big problem.
Btw a Google search for site:freebasic.net string null embedded finds only 329 hits, so it's apparently not a big problem.
Re: openfilename
jj2007!VANYA wrote:jj2007 wrote:So it remains a mystery why the same code with the same compiler produces different results on different machines.
I suspect that you save the file in the UTF-16 encoding, and Paul DoE saves in ASCII. Therefore, you have different results.
If you use UTF-16 encoding, the Type of String also swallows zero characters, which is why your strings merge:
Code: Select all
#define chNull chr( 0 )
#define chNullNull chr( 0, 0 )
Dim filter As string = "Sources" + chNull + "*.bas"
for i as Long = 0 to len(filter)
? filter[i] , chr(filter[i])
Next
sleep
Code: Select all
83 S
111 o
117 u
114 r
99 c
101 e
115 s
42 *
46 .
98 b
97 a
115 s
0
Last edited by VANYA on May 08, 2021 17:36, edited 1 time in total.
Re: openfilename
To the PAUL DOE code worked when the file is saved in UTF-16, you can do this:
Code: Select all
#include "Windows.bi"
#Include Once "win\commdlg.bi"
#define chNull chr( 0 )
#define chNullNull chr( 0, 0 )
Dim ofn As OPENFILENAME
Dim buffer As string * MAX_PATH = "testme.bas"
Dim filter As string = _
str("Sources (*.bas)") + chNull + str("*.bas") + chNull + _
str("Includes (*.bi)") + chNull + str("*.bi") + chNullNull
with ofn
.lStructSize=sizeof( OPENFILENAME )
.hwndOwner=GetForegroundWindow()
.lpstrFilter=strPtr( filter )
.lpstrFile=strPtr( buffer )
.nMaxFile=MAX_PATH
.lpstrTitle=strptr( "Grab a file" )
.Flags=OFN_FILEMUSTEXIST or OFN_EXPLORER or OFN_NOCHANGEDIR
.lpstrDefExt=strPtr( "asm" )
end with
GetOpenFileName( @ofn )
MessageBox( 0, strPtr( buffer ), "Your choice:", MB_OK or MB_SETFOREGROUND )
Re: openfilename
I checked twice now, and you are right indeed! So if the source is in UTF-16, then FB codes strings a little bit different... they are still ANSI (otherwise GetOpenFileNameA would not work), but string concatenation works a little bit different. Great! Thanks, VANYA, for solving the mystery.VANYA wrote:jj2007!VANYA wrote:jj2007 wrote:So it remains a mystery why the same code with the same compiler produces different results on different machines.
I suspect that you save the file in the UTF-16 encoding, and Paul DoE saves in ASCII. Therefore, you have different results.
Re: openfilename
Something is strange to me with this filter ..
it looks similar to what i use in o2 but not work like there
so i will check any member of ofn structure
because what i see in explorer is not proper.
it looks similar to what i use in o2 but not work like there
so i will check any member of ofn structure
because what i see in explorer is not proper.
Re: openfilename
Ok
it looks that i found solution even i am not much used to FB...shame on me!
After i set sizeOf of structure to 76 i got proper FileDialog
and also looks that bitmap file is in explorer
i changed buffer from string to zstring type..
I still dont know how to kill console in background ?? ..it is so annoying ...
it looks that i found solution even i am not much used to FB...shame on me!
After i set sizeOf of structure to 76 i got proper FileDialog
and also looks that bitmap file is in explorer
i changed buffer from string to zstring type..
I still dont know how to kill console in background ?? ..it is so annoying ...
Code: Select all
#include "Windows.bi"
#Include Once "win\commdlg.bi"
#define chNull chr( 0 )
#define chNullNull chr( 0, 0 )
Dim ofn As OPENFILENAME
Dim retVal As Long
Dim sep as string : sep = chr(0)
Dim buffer As zstring * 255
Dim filter As string = "All files "+ sep + "*.*"+ sep + "Bitmap files" + sep + "*.bmp"
with ofn
.lStructSize= 76 'sizeof( OPENFILENAME )
.hwndOwner=GetForegroundWindow()
.hInstance = GetModuleHandle(0)
.lpstrFilter=strPtr( filter )
.lpstrFile=strPtr( buffer )
.nMaxFile= 255
.lpstrTitle=strptr( "Open file" )
.Flags=OFN_FILEMUSTEXIST or OFN_EXPLORER or OFN_HIDEREADONLY
.lpstrDefExt=strPtr( "bmp" )
end with
retval = GetOpenFileName( @ofn )
MessageBox( 0, strPtr( buffer ),str(retval) + " Your File:", MB_OK or MB_SETFOREGROUND )
Re: openfilename
When you compile, use the "-s gui" option, as in:aurelVZAB wrote:Ok
I still dont know how to kill console in background ?? ..it is so annoying ...
fbc -s gui toy.bas
This tells FreeBasic you don't want that annoying console :)
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: openfilename
fbc -s gui blabla.basaurelVZAB wrote:I still dont know how to kill console in background ??
(default is -s console)
Joshy
UPS: @Ed Davis was faster :-)
Re: openfilename
"I still dont know how to kill console in background ?? ..it is so annoying ..."
Are you using Geany as editor? It can be Geany doing that, but I cannot find the option to disable that at the moment. Do you also get the console when you run the program from the file explorer? And see also: Compiler Option: -s
(really too slow)
Are you using Geany as editor? It can be Geany doing that, but I cannot find the option to disable that at the moment. Do you also get the console when you run the program from the file explorer? And see also: Compiler Option: -s
(really too slow)
Last edited by badidea on May 29, 2021 9:26, edited 1 time in total.
Re: openfilename
Yes
Ed,dj,bad_idea... thanks!
oh ..i forgot to ask Kuan...i am using FB_Poseidon and i don't see that in Options
hmm ...maybe i really need to modify AurelEdit for FreeBasic , once again...
I have in plan to add OpenFile,SaveFile into Bitmap editor program ..i hope that should work!
Ed,dj,bad_idea... thanks!
oh ..i forgot to ask Kuan...i am using FB_Poseidon and i don't see that in Options
hmm ...maybe i really need to modify AurelEdit for FreeBasic , once again...
I have in plan to add OpenFile,SaveFile into Bitmap editor program ..i hope that should work!