Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select Case
#1
Hi guys

I noticed in CodeView that the program steps through every case untill it gets to the case number targetted.
When it has executed the code in that case, it jumps straight to End Select.

Some of my code has lots of routines, each with Select Case 1 of 20 or more. A bit like a PLC program that has to do things in a particular order.
As these routines get called in an endless loop, a lot of time appears to be wasted in this "case stepping".

Has anybody any suggestions on eliminating or reducing time lost.
t is the End result that matters, not the Tools used to get there.
Reply
#2
With such a general description, I think that the only suggestion that I can give is: if there is a preference, or more frequent use of some of the cases, put those first.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#3
Ralph

Not really an option.
Each time I complete a task, the "Case Nr" is incremented.
The next time it comes to this Routine , Select Case selects the next step in the sequence.

Regards
t is the End result that matters, not the Tools used to get there.
Reply
#4
If your program knows the next case number, then, instead of a CASE, I woud use a LABEL, say the case number, and just use a GOTO. That would seem to be the only logical approach to your problem.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#5
Oh the KISS principle .

Not so simple.
How do you save and call/goto the new label.

I think this has been on the wish list for a long time.
Being able to call or jump to a routine using either a string or a number.

I am toiling with the idea, that if I use the .map file to identify a label or routine,
then I can write an asm routine that jumps to that address.

But I suspect I an only do this within a subroutine, thereby leaving basic's calling stack intact.

Like make a asm function called JUMP
then
JUMP Label19
t is the End result that matters, not the Tools used to get there.
Reply
#6
select case will give you the most efficiency (if i understand your problem correctly), the only better thing i could suggest is function pointers, which aren't in QB, only FB ;p


edit: functional examples (no pun)




Ye Olde QB way:
Code:
Do

  For p = 0 To 3
  
    ? p;
  
    Select Case p
  
      Case 0
        ? " th"
  
      Case 1
        ? " st"
  
      Case 2
        ? " nd"
  
      Case 3
        ? " rd"
        
    End Select

    If Inkey$ = Chr( 27 ) Then Exit Do
  
  Next

Loop




and heres the fb special:


Code:
Sub my_Case0()
  ? " th"
  
End Sub  

Sub my_Case1()
  ? " st"
  
End Sub  
  
Sub my_Case2()
  ? " nd"
  
End Sub  
  
Sub my_Case3()
  ? " rd"
  
End Sub  


Dim my_Case( 3 ) As Sub

my_Case( 0 ) = ProcPtr( my_Case0 )
my_Case( 1 ) = ProcPtr( my_Case1 )
my_Case( 2 ) = ProcPtr( my_Case2 )
my_Case( 3 ) = ProcPtr( my_Case3 )


Do

  For p = 0 To 3
  
    ? p;
    
    my_Case( p ) ()
  
    If Inkey$ = Chr( 27 ) Then Exit Do
  
  Next

Loop



need help with any fb function crap, jjust ask.
Reply
#7
Unfortunately the extensive testing I have done with FB in Dos
has proven that FB is not faster then pds7.1 in my experience.

Sofar I have managed to create the JUMPTO asm routine, but
need to work out how to save the labels for the asm call.\

JUMPTO Label1


Will keep you posted.
t is the End result that matters, not the Tools used to get there.
Reply
#8
No offence, but FB is still in development, and as far as I can tell, it's far bigger than PDS.

However, the problem with save and GOTO can be solved using GOSUB / RETURN ...
Screwing with your reality since 1998.
Reply
#9
Quote:Unfortunately the extensive testing I have done with FB in Dos
has proven that FB is not faster then pds7.1 in my experience.


I'd love to have some benchmarks that I could test in DOS on my box. I bet fb would walk all over PDS, using that func ptr example vs select case in PDS
Reply
#10
Quote:using that func ptr example vs select case in PDS

Absolutely with that function.
But I have already worn out my welcome on that subject, so
I wont go there.
t is the End result that matters, not the Tools used to get there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)