FreeBASIC  0.91.0
io_widthfile.c
Go to the documentation of this file.
1 /* set the with for files */
2 
3 #include "fb.h"
4 
5 /*:::::*/
6 FBCALL int fb_WidthFile( int fnum, int width )
7 {
8  int cur = width;
10 
11  FB_LOCK();
12 
13  handle = FB_HANDLE_DEREF(FB_FILE_TO_HANDLE(fnum));
14 
15  if( !FB_HANDLE_USED(handle) ) {
16  /* invalid file handle */
17  FB_UNLOCK();
19  }
20 
21  if( handle->hooks==NULL ) {
22  /* not opened yet */
23  FB_UNLOCK();
25  }
26 
27  if( handle==FB_HANDLE_SCREEN ) {
28  /* SCREEN device */
29  if( width!=-1 ) {
30  fb_Width( width, -1 );
31  }
32  cur = FB_HANDLE_SCREEN->width;
33 
34  } else {
35  if( width!=-1 ) {
36  handle->width = width;
37  if( handle->hooks->pfnSetWidth!=NULL )
38  handle->hooks->pfnSetWidth( handle, width );
39  }
40  cur = handle->width;
41  }
42 
43  FB_UNLOCK();
44 
45  if( width==-1 ) {
46  return cur;
47  }
48 
49  return fb_ErrorSetNum( FB_RTERROR_OK );
50 }