Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Challange VFP: specify Text Length
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Challange VFP: specify Text Length
Miscellaneous
Thread ID:
00648876
Message ID:
00648876
Views:
52
Needed,
A way to mandate an input text file at a specified record length!
C code works well ...
#include <stdio.h>
main(int argc, char * argv[])
{
        int c;
        int cr=0x0d;
        int lf=0d0a;
        FILE *in, *out;
        printf("argument count: %d",argc);
        if ( argc < 4 ) { puts("Usage: setrec.exe (number of bytes for each record) (input file) (output file)"); }
        printf("operation beginning on: %s->%s\n",argv[2],argv[3]);
        in = fopen(argv[2], "rb");
        if ( in == NULL ) { printf("Could not open input file,\nUsage: setrec.exe (number of bytes for each record) (input file) (output file)"); }
        out = fopen(argv[3], "wb");
        if ( out == NULL ) { printf("Could not open output file,\nUsage: setrec.exe (number of bytes for each record) (input file) (output file)"); }
        for (int count=1; c=fgetc(in)!=EOF ; count++)
        {
          if ( count==(argv[1])) /* if bytes read is same as expected. */
          {
            fputc(c,out);
            fputc(cr,out);
            fputc(lf,out);
            count=-1;
          }
          else
          {
            if (c==cr || c==lf)
            {
              count=0;
            }
            else
            {
              fputc(c,out);
            } /* end of inner if else loop */
          } /* end of if else loop */
        } /* end of for loop */
   fclose(in);
   fclose(out);
   printf("operation completed on: %s->%s\n",argv[2],argv[3]);
}
Now lets do it in VFP ...

Thanx in advance
Edgar L. Bolton, B.S. B.B.A.
Next
Reply
Map
View

Click here to load this message in the networking platform