KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q40870: BC 6.00 Example of OS/2 API Function Call DosNewSize

Article: Q40870
Product(s): See article
Version(s): 6.00 6.00b 7.00
Operating System(s): OS/2
Keyword(s): ENDUSER | SR# S890125-34 | mspl13_basic
Last Modified: 1-FEB-1990

Below is a sample program that makes a call to the MS OS/2 API
function DosNewSize. This function can be used to truncate or expand a
file. If the file is expanded, the new bytes are undefined. The
program also makes calls to DosOpen and DosClose.

The program can be compiled in Microsoft BASIC Compiler Versions 6.00
and 6.00b for MS OS/2 and Microsoft BASIC Professional Development
System (PDS) Version 7.00 for MS OS/2.

The following is the sample program:

REM $INCLUDE: 'bsedosfl.bi'
DEFINT a-z
CLS
DIM filelist AS FileStatus
DIM sizel AS LONG
DIM reserved AS LONG
DIM buf AS STRING*512
DIM distance AS LONG
DIM NewPointer AS LONG

input "Enter the Filename : ";fl$
fl$=fl$+chr$(0)
openflag=17
openmode=&h6092

x=DosOpen(varseg(fl$),sadd(fl$),handle,action,sizel,_
          filea,openflag,openmode,reserved)

IF (x) THEN
   print "An error occurred.  The number is : ";x
   end
ELSE
  input "Enter the new size ",newsize&
  x=DosNewSize(handle,newsize&)
  IF (x) THEN
     Print "An error occurred.  The number is : ";x
  ELSE
     Print "File size was changed"
  END IF
  x=DosClose%(handle)
  IF (x) THEN
     color 7 :PRINT "An error occurred. The number is : ";x :color 15
  ELSE
     print "File Closed."
     print "Enter any key to exit..."
     while inkey$="" :wend
  END IF
END IF
END

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.