Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Guide me for converting C source to VFP
Message
 
 
To
23/07/2006 14:11:27
Reza Meamar
Homa Programming Group
Shiraz, Iran
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
Miscellaneous
Thread ID:
01138914
Message ID:
01138953
Views:
9
I am thinking can you create an fll instead? Remove printf functions and try to create it as fll.

>My problem is that i think this code read data in hex and so convert it to dec.
>Is it right?
>BiosCom is notuser-defined function. i find it in C++ help. it is a function for work with com port.
>
>
>>I don't think I can convert the entire code, but here are a few tips.
>>
>>Lines that start with "//" are comments.
>>
>>gotoxy() goes to a specific screen position (the screen is assumed to be in text mode, 80 columns x 25 lines, or something similar); printf() will show a text.
>>
>>if (ch) should be translated in VFP as if ch # 0, since it seems to be numeric, and that is the way equality is interpreted in C. Similar for while.
>>
>>I suspect that bioscom() is a user-defined function, not a built-in C command.
>>
>>
>>>Dear all,
>>>I have a C source code for reading data from com port.
>>>I want to change it to VFP code.
>>>Can anyone help me?
>>>I dont want to enter number for choose type of instrument. my instrument is Baskool and port is COM1 and Buad is 2400
>>>
>>>i need only section between if( scale_type==1) // Bascool
>>> and else // Scale
>>>
>>>thanks for your help
>>>
>>>
>>>
>>>
>>>
>>>
>>>#define PP 0x320
>>>#define NO1 14
>>>#define NO2 350
>>>
>>>#include <stdio.h>
>>>#include <conio.h>
>>>#include <dos.h>
>>>#include <io.h>
>>>#include <stdlib.h>
>>>#include <bios.h>
>>>
>>>void main()
>>>{
>>>  FILE *fop;
>>>  int t;
>>>  int i,j,k,l,i1,j1,l1,k1,zero,j2,l2,k2,last;
>>>  unsigned char ch ,comno,scale_type,baud;
>>>
>>>  textbackground(BLUE);
>>>  window(1,1,80,25);
>>>  clrscr();
>>>  gotoxy(30,2);
>>>  printf("P A N D  Industries Co.");
>>>
>>>  gotoxy(20,5);
>>>  printf("Enter COM Port No.:< 1:com1  , 2:com2 >");
>>>   do
>>>   {
>>>   comno = getch()-'1';
>>>   } while((comno != 0)&&(comno != 1));
>>>  putch(comno+'1');
>>>
>>>  gotoxy(20,10);
>>>  printf("Enter Scale Type :< 1:Bascool  , 2:Scale >");
>>>   do
>>>   {
>>>   scale_type= getch()-'0';
>>>   } while((scale_type!= 1)&&(scale_type!= 2));
>>>  putch(scale_type+'0');
>>>
>>>  gotoxy(20,15);
>>>  printf("Enter Baud Rate :< 1:2400, 2:4800 bps >");
>>>   do
>>>   {
>>>   baud= getch()-'0';
>>>   } while((baud!= 1)&&(baud!= 2));
>>>  putch(baud+'0');
>>>//....................................................................
>>>  if( baud==2) bioscom(0,0xc3,comno);
>>>    else       bioscom(0,0xa3,comno);
>>>
>>>  clrscr();
>>>
>>>  gotoxy(30,5);
>>>  printf("P A N D  Industries Co.");
>>>  gotoxy(20,8);
>>>  printf("Test Program For Reading Weight From Serial Port");
>>>  gotoxy(20,10);
>>>  if( scale_type==1)  printf(" COM %d: %d bps   Bascool",comno+1,baud*2400);
>>>	  else        printf(" COM %d: %d bps   Scale",comno+1,baud*2400);
>>>
>>>  if( scale_type==1)      // Bascool
>>>	while(!kbhit())
>>>	{
>>>	 while ( ( bioscom(2,0,comno) & 0xff ) !=0xbb && !kbhit()) ;
>>>	 if(!kbhit())
>>>	 {
>>>	 gotoxy(20,15);
>>>	 ch = bioscom(2,0,comno) & 0xff ;
>>>	 if (ch==0xe0 || ch==0xf0 )
>>>	  ch = bioscom(2,0,comno) & 0xff ;
>>>	 if(ch)  printf("total weight = %x",ch);
>>>	 else  printf("total weight = ");
>>>	 ch = bioscom(2,0,comno) & 0xff ;
>>>	 printf("%x",ch>>4);
>>>	 printf(".");
>>>	 printf("%x",ch%16);
>>>	 ch = bioscom(2,0,comno) & 0xff ;
>>>//     ch=ch>>4;
>>>	 printf("%02x    ",ch );
>>>	 }
>>>	}
>>>	else                    // Scale
>>>  while(!kbhit())
>>>	{
>>>	 while ( (( bioscom(2,0,comno) & 0xff ) !=0xbb )&&!kbhit()) ;
>>>	 gotoxy(20,15);
>>>
>>>	 ch = bioscom(2,0,comno) & 0xff ;
>>>	 if (ch==0xe0 || ch==0xf0 )
>>>	  ch = bioscom(2,0,comno) & 0xff ;
>>>	 if(ch)  printf("total weight = %x",ch);
>>>	 else  printf("total weight = ");
>>>	 //printf("total weight = %x.",ch);
>>>	 ch = bioscom(2,0,comno) & 0xff ;
>>>	 printf("%x",ch>>4);
>>>	 printf(".");
>>>	 printf("%x",ch%16);
>>>	 //printf("%02x",ch );
>>>	 ch = bioscom(2,0,comno) & 0xff ;
>>>	 //ch=ch>>4;
>>>	 printf("%02x",ch );
>>>	 printf("  ");
>>>	}
>>>  textbackground(BLACK);
>>>  window(1,1,80,25);
>>>  clrscr();
>>>
>>>}
>>>
>>>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform