home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / HP95_100 / GRAPHICS / DRW_FF / ARRAY.C next >
Encoding:
C/C++ Source or Header  |  1997-07-25  |  2.8 KB  |  75 lines

  1. /*
  2.  
  3. This example app, written for a standard C compiler, generates an array 
  4. of 5x3 boxes of size 1.0x1.0 each.
  5. The information is written in ARRAY.DRW file to be loaded in the PalDRAW app.
  6. The DRW file format is defined in the document F150797M available in our
  7. www site.
  8.  
  9.   (C) Ariel Rocholl 1996,1997
  10.   e-mail: aroch@geocities.com
  11.   http:\\ourworld.compuserve.com\homepages\ariel_rocholl\palmtop.htm
  12.  
  13. This app was compiled using Microsoft Visual C++ 4.2.
  14.  
  15. */
  16.  
  17. /* ----------------------------------------------------------------------- */
  18.  
  19. #include <fcntl.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22. #include <io.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25.  
  26. /* ----------------------------------------------------------------------- */
  27. /*Function which writes a string in the opened file as a text line*/
  28.  
  29. void WriteStringLine(int nFileHandle, const char* pString)
  30. {
  31.     _write(nFileHandle,pString,strlen(pString));
  32.     _write(nFileHandle,"\n",1);
  33. }
  34.  
  35. /* ----------------------------------------------------------------------- */
  36. /* C main process*/
  37.  
  38. void main (void)
  39. {
  40.     /*Creates the output file in the current directory*/
  41.     int nFileHandle=_open("ARRAY.DRW",_O_WRONLY|_O_CREAT|_O_TEXT,_S_IREAD|_S_IWRITE);
  42.     int nHorizPoint, nVertPoint;
  43.  
  44.     /*Writes the header file*/
  45.     WriteStringLine(nFileHandle, "#PalDRAW file - ARRAY example written in C");
  46.     /*Don't write Status section as it is optional and not required in this example*/
  47.     /*Don't write Blocks section as it is optional and not required in this example*/
  48.     /*Writes the entities section name*/
  49.     WriteStringLine(nFileHandle,"[Entities]");
  50.     /*Write each box increasing horizontal and vertical origin*/
  51.     for (nHorizPoint=0; nHorizPoint<10; nHorizPoint+=2)
  52.     {
  53.         for (nVertPoint=0; nVertPoint<6; nVertPoint+=2)
  54.         {
  55.             char pLine[100];
  56.             /*Write 4 lines as a box*/
  57.             sprintf(pLine,"L %d %d %d %d",nHorizPoint+0,nVertPoint+0,nHorizPoint+1,nVertPoint+0);
  58.             WriteStringLine(nFileHandle,pLine);
  59.             sprintf(pLine,"L %d %d %d %d",nHorizPoint+1,nVertPoint+0,nHorizPoint+1,nVertPoint+1);
  60.             WriteStringLine(nFileHandle,pLine);
  61.             sprintf(pLine,"L %d %d %d %d",nHorizPoint+1,nVertPoint+1,nHorizPoint+0,nVertPoint+1);
  62.             WriteStringLine(nFileHandle,pLine);
  63.             sprintf(pLine,"L %d %d %d %d",nHorizPoint+0,nVertPoint+1,nHorizPoint+0,nVertPoint+0);
  64.             WriteStringLine(nFileHandle,pLine);
  65.         }
  66.     }
  67.  
  68.     /*Close the file*/
  69.     _close(nFileHandle);
  70. }
  71.  
  72. /* ----------------------------------------------------------------------- */
  73. /* End of file                                                             */
  74. /* ----------------------------------------------------------------------- */
  75.