Thread: flag not saved

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    37

    flag not saved

    Hi everyone,

    I have a bit of a situation here. From the code below, its just a function for obtaining key codes from 1-6 and left and right. the left and right keys are detached from the system but it serves as a 1-6 button function. the right button to increase from 1-6 and the left button is to decrease from 6-1.

    the problem i am facing right now is that i cant seem to get the same value that the keys 1-6 are holding when i press the left/right keys.

    example:
    1. i pressed button number 5. so i am currently on channel 5.
    2. i press the right key. by right it should display channel 6 and if i press the right key again, it should be displaying channel 1 (in a loop)
    3. what i get is, after pressing button number 5, and then pressing the right key, it displayed channel 1 instead of channel 6.
    4. this shows that i may not be saving the value from the 1-6 keys.

    Is there any opinions on how I should deal this with?

    thanks


    Code:
    switch (ky_getKyCode())	{
    		case K_1:
    			d_kyRaCmd = L_PCH1_KEY;				/*  Channel 1		*/
    			break;
    		case K_2:
    			d_kyRaCmd = L_PCH2_KEY;				/*  Channel 2		*/
    			break;
    		case K_3:
    			d_kyRaCmd = L_PCH3_KEY;				/*  Channel 3		*/
    			break;
    		case K_4:
    			d_kyRaCmd = L_PCH4_KEY;				/*  Channel 4		*/
    			break;
    		case K_5:
    			d_kyRaCmd = L_PCH5_KEY;				/*  Channel 5		*/
    			break;
    		case K_6:
    			d_kyRaCmd = L_PCH6_KEY;				/*  Channel 6		*/
    		break;
    		case K_RIGHT_R:		/* right key for remote*/
    		{
    			if((key_counter != 0) && (key_counter < 6))
    			{
    				pchno = key_counter;		/*	Store working Channel number	*/
    				pchno++;
    			}
    			else
    			{
    				key_counter = 1;
    				pchno = d_wpch;		/*	Store working Channel number	*/
    			}
    	
    		}
    		break;
    		case K_LEFT_R:		/*left key for remote*/
    		{
    			if(key_counter > 0)
    			{
    				pchno = key_counter;		/*	Store working Channel number	*/
    				pchno--;
    			}
    			else
    			{
    				key_counter = 6;
    				pchno = key_counter;		/*	Store working Channel number	*/
    				
    			}
    		
    		}
    		break;
    	}
    			
    	     if (key_counter == 1)d_kyRaCmd = L_PCH1_KEY;
    	else if (key_counter == 2)d_kyRaCmd = L_PCH2_KEY;
    	else if (key_counter == 3)d_kyRaCmd = L_PCH3_KEY;
    	else if (key_counter == 4)d_kyRaCmd = L_PCH4_KEY;
    	else if (key_counter == 5)d_kyRaCmd = L_PCH5_KEY;
    	else if (key_counter == 6)d_kyRaCmd = L_PCH6_KEY;
    
    
    	if(key_counter >6)
    	{
    		key_counter = 1;
    	}
    	else
    	{
    		key_counter = pchno;				/*	Store working Channel number	*/

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    I'm not shure what you try exactly but
    Code:
    switch (ky_getKyCode()) {
            case K_1:
               key_counter = 1;              /*  Channel 1      */
               break;
            case K_2:
                key_counter = 2;            /*  Channel 2       */
                break;
       .....
    should do
    the if key_counter == ... statements should take care to set d_kyRaCmd to the right value

    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Value not being saved inside function
    By Pztar in forum C Programming
    Replies: 5
    Last Post: 06-13-2011, 05:27 PM
  2. Scoreboard saved in .txt file?
    By Newklear in forum C Programming
    Replies: 14
    Last Post: 03-21-2011, 08:06 PM
  3. Location of Saved File
    By loopshot in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2006, 11:26 PM
  4. reading saved file
    By firefly in forum C++ Programming
    Replies: 1
    Last Post: 07-09-2005, 01:24 AM
  5. Points saved
    By wayko in forum C++ Programming
    Replies: 1
    Last Post: 09-21-2001, 09:42 PM