Thread: what could be wrong with this loop!?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    many thanks bro.
    i meant if one of them is wrong ! just exit!
    i should make those && ! yes?
    Last edited by Masterx; 01-31-2009 at 09:58 AM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    596
    Your indentation is confusing. Do you really intend that the second "if" is inside the first "if" block, and the "else" refers to the first "if"?

  3. #3
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    Quote Originally Posted by R.Stiltskin View Post
    Your indentation is confusing. Do you really intend that the second "if" is inside the first "if" block, and the "else" refers to the first "if"?
    well the second if is inside the first if , and the else refers to the second if !
    Code:
                   if ( temp != "not needed" )
                    {
                            argument = Atoi(offsetptr);
                            offsetptr = Oct2Bin( argument );
    
    
                            if ( (temp != "INX") && (temp != "LAX" ) && (temp != "LDX") && (temp != "DEX") && (temp != "CLX" ) )
                            {
                                    CommandsBinaryString = BinaryDetector( commandnameptr );
                                    CommandsBinaryString.append(mixstateptr);
                                    CommandsBinaryString.append(offsetptr);
    
                            }
    
    ///Error .Inx kar nemikonan.
    
                            else
                            {
                                    CommandsBinaryString = commandnameptr;
                            }
                    }
    by the way ! the first error i used to get is gone! by changing || to && . but it seems now the second else is not functioning ! how am i supposed to attach that if with this else !?
    Last edited by Masterx; 01-31-2009 at 08:42 PM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    596
    ... and if your revised code is what you intended, you can replace
    Code:
    else if ( (temp == "INX") || (temp == "LAX" ) || (temp == "LDX")|| (temp == "DEX") || (temp == "CLX" ) )
    {
    with
    Code:
    else
    {

  5. #5
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    Quote Originally Posted by laserlight View Post
    The problem is that in your original code the else is associated with the first if.
    tanx .
    Quote Originally Posted by R.Stiltskin View Post
    ... and if your revised code is what you intended, you can replace
    Code:
    else if ( (temp == "INX") || (temp == "LAX" ) || (temp == "LDX")|| (temp == "DEX") || (temp == "CLX" ) )
    {
    with
    Code:
    else
    {
    tanx , i did tha , is it supposed to connect the second if and the else ? !
    ( i did it . but im still getting none sense here . )
    snapshot.JPG
    ========================
    i have two kind of commands :
    1 plain commands
    2 commands stating a specific addressing mode.(complex commands)
    ========================
    i the following loop, i search for both commands, there is a difference the complex commands dont need the offset and M.I.X (which is an addressing mode indicator)
    ========================
    so , when the command is recognized! the BinaryDetector() function takes the command name , and analyzes it , and then retrieve the commands binary representation!. if it is aplain command , it would be merged with mix and offset.
    if not it should be either (INX, or DEX, or LDX, or LAX or ,CLX) . and its binary representaion should be retrieved!
    ========================

    well i just dont know why it doesnt do it right!
    ========================
    note : that first if is to eliminate declaration instrcutions, i mean because each time one string representing one instruction is taken under analysis , this is to avoid further error! because declaration are not executive commands, they just represents offsets! so the must not get into this session and accidantaly get into the memory!
    each declaration when recognized in tokenizer() ( a function before this) would contain "not needed" string as its command name and also its offset value!
    so by using this trick i can recognize it from other actual commands.
    thats the reson its up there !

    hope this intruductory helps you understand what i meant by doing such a thing

    thank you all for you time and answers.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loop the loop - feeling foolish
    By estos in forum C Programming
    Replies: 2
    Last Post: 04-07-2007, 02:45 AM
  2. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  3. I need help as soon as possible.
    By hyrule in forum C++ Programming
    Replies: 7
    Last Post: 11-09-2005, 05:49 PM
  4. What is wrong with my while loop?
    By aspand in forum C Programming
    Replies: 3
    Last Post: 06-19-2002, 12:07 PM
  5. Whats wrong w/ my loop?? Please help?
    By aspand in forum C Programming
    Replies: 6
    Last Post: 05-30-2002, 03:42 AM