home *** CD-ROM | disk | FTP | other *** search
- /*
-
- This example app, written for a standard C compiler, generates an array
- of 5x3 boxes of size 1.0x1.0 each.
- The information is written in ARRAY.DRW file to be loaded in the PalDRAW app.
- The DRW file format is defined in the document F150797M available in our
- www site.
-
- (C) Ariel Rocholl 1996,1997
- e-mail: aroch@geocities.com
- http:\\ourworld.compuserve.com\homepages\ariel_rocholl\palmtop.htm
-
- This app was compiled using Microsoft Visual C++ 4.2.
-
- */
-
- /* ----------------------------------------------------------------------- */
-
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <io.h>
- #include <stdio.h>
- #include <string.h>
-
- /* ----------------------------------------------------------------------- */
- /*Function which writes a string in the opened file as a text line*/
-
- void WriteStringLine(int nFileHandle, const char* pString)
- {
- _write(nFileHandle,pString,strlen(pString));
- _write(nFileHandle,"\n",1);
- }
-
- /* ----------------------------------------------------------------------- */
- /* C main process*/
-
- void main (void)
- {
- /*Creates the output file in the current directory*/
- int nFileHandle=_open("ARRAY.DRW",_O_WRONLY|_O_CREAT|_O_TEXT,_S_IREAD|_S_IWRITE);
- int nHorizPoint, nVertPoint;
-
- /*Writes the header file*/
- WriteStringLine(nFileHandle, "#PalDRAW file - ARRAY example written in C");
- /*Don't write Status section as it is optional and not required in this example*/
- /*Don't write Blocks section as it is optional and not required in this example*/
- /*Writes the entities section name*/
- WriteStringLine(nFileHandle,"[Entities]");
- /*Write each box increasing horizontal and vertical origin*/
- for (nHorizPoint=0; nHorizPoint<10; nHorizPoint+=2)
- {
- for (nVertPoint=0; nVertPoint<6; nVertPoint+=2)
- {
- char pLine[100];
- /*Write 4 lines as a box*/
- sprintf(pLine,"L %d %d %d %d",nHorizPoint+0,nVertPoint+0,nHorizPoint+1,nVertPoint+0);
- WriteStringLine(nFileHandle,pLine);
- sprintf(pLine,"L %d %d %d %d",nHorizPoint+1,nVertPoint+0,nHorizPoint+1,nVertPoint+1);
- WriteStringLine(nFileHandle,pLine);
- sprintf(pLine,"L %d %d %d %d",nHorizPoint+1,nVertPoint+1,nHorizPoint+0,nVertPoint+1);
- WriteStringLine(nFileHandle,pLine);
- sprintf(pLine,"L %d %d %d %d",nHorizPoint+0,nVertPoint+1,nHorizPoint+0,nVertPoint+0);
- WriteStringLine(nFileHandle,pLine);
- }
- }
-
- /*Close the file*/
- _close(nFileHandle);
- }
-
- /* ----------------------------------------------------------------------- */
- /* End of file */
- /* ----------------------------------------------------------------------- */
-