I'm adding a form to my backup program.
When compiling under the Win32 GUI (Release), the final line in this code snippet generates a type mismatch error.
open "backup2.log" For Output Encoding "utf-8" As #3
print #3,";"
print #3, " Mirror backup ";date;spc(2);time
print #3, spc(2); string(50,45) 'replacement line to fix error in gui version
print #3, spc(2); string(50,"-") 'original line from console version
close
C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas(152) error 58: Type mismatch, at parameter 2
This is not the case with the console version of my program.
So it appears that when I added a form, the compiler doesn't accept "-" as a parameter.
Another small issue with the 2.1.5 version.
One of the final lines in my code gets modified from "¯\(º_º)/¯" to "Ã,¯\(Ã,º_Ã,º)/Ã,¯"
The .bas file is in UTF-16 (BOM)
Print #3, "¯\(º_º)/¯" 'original line
Print #3, "Ã,¯\(Ã,º_Ã,º)/Ã,¯" 'line in WinFBE_VD_MAIN.bas
Hi, I am not 100% sure yet what this problem would be. Scintilla handles the screen code using UTF-8 whereas you are saving and loading from UTF-16. It is quite possible that some of save/conversion code is not translating those characters correctly from UTF-8 to UTF-16.
I have logged the problem and will investigate.
I may as well include another problem I encountered on another program I'm working on. On the console version of my program, the code below doesn't cause any compile warnings. But on the GUI version, the LPCSTR type appears to have issues.
' You should always include a resource file that references a valid manifest.xml
' file otherwise your application will not properly display Windows themed controls.
' Sample resource.rc and manifest.xml files can be found in the WinFBE \Settings folder.
' The following WinFBE directive includes the resource in your application. Simply
' uncomment the line.
' If you are using WinFBE's project management features then delete the following line
' because a resource file will be generated automatically.
' '#RESOURCE "resource.rc"
''
'' Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)
#Include "windows.bi"
#Include "vbcompat.bi"
'Possible registry data types
Enum InTypes
ValNull = 0
ValString = 1
ValXString = 2
ValBinary = 3
ValDWord = 4
ValLink = 6
ValMultiString = 7
ValResList = 8
End Enum
Sub WriteRegistry(Byval Group As HKEY, Byval Section As LPCSTR, Byval Key As LPCSTR, Byval ValType As InTypes, value As String)
Dim lResult As Integer
Dim lKeyValue As HKEY
Dim lNewVal As DWORD
Dim sNewVal As String * 2048
lResult = RegCreateKey(Group, Section, @lKeyValue)
If ValType = ValDWord Then
lNewVal = Cuint(value)
lResult = RegSetValueEx(lKeyValue, Key, 0&, ValType, Cast(Byte Ptr,@lNewVal), Sizeof(DWORD))
Else
If ValType = ValString Then
sNewVal = value & Chr(0)
lResult = RegSetValueEx(lKeyValue, Key, 0&, ValString, Cast(Byte Ptr,@sNewVal), Len(sNewVal))
EndIf
End If
lResult = RegFlushKey(lKeyValue)
lResult = RegCloseKey(lKeyValue)
End Sub
Successful Compile (Errors 0 Warnings 3)
Primary Source: C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas
Target Compilation: C:\Decoy\Software\fb\plfm.exe (116 KB, 118272 bytes)
Compile Time: 1.6 seconds (2020-05-14 10:01:14)
Command Line:
C:\Users\Laura\AppData\Local\WinFBE\FreeBASIC-1.07.1-gcc-5.2\fbc32.exe -m "C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas" -v -s gui -x "C:\Decoy\Software\fb\plfm.exe"
FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
compiling: C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas -o C:\Decoy\Software\fb\WinFBE_VD_MAIN.asm (main module)
C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas(84) warning 3(1): Passing different pointer types, at parameter 2 of REGCREATEKEY()
C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas(87) warning 3(1): Passing different pointer types, at parameter 2 of REGSETVALUEEX()
C:\Decoy\Software\fb\WinFBE_VD_MAIN.bas(91) warning 3(1): Passing different pointer types, at parameter 2 of REGSETVALUEEX()
Is it possible that you can zip up that project and email it to me at support@planetsquires.com ?
I am thinking that it may have to do with the way in which your project is structured in addition to the file types. It is hard to debug without a concrete example in front of me.
backup.bas - console version
backup2.bas - gui version (in progress)
registry.bas - console version
registry2.bas - gui version (under construction)
Thanks for the files. I will look at them tomorrow and hopefully pinpoint what the issues may be.
Hi,
I have found the problem with the Registry code that you posted. When the code is added as part of a Form then the functions will automatically try to use the UNICODE versions of the api functions. So, in your case, it would have to be a LPCWSTR incoming parameter. This is because any Forms used in WinFBE MUST have Unicode enabled. You can get around this by explicitly appending "A" to your registry functions (ie. RegOpenKeyA, RegQueryValueExA, RegSetValueExA). Basically, any key that handles strings.
Another issue that I found (and have now fixed), is that if you open both your files in the editor at the same time (registry.bas and registry2.bas) then you will get errors. This is because in non-projects, only the file with focus is supposed to be compiled. This worked until you tried to compile the registry2.bas Form file. There was code in the code generation that would aggregate code from all loaded files in the editor. Basically, it treated compiling the Form as if it was part of a Project when in fact it is not.
Quote from: Bumblebee on May 14, 2020, 02:30:39 PM
Another small issue with the 2.1.5 version.
One of the final lines in my code gets modified from "¯\(º_º)/¯" to "Ã,¯\(Ã,º_Ã,º)/Ã,¯"
The .bas file is in UTF-16 (BOM)
Print #3, "¯\(º_º)/¯" 'original line
Print #3, "Ã,¯\(Ã,º_Ã,º)/Ã,¯" 'line in WinFBE_VD_MAIN.bas
Hi, this error is also now fixed. It was indeed a Utf8 to UTF-16 conversion error.
The fix will be in 2.1.6.
Thank-you :)
Have you found the reason for the String(50,"-") error?