realbasic-nug
[Top] [All Lists]

Elseif problem?

To: REALbasic Network Users Group <realbasic-nug@lists.realsoftware.com>
Subject: Elseif problem?
From: Markus Winter <markus_winter@online.de>
Date: Tue, 30 Jun 2009 22:33:49 +0200
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
Thread-index: Acn5whK7UTww7GW1Ed6yKwAX8sP4eQ==
Thread-topic: Elseif problem?
User-agent: Microsoft-Entourage/11.4.0.080122
Hi,

I have the following code which jumps over the elseif statement straight
into the second loop but does not execute it - with CB_Numeric checked,
StartValue = 10, EndValue = 5, and StepValue = -1 :


  // initialize
  
  EditField1.text = ""
  dim i as Double = 0
  
  dim StartValue as Double = Val(EF_Start.text)
  dim EndValue as Double = Val(EF_End.text)
  dim StepValue as Double = Val(EF_Step.text)
  
  if  EF_Step.text = "" or StepValue = 0 then
    StepValue = 1
    EF_Step.text = "1"
  else
    StepValue = Val(EF_Step.text)
  end if
  
  
  if CB_Numeric.value then // if numeric
    
    
    if  StartValue <= EndValue  And  StepValue >0 then  // count up
      
      for i = StartValue to EndValue step StepValue
        EditField1.AppendText Str(i) + EndOfLine
      next
      
      
    elseif  StartValue >= EndValue  And  StepValue <0  then  // count down
      
      for i = StartValue DownTo EndValue step StepValue
        EditField1.AppendText Str(i) + EndOfLine
      next
      
    else
      MsgBox "The numeric values would result in an endless loop - please
correct them"
      exit
    end if
    
    
  else  // not numeric then use the EF_Cases
    
    MsgBox "not numeric"
    
  end if
  
  

I can follow in the debugger that code execution is

  if CB_Numeric.value then // if numeric

    if  StartValue <= EndValue  And  StepValue >0 then
  // jumps over the elseif statement
      for i = StartValue DownTo EndValue step StepValue

but does not execute the second loop, it just continues after the last end
if


I made a small demo at
http://ahatfullofsky.comuv.com/files/bugs/Elseif_bug.rbp.zip


Anyone can tell me where I muck this up?

Markus

Tried R2007R3 and RB2009R2





_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>