PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 10
 on: Today at 09:24:26 PM 
Started by Paul Squires - Last post by Paul Squires
I went into the forum admin settings and changed the following server setting:

Seconds before an unused session timeout

I changed the value to 14400 because I saw that mentioned somewhere on the web. Maybe this make a difference for you with that session timeout problem.

 on: Today at 08:39:17 PM 
Started by Paul Squires - Last post by Paul Squires
Ah yes right you are. I should have looked at the code more closely... it is the first 1K that is read not the full file greater than 1K.

Sorry that you are having timeout problems. I wish I knew what causes that.

 on: Today at 06:21:55 PM 
Started by Paul Squires - Last post by JosÚ Roca
I'm having timeout problems again.

I fyou need that function, I will include it.

However, you're wrong in the assumption that AfxIsFileUnicode has to analyze the whole file. It just reads and analyzes the first 1024 bytes.

 on: Today at 06:14:38 PM 
Started by Paul Squires - Last post by Paul Squires
Thanks for the update. I'll try to build a check into the code generation to detect such anomalies. Strange that the resource compiler blows up when there are duplicate defined images.

 on: Today at 04:22:45 PM 
Started by Paul Squires - Last post by SeaVipe
Hi Paul, I didn't notice that the Image Manager had included one image file twice. I've since removed the file from the Image Manager and all is good again...:0)

 on: Today at 01:18:03 PM 
Started by Paul Squires - Last post by Paul Squires
Hi Jose,

I have attached for your consideration a new Afx function that attempts to detect the encoding of a file. The attachment is a project with sample files that shows the function in action. I have had occasion to need to know the encoding of a text file more than just that it is unicode (AfxIsFileUnicode).

Here is the function:
Code: [Select]

