Loading ...
Sorry, an error occurred while loading the content.
 

Re: [libertybasic] Re: veneffy - program causes exception error

Expand Messages
  • RipSaw
    Stefan thank u for helping me with LB  programming this year. Happy New Year.  Kurt ________________________________ From: Stefan Pendl
    Message 1 of 11 , Dec 31, 2011
      Stefan thank u for helping me with LB  programming this year.
      Happy New Year.  Kurt


      ________________________________
      From: Stefan Pendl <pendl2megabit@...>
      To: libertybasic@yahoogroups.com
      Sent: Saturday, December 31, 2011 7:36 PM
      Subject: Re: [libertybasic] Re: veneffy - program causes exception error



       

      Am 01.01.2012 01:31, schrieb Stefan Pendl:
      > Am 01.01.2012 01:12, schrieb veneff@...:
      >> Stefan,
      >>
      >> Is boolean a 16 or 32 bit integer?
      >>
      >> I changed the 3 occurances of AS BOOLEAN to AS LONG.
      >> Still similar results.
      >>
      >> When I ran with the changes I got the error:
      >> MessageNotUnderstood
      >>
      >> I closed LB and restarted and reran with the same results.
      >> I did the same but ran the Debug with animation getting the error:
      >> a non-continuable protection violation has occurred. Check ERROR.LOG file.
      >> The error log just shows the same error with a register dump.
      >> At this point, when I rerun the program I get the non-continuable... error.
      >> I have to reboot in order to get the MessageNotUnderstood error.
      >>
      >
      > See the code below for the size of the data types in LB.
      >
      > The best translation table between C and LB can be found at
      > http://www.b6sw.com/forum/content.php?mode=hints&t=235
      >
      >

      Does the following function work?

      '---code start (watch for line wraps)

      function FindFiles(Path$, ByRef Found$)
      ' searches for the given file or folder
      '
      ' fills Found$ with the list of found files or folders
      ' separated by ;
      '
      ' returns the number of files or folders found

      struct Win32FindData, _
      FileAttributes as ulong, _
      CreationTimeLow as ulong, _
      CreationTimeHigh as ulong, _
      LastAccessTimeLow as ulong, _
      LastAccessTimeHigh as ulong, _
      LastWriteTimeLow as ulong, _
      LastWriteTimeHigh as ulong, _
      FileSizeHigh as ulong, _
      FileSizeLow as ulong, _
      Reserved0 as ulong, _
      Reserved1 as ulong, _
      FileName$ as char[260], _
      AlternateFileName$ as char[14]

      calldll #kernel32, "FindFirstFileA", _
      Path$ as ptr, _
      Win32FindData as struct,_
      handle as ulong

      if handle = _INVALID_HANDLE_VALUE then
      FindFiles = 0
      else
      do
      if Found$ = "" then
      Found$ = Win32FindData.FileName$.struct
      else
      Found$ = Found$; ";"; Win32FindData.FileName$.struct
      end if
      FindFiles = FindFiles + 1

      calldll #kernel32, "FindNextFileA",_
      handle as ulong,_
      Win32FindData as struct,_
      result as long
      loop until result = 0

      calldll #kernel32, "FindClose", _
      handle as ulong, _
      result as long
      end if
      end function

      '---code end

      --
      Stefan Pendl
      http://stefanpendl.runbasichosting.com/

      LB 4.04 Pro ... http://www.libertybasic.com/assist.html
      LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

      LB Community Wiki .............. http://basic.wikispaces.com/
      LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
      LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

      Books at http://www.lulu.com/ and http://www.amazon.com/
      Alyce Watson ... APIs for Liberty BASIC
      Carl Gundel .... Beginning Programming with Liberty BASIC

      Windows 7 Home Premium 64-bit SP1
      AMD Turion X2 RM-70 2GHz, 4GB RAM



      [Non-text portions of this message have been removed]
    • veneff@intouchmi.com
      Stefan, Actually, the question I should have been asking, is the C type bool 16 or 32 bits. Anyway, I think your function FindFiles seems to working. I did
      Message 2 of 11 , Jan 1, 2012
        Stefan,

        Actually, the question I should have been asking, is the C type bool 16 or
        32 bits.

        Anyway, I think your function FindFiles seems to working. I did get an
        error keyNotFound (or something like that) one time, but I may have done
        something to cause it by ending the LB task prematurely because it was
        taking so long to run because the file list string was growing large while
        iterating that loop 1000 times. I'm going to restructure the original
        program so that the find first...next API calls occur together in the same
        routine. This will take some time but I'll let you know what I find.

        Why do you figure the problem was occurring?

        Vance

        > Am 01.01.2012 01:31, schrieb Stefan Pendl:
        >> Am 01.01.2012 01:12, schrieb veneff@...:
        >>> Stefan,
        >>>
        >>> Is boolean a 16 or 32 bit integer?
        >>>
        >>> I changed the 3 occurances of AS BOOLEAN to AS LONG.
        >>> Still similar results.
        >>>
        >>> When I ran with the changes I got the error:
        >>> MessageNotUnderstood
        >>>
        >>> I closed LB and restarted and reran with the same results.
        >>> I did the same but ran the Debug with animation getting the error:
        >>> a non-continuable protection violation has occurred. Check ERROR.LOG
        >>> file.
        >>> The error log just shows the same error with a register dump.
        >>> At this point, when I rerun the program I get the non-continuable...
        >>> error.
        >>> I have to reboot in order to get the MessageNotUnderstood error.
        >>>
        >>
        >> See the code below for the size of the data types in LB.
        >>
        >> The best translation table between C and LB can be found at
        >> http://www.b6sw.com/forum/content.php?mode=hints&t=235
        >>
        >>
        >
        > Does the following function work?
        >
        > '---code start (watch for line wraps)
        >
        > function FindFiles(Path$, ByRef Found$)
        > ' searches for the given file or folder
        > '
        > ' fills Found$ with the list of found files or folders
        > ' separated by ;
        > '
        > ' returns the number of files or folders found
        >
        > struct Win32FindData, _
        > FileAttributes as ulong, _
        > CreationTimeLow as ulong, _
        > CreationTimeHigh as ulong, _
        > LastAccessTimeLow as ulong, _
        > LastAccessTimeHigh as ulong, _
        > LastWriteTimeLow as ulong, _
        > LastWriteTimeHigh as ulong, _
        > FileSizeHigh as ulong, _
        > FileSizeLow as ulong, _
        > Reserved0 as ulong, _
        > Reserved1 as ulong, _
        > FileName$ as char[260], _
        > AlternateFileName$ as char[14]
        >
        > calldll #kernel32, "FindFirstFileA", _
        > Path$ as ptr, _
        > Win32FindData as struct,_
        > handle as ulong
        >
        > if handle = _INVALID_HANDLE_VALUE then
        > FindFiles = 0
        > else
        > do
        > if Found$ = "" then
        > Found$ = Win32FindData.FileName$.struct
        > else
        > Found$ = Found$; ";"; Win32FindData.FileName$.struct
        > end if
        > FindFiles = FindFiles + 1
        >
        > calldll #kernel32, "FindNextFileA",_
        > handle as ulong,_
        > Win32FindData as struct,_
        > result as long
        > loop until result = 0
        >
        > calldll #kernel32, "FindClose", _
        > handle as ulong, _
        > result as long
        > end if
        > end function
        >
        > '---code end
        >
        > --
        > Stefan Pendl
        > http://stefanpendl.runbasichosting.com/
        >
        > LB 4.04 Pro ... http://www.libertybasic.com/assist.html
        > LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe
        >
        > LB Community Wiki .............. http://basic.wikispaces.com/
        > LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
        > LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/
        >
        > Books at http://www.lulu.com/ and http://www.amazon.com/
        > Alyce Watson ... APIs for Liberty BASIC
        > Carl Gundel .... Beginning Programming with Liberty BASIC
        >
        > Windows 7 Home Premium 64-bit SP1
        > AMD Turion X2 RM-70 2GHz, 4GB RAM
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
      • Stefan Pendl
        ... The LB boolean is 16-bit long and BOOL is 32-bit, so the API function likes to return more than boolean can hold and you get an overflow error. The general
        Message 3 of 11 , Jan 1, 2012
          Am 01.01.2012 18:16, schrieb veneff@...:
          > Stefan,
          >
          > Actually, the question I should have been asking, is the C type bool 16 or
          > 32 bits.
          >

          The LB boolean is 16-bit long and BOOL is 32-bit, so the API function
          likes to return more than boolean can hold and you get an overflow error.

          The general protection violation is usually indicating the use of an
          incorrect data type:

          1) one that can't hold the returned value
          2) using a regular data type, where a structure containing that data
          type should be used to enable the API function to fill it with a
          value
          3) using a string pointer without a trailing CHR$(0) initially

          > Anyway, I think your function FindFiles seems to working. I did get an
          > error keyNotFound (or something like that) one time, but I may have done
          > something to cause it by ending the LB task prematurely because it was
          > taking so long to run because the file list string was growing large while
          > iterating that loop 1000 times. I'm going to restructure the original
          > program so that the find first...next API calls occur together in the same
          > routine. This will take some time but I'll let you know what I find.
          >
          > Why do you figure the problem was occurring?
          >
          > Vance
          >

          It might have been the file name item of the structure, which is
          declared as char[MAX_PATH] in C, where MAX_PATH is 260 instead of 256 as
          you used.


          --
          Stefan Pendl
          http://stefanpendl.runbasichosting.com/

          LB 4.04 Pro ... http://www.libertybasic.com/assist.html
          LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

          LB Community Wiki .............. http://basic.wikispaces.com/
          LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
          LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

          Books at http://www.lulu.com/ and http://www.amazon.com/
          Alyce Watson ... APIs for Liberty BASIC
          Carl Gundel .... Beginning Programming with Liberty BASIC

          Windows 7 Home Premium 64-bit SP1
          AMD Turion X2 RM-70 2GHz, 4GB RAM
        • veneff@intouchmi.com
          Stefan, It was the MaxPath size. When I had searched on the MSDN site, the only thing I found was a mention of 256 bytes. I see now that _MAX_PATH = 260 even
          Message 4 of 11 , Jan 1, 2012
            Stefan,

            It was the MaxPath size. When I had searched on the MSDN site, the only
            thing I found was a mention of 256 bytes. I see now that _MAX_PATH = 260
            even though it doesn't seem to be allowed in the AS char[...] length.

            Thanks a lot for your efforts!

            Vance

            > Am 01.01.2012 18:16, schrieb veneff@...:
            >> Stefan,
            >>
            >> Actually, the question I should have been asking, is the C type bool 16
            >> or
            >> 32 bits.
            >>
            >
            > The LB boolean is 16-bit long and BOOL is 32-bit, so the API function
            > likes to return more than boolean can hold and you get an overflow error.
            >
            > The general protection violation is usually indicating the use of an
            > incorrect data type:
            >
            > 1) one that can't hold the returned value
            > 2) using a regular data type, where a structure containing that data
            > type should be used to enable the API function to fill it with a
            > value
            > 3) using a string pointer without a trailing CHR$(0) initially
            >
            >> Anyway, I think your function FindFiles seems to working. I did get an
            >> error keyNotFound (or something like that) one time, but I may have done
            >> something to cause it by ending the LB task prematurely because it was
            >> taking so long to run because the file list string was growing large
            >> while
            >> iterating that loop 1000 times. I'm going to restructure the original
            >> program so that the find first...next API calls occur together in the
            >> same
            >> routine. This will take some time but I'll let you know what I find.
            >>
            >> Why do you figure the problem was occurring?
            >>
            >> Vance
            >>
            >
            > It might have been the file name item of the structure, which is
            > declared as char[MAX_PATH] in C, where MAX_PATH is 260 instead of 256 as
            > you used.
            >
            >
            > --
            > Stefan Pendl
            > http://stefanpendl.runbasichosting.com/
            >
            > LB 4.04 Pro ... http://www.libertybasic.com/assist.html
            > LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe
            >
            > LB Community Wiki .............. http://basic.wikispaces.com/
            > LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
            > LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/
            >
            > Books at http://www.lulu.com/ and http://www.amazon.com/
            > Alyce Watson ... APIs for Liberty BASIC
            > Carl Gundel .... Beginning Programming with Liberty BASIC
            >
            > Windows 7 Home Premium 64-bit SP1
            > AMD Turion X2 RM-70 2GHz, 4GB RAM
            >
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
          • Stefan Pendl
            ... Yes, it would be great if we could use constants and variables with char[], but we can t. Hope this will be supported in LB5, Carl? -- Stefan Pendl
            Message 5 of 11 , Jan 1, 2012
              Am 01.01.2012 22:10, schrieb veneff@...:
              > Stefan,
              >
              > It was the MaxPath size. When I had searched on the MSDN site, the only
              > thing I found was a mention of 256 bytes. I see now that _MAX_PATH = 260
              > even though it doesn't seem to be allowed in the AS char[...] length.
              >

              Yes, it would be great if we could use constants and variables with
              char[], but we can't.

              Hope this will be supported in LB5, Carl?

              --
              Stefan Pendl
              http://stefanpendl.runbasichosting.com/

              LB 4.04 Pro ... http://www.libertybasic.com/assist.html
              LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

              LB Community Wiki .............. http://basic.wikispaces.com/
              LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
              LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

              Books at http://www.lulu.com/ and http://www.amazon.com/
              Alyce Watson ... APIs for Liberty BASIC
              Carl Gundel .... Beginning Programming with Liberty BASIC

              Windows 7 Home Premium 64-bit SP1
              AMD Turion X2 RM-70 2GHz, 4GB RAM
            Your message has been successfully submitted and would be delivered to recipients shortly.