Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

File size

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PBWin/PBCC File size

    Include win32api.inc if using an old compiler.
    Added DIR$ CLOSE

    REM 64-bit Windows 7 system folder not supported



    Code:
    FUNCTION PBFileSize(BYVAL sFile AS STRING) AS QUAD
      [B]REM 64-bit Windows 7 system folder not supported[/B]
    
      LOCAL Udt AS DIRDATA         'DIRDATA built into PowerBASIC
      sFile = DIR$ (sfile TO Udt)  'fill structure
      DIR$ CLOSE                   'Michael Mattias
      IF LEN(sFile) THEN           'file found
        FUNCTION = MAK(QUAD, Udt.FileSizeLow , Udt.FileSizeHigh)'make quad
      ELSE
        FUNCTION = -53             'not found, return error -53
      END IF
     
    END FUNCTION
     
    FUNCTION PBMAIN AS LONG
     
      LOCAL sFile AS STRING
      LOCAL qSize AS QUAD
     
      sFile = "c:\windows\system32\mrt.exe"
      qSize = PBFileSize(sFile)
      ? USING$("#,",qSize)
     
    END FUNCTION
    Mike Doty
    Member
    Last edited by Mike Doty; 25 Aug 2010, 11:06 PM. Reason: Added DIR$ CLOSE - Thank you Michael Mattias

  • #2
    This works on my Windows 7 / 64 bit:

    Code:
    '-------------------------------------------------------------------------------
    '                      D I S P L A Y B A S N A M E S
    '-------------------------------------------------------------------------------
    '
    ' Display the name of BAS files in the current directory, with their length
    '
    ' Version 26-sep-2010 - PB/CC 5.05
    '
    '-------------------------------------------------------------------------------
    
     #COMPILE EXE
     #DIM ALL
     #INCLUDE "win32api.inc"
    
    
    
     FUNCTION PBMAIN()
    
       DIM FileList(1024) AS DIRDATA
       DIM Index AS LONG, OneFile AS STRING
                                                                 
       CONSOLE SET SCREEN 25,80
    
       CURSOR OFF
       COLOR 15,1
       CLS
      
    
       OneFile = DIR$("*.bas", TO FileList(index))
       
       WHILE LEN(OneFile) AND Index < 24 ' max = 24 rows displayed
         INCR Index
         OneFile = DIR$(NEXT, TO FileList(Index) )
         PRINT OneFile; "/ len = ";
         PRINT FileList(Index).FileSizeLow
       WEND
       
       WAITKEY$
    
     EndPgm:
    
     END FUNCTION
    Salvatore
    salvatore renda
    Member
    Last edited by salvatore renda; 26 Sep 2010, 11:13 AM.

    Comment

    Working...
    X