'//   From the FAQ:
'//   00 00 FE FF      UTF-32, big-endian
'//   FF FE 00 00      UTF-32, little-endian
'//   FE FF            UTF-16, big-endian
'//   FF FE            UTF-16, little-endian
'//   EF BB BF         UTF-8
'//   Match the first x bytes of the file against the
'//   Byte-Order-Mark (BOM) lookup table
private function AfxGetFileEncoding( byref wszFilename as wstring ) as Integer

   type _BOM_LOOKUP
      bom   as DWORD 
      nlen  as ulong
      ntype as Integer
   end type

   '// define longest headers first
   static BOMLOOK(...) as _BOM_LOOKUP = _
   {( &H0000FEFF, 4, NCP_UTF32    ), _
    ( &HFFFE0000, 4, NCP_UTF32BE  ), _
    ( &HBFBBEF,   3, NCP_UTF8     ), _
    ( &HFFFE,     2, NCP_UTF16BE  ), _
    ( &HFEFF,     2, NCP_UTF16    ), _
    ( 0,          0, NCP_ASCII    ) _
   DIM as DWORD dwBytesRead
   DIM as HANDLE hFile
   dim as BYTE header(4)

   hFile = CreateFile( @wszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, _
      if ReadFile( hFile, @header(0), 4, @dwBytesRead, NULL ) <> 0 then
         for i as long = lbound(BOMLOOK) to ubound(BOMLOOK)
            if dwBytesRead >= BOMLOOK(i).nLen then
               if memcmp( @header(0), @BOMLOOK(i).bom, BOMLOOK(i).nlen ) = 0 then
                  return BOMLOOK(i).ntype
               end if
            end if
      end if
   end if

   return NCP_ASCII   '// default to ASCII 
end function

Here is the example code (sample text files are also in the attachment):

Code: [Select]
#define unicode

#include once "Afx\"

'// currently supported codepages
#define NCP_ASCII     0
#define NCP_UTF8      1
#define NCP_UTF16     2
#define NCP_UTF16BE   3
#define NCP_UTF32     4
#define NCP_UTF32BE   5

#include once ""

' ========================================================================================
' ========================================================================================

' Test all of the sample files in the "samples" subfolder

DIM as HANDLE hSearch
dim as CWSTR wszFilename, wszFileType, wszPath
dim as Boolean IsUnicode

wszPath = AfxGetExePathName + "samples\"

hSearch = FindFirstFile( wszPath + "*.txt", @WFD )
         wszFilename = wszPath & WFD.cFileName

         select case AfxGetFileEncoding( wszFilename )
            case NCP_UTF8
               wszFileType = "NCP_UTF8":    IsUnicode = true
            case NCP_UTF16
               wszFileType = "NCP_UTF16":   IsUnicode = true
            case NCP_UTF16BE
               wszFileType = "NCP_UTF16BE": IsUnicode = true
            case NCP_UTF32
               wszFileType = "NCP_UTF32":   IsUnicode = true
            case NCP_UTF32BE
               wszFileType = "NCP_UTF32BE": IsUnicode = true
            case NCP_ASCII
               wszFileType = "NCP_ASCII"
               ' If no BOM exists then it is possible that the file still contains
               ' unicode characters. We can test for that using AfxIsFileUnicode.
               ' We would only do this test in cases where for greater certainty
               ' that we need to know that the file contains unicode text. This is
               ' a more expensive test because the whole file has to be read into
               ' memory in order to be analyzed.
               if AfxIsFileUnicode( wszFilename ) then IsUnicode = true
         end select

         ? "Encoding: "; wszFileType, "IsUnicode: "; IsUnicode, "Filename: "; AfxStrPathName( "NAME", wszFilename)

      END IF
   LOOP WHILE FindNextFile(hSearch, @WFD)


 on: April 08, 2020, 09:21:09 PM 
Started by Paul Squires - Last post by Paul Squires
Yes, I seem to remember that type of resource file error mentioned here before. I can't remember what the outcome of it was? Maybe that was time that we all had to ensure that we had the latest GoRc resource compiler downloaded from the author's site. Those temporary files (ie TMPE582.rc) are created during compiling. They mostly contain the references to IMAGES that exist in your project. The temporary file is then appended to the main program's resource file and then deleted.

 on: April 08, 2020, 08:15:41 PM 
Started by Paul Squires - Last post by SeaVipe
WinFBE was crashing sometime during the Compile - about 10 or so seconds into it before crashing. So I deleted "projectname_db_data.ini" and "WinFBE_VD_MAIN.bas" again, but to no avail. Next, I rebooted my machine and tried again. This time (without any modifications) it compiled but threw an error: "mnemonic Not Defined" in wfxButton. This may be because when I added the new button (which started all this) I wanted the mnemonic for the button to be "c" which was already in use by the "Cancel" button. So I changed the Cancel button mnemonic to the letter "n" and set the new button to the letter "c". This error did not show up until after I rebooted.
Now, however, I cannot replicate the errors or the crashing but still can't compile because of my old nemesis "1 Error" (the Compiler Results tab is blank). The last line of the Compile Log reads: "compiling rc: C:\WinFBE_Suite\FreeBASIC-1.07.1-gcc-5.2\bin\win64\GoRC.exe /ni /nw /o /machine X64 /fo "C:\SRC\DailyJournal\TMPE582.obj" "C:\SRC\DailyJournal\TMPE582.rc  ■" including the 2 trailing ASCII Chr.
You may recall I've been through this before but for the life of me I can't remember what the previous fixes were. I deleted the resource file but no change. :0(
Setting any button UseMnemonics to False will throw an error pointing to this line in WinFBE_VD_MAIN.bas: "pForm->btnCancel.UseMnemonic = False". ThemeSupport is set to False for all buttons.

 on: April 08, 2020, 06:53:54 PM 
Started by Paul Squires - Last post by Paul Squires
Sounds like maybe the Form file itself is corrupted? If a Form exists in the project then it should generate a WinFBE_VD_MAIN.bas file when you compile. Not 100% sure at this point. At what point does WinFBE crash? As soon as you load the project?

 on: April 08, 2020, 04:28:02 PM 
Started by Paul Squires - Last post by SeaVipe
Hi Paul, I deleted "projectname_db_data.ini". WinFBE still crashes. "projectname_db_data.ini" does not get recreated and "WinFBE_VD_MAIN.bas" is a blank file.

Pages: [1] 2 3 ... 10