How to make C++ give me a chance to inter a number while excuting?


 
Thread Tools Search this Thread
Top Forums Programming How to make C++ give me a chance to inter a number while excuting?
# 1  
Old 04-14-2013
How to make C++ give me a chance to inter a number while excuting?

Iam Trying to simulate a hardware "pci" by visual c++ program.....
" i don't have the hardware right now so i want to test my program"
the hardware is about to inter a number for example from switches compare it to other number also from switches.."which iam gonna take it from 1 textbox"...
1- inter first number
2- and then wait for strop on pin 3 of the switches " eg. sw3= 0...1...0 iam ready to read 2nd number"
3- inter the second number on the same text box....
4-then display the largest on leds which will be a message box for me

the problem is when I inter the first number i keep checking for the strop to be ready to inter next value but compiler keep checking and doesn't give me a chance to change the value of the textbox "not responding infinite loop"

this is the code
Code:
CString str1;
	CEdit *ptr1;
	double d; 
	
	
	unsigned long port = 0;
	unsigned char num1 = 0;
	unsigned char num2 = 0;
	unsigned char data = 0;
	unsigned char tempdata = 0;
	unsigned char check = 0;
	unsigned char begin_state;
	unsigned char l =0;

	ptr1= (CEdit*)GetDlgItem(DutyCycle);
	ptr1 -> GetWindowText(str1);
	d=atoi(str1);
	l = (unsigned char)d;

	tempdata = l & 15;
	check = tempdata/8;
	begin_state = check;
	int i=0;
	

	while (i<3)
	{
		ptr1= (CEdit*)GetDlgItem(DutyCycle);
		ptr1 -> GetWindowText(str1);
		d=atoi(str1);
		l = (unsigned char)d;

		tempdata = l & 15;
		check = tempdata / 8;

		unsigned char y2=0;
		unsigned char y3=0;

		y2 = l & 7;		
		y3 = l & 240;
   		y3 = y3 >> 1;
		num1 = y2 + y3;
		i++;
		CString S;
    	        S.Format("%d",num1);
		MessageBox("first number ="+ S);
		begin_state = check;

		while(check = begin_state)
		{	
			ptr1= (CEdit*)GetDlgItem(DutyCycle);
			ptr1 -> GetWindowText(str1);
			d=atoi(str1);
			l = (unsigned char)d;
			tempdata = l & 15;
			check = tempdata/8;
			if(check != begin_state)
			{break;}

		}

		CString S2;
    	        S2.Format("%d",check);
		MessageBox("bit3 ="+ S2);

		while(check != begin_state)
			{	
				ptr1= (CEdit*)GetDlgItem(DutyCycle);
				ptr1 -> GetWindowText(str1);
				d=atoi(str1);
				l = (unsigned char)d;
				tempdata = l & 15;
				check = tempdata/8;
				if(check == begin_state)
				{break;}

			}
			CString S3;
    		S3.Format("%d",check);
			MessageBox("bit3 ="+ S3);
		if(check == begin_state)
			 {
				y2 = l & 7;		
				y3 = l & 240;
   				y3 = y3>>1;
				num2 = y2 + y3;
				i++;

				CString S4;
    			S4.Format("%d",num2);
				MessageBox("second number ="+ S4);

				CString S5;
    				
				if(num1 >= num2)
					{
					 i++;

				   	 S5.Format("%d",num1);
					 MessageBox("the larger is ="+ S5);
					 

					}

				else
					{	
						i++;

						S5.Format("%d",num1);
						MessageBox("the larger is ="+ S5);
						
					}
				
				
			}
		
	}

how can I make the compiler to let me edit the text box while it's inside the while loop
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error in excuting while loop

can you please support me to understand what is wrong in this code, I am getting error as sytnax error near unexpected token if if then code is cat text.txt | /path/mapper.sh data in file is hi hi how how are you while read line do for word in $line do if then wcount=`echo... (4 Replies)
Discussion started by: mirwasim
4 Replies

2. UNIX for Dummies Questions & Answers

Crontab jobs excuting

Hi i want to run the cronjob from 7 Am till 11.30Am for every 5 minutes from monday to friday. can anyone help? (15 Replies)
Discussion started by: satheesh_charle
15 Replies

3. UNIX for Dummies Questions & Answers

Make all records with the same number of fields (awk)

Hi, input: AA|BB|CC DD|EE FF what I am trying to get: AA|BB|CC DD|EE| FF|| I tried to create first an UDF for printing repeats, but I think I have an issue with my END section or my array: function repeat(str, n, rep, i) { for(i=1 ;i<n;i++) rep=rep str return rep } ... (6 Replies)
Discussion started by: beca123456
6 Replies

4. Shell Programming and Scripting

Bash script to give multiple choices and a varying number of answers

Hello everybody, I use `case' quite a lot but , excellent as it is , it only gives one final result ; can anyone suggest a way whereas , say long lists of choices are given and I , or a user could select either one two or any number of results to be echoed . many thanks in... (3 Replies)
Discussion started by: V686
3 Replies

5. Shell Programming and Scripting

Script to Serach pattern and give number of occurrences

Hi, I want a script which search for a pattern "good" in a huge file and provide me number of occurences of such pattern in a file. lets say i have a file test.txt contents as below good is good but good is sometime bad and sometime good you are very good and good is always good ... (7 Replies)
Discussion started by: sv0081493
7 Replies

6. Solaris

Can v240 disks be moved to v440 and have a chance of working?

We have a v240 running Solaris 10, and an application that I don't want to go through the pain of reinstalling on a new system right now. Can I just move those disks to a v440 for an easy upgrade? At first I thought the idea was laughable, but then I started thinking that they are both Ultra... (9 Replies)
Discussion started by: lyle
9 Replies

7. Shell Programming and Scripting

Make new files based on the number extracted

Hi All, I have a big file which looks like this: 0 4.5 6.7 0 3.4 6 1 5 6 1 6 4 2 9 4.44 Above is just a miniature version of the file. In fact, considering the first column of the file that is 0 0 1 1 2, the numbers in actual go until 10442. This means my actual file looks like... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

8. Shell Programming and Scripting

excuting the following code

hi i am trying the below code for the following |_ | |_ | |_ |_ | |_ |_ |_ | |_ |_ |_ |_ and for this code also * * * * * * * * * * * * * * * !/bin/bash #i = "*" (2 Replies)
Discussion started by: kullu
2 Replies

9. Shell Programming and Scripting

Bash : how do i check the user input and make sure is only chracter or only number ?

Bash : how do i check the user input and make sure is only character or only number ? (7 Replies)
Discussion started by: CheeSen
7 Replies

10. Shell Programming and Scripting

How to make a number in a text file a variable?

OK this one sounds like it should be a natural... it must be possible to send a number say 200 to a text file and later use it as a variable? yada yada > file.txt how would I retrieve that number to use as a variable? Is this possible? (5 Replies)
Discussion started by: nortypig
5 Replies
Login or Register to Ask a Question