Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Challange VFP: specify Text Length
Message
 
 
To
24/04/2002 18:37:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00648876
Message ID:
00649397
Views:
44
Well,
I never noticed the bug

Thanx - Albert


>
>* blank lines after comments endin in ; are required
>*!*	#include <stdio.h>
>*!*	main(int argc, char * argv[])
>lparameters tc1, tc2, tc3
>*!*	{
>*!*	        int c;
>
>local lcc, lccr, lclf
>*!*	        int cr=0x0d;
>
>lncr = chr(0x0d)
>*!*	        int lf=0d0a;
>
>lnlf = chr(0x0a)	&& bug in the C code
>*!*	        FILE *in, *out;
>
>local lnin, lnout
>*!*	        printf("argument count: %d",argc);
>
>? "argument count: " + transform(pcount())
>*!*	        if ( argc < 4 ) { puts("Usage: setrec.exe (number of bytes for each record) (input file) (output file)"); }
>
>if pcount() < 3
>	? "Usage: setrec.exe (number of bytes for each record) (input file) (output file)"
>else
>*!*	        printf("operation beginning on: %s->%s\n",argv[2],argv[3]);
>
>	?? "operation beginning on: " + tc2 + "->" + tc3
>*!*	        in = fopen(argv[2], "rb");
>
>	lnin = fopen(tc2, 0)
>*!*	        if ( in == NULL ) { printf("Could not open input file,\nUsage: setrec.exe (number of bytes for each record) (input file) (output file)"); }
>
>	if lnin = -1
>		? "Could not open input file,"
>		? "Usage: setrec.exe (number of bytes for each record) (input file) (output file)"
>	endif
>*!*	        out = fopen(argv[3], "wb");
>
>	lnout = fopen(tc3, 1)
>*!*	        if ( out == NULL ) { printf("Could not open output file,\nUsage: setrec.exe (number of bytes for each record) (input file) (output file)"); }
>
>	if lnout = -1
>		? "Could not open output file,"
>		? "Usage: setrec.exe (number of bytes for each record) (input file) (output file)"
>	endif
>*!*	        for (int count=1; c=fgetc(in)!=EOF ; count++)
>*!*	        {
>	local lncount
>	lncount = 0
>	do while !feof(lnin)
>		lncount = lncount + 1
>		lcc = fread(lnin, 1)
>*!*	          if ( count==(argv[1])) /* if bytes read is same as expected. */
>*!*	          {
>		if lncount = val(tc1)	&& the C code is wrong because (argv[1]) will not evaluate to the count
>*!*	            fputc(c,out);
>*!*	            fputc(cr,out);
>*!*	            fputc(lf,out);
>*!*	            count=-1;
>
>			fwrite(lnout, lcc + lccr + lclf)
>*!*	          }
>*!*	          else
>		else
>*!*	{
>*!*	            if (c==cr || c==lf)
>*!*	            {
>			if lcc = lccr or lcc = lclf
>*!*	              count=0;
>
>				lncount = 0			
>*!*	            }
>*!*	            else
>*!*	{
>			else
>*!*	              fputc(c,out);
>
>				fwrite(lnout, lcc)
>*!*	            } /* end of inner if else loop */
>			endif
>*!*	          } /* end of if else loop */
>		endif
>*!*	        } /* end of for loop */
>	enddo
>*!*	   fclose(in);
>
>	fclose(lnin)
>*!*	   fclose(out);
>
>	fclose(lnout)
>*!*	   printf("operation completed on: %s->%s\n",argv[2],argv[3]);
>	? "operation completed on: " + tc2 + "->" + tc3
>*!*	}
>endif
>
>>Needed,
>>A way to mandate an input text file at a specified record length!
>>C code works well ...
Edgar L. Bolton, B.S. B.B.A.
Previous
Reply
Map
View

Click here to load this message in the networking platform