English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 10 June 2018, 09:45   #121
E-Penguin
Banana

 
Join Date: Jul 2016
Location: Darmstadt
Posts: 563
Quote:
Originally Posted by Shatterhand View Post
Any ideas if its possible to implement something like this?
Yes, it is definitely possible. The question is how... In c I'd create an array of function pointers and call those.

Ultimately its just an array of memory addresses which you jump to.

I think this is what you want
Code:
On Expression Goto|Gosub Program Label[,Program Label...] 

On allows a program to branch, via either a Goto or a Gosub, to one of a number of
Program Labels depending upon the result of the specified Expression.

If the specified Expression results in a 1, then the first Program Label will be
branched to. A result of 2 will cause the second Program Label to be branched to and
so on. If the result of Expression is less than one, or not enough

Program Labels are supplied, program flow will continue without a branch.
E-Penguin is online now  
AdSense AdSense  
Old 10 June 2018, 17:39   #122
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,926
OH MY GOD.
I remember when I coded on MSX Basic there was this EXACT command and I had completely forgot about it.

Yes, found this on the manual. Somehow I believe that, performance-wise, this will be just like doing a select...case . I'll have to test speed of this to see if it's faster than doing a few ifs on a tree strcuture.

Thank you a lot!
Shatterhand is offline  
Old 11 June 2018, 00:27   #123
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,926
Ok, I've made a few tests.

Select..Case seems to be just a series of If..else one after the other. If the first "case" is the right one, it executes faster than the last "case" is the true one (or if there's no case at all).. it's actually a little faster than doing IFs for some reason, but not a lot faster to make a big difference unless you are doing a shitload of them (Still worth using it though - should use it more on my code)

In the other hand, On..Gosub is pretty fast most of the time. If the first subroutine is the selected one it will go a little faster, but then the speed doesnt change if its the second or the thirtieth one being executed. This is *great*


EDIT: Testing on REAL hardware (my 68000 A600 with 2Mb Chip Ram) gives me a lot more random results than on Winuae emulating a 040. Still, the same results more or less, On..Gosub always more or less at the same speed either the second or thirtieth option is the true one, while Select Case is a little faster when it's the first or second option, then it becomes progressively slower.

On..Gosub should be used instead of Select..Case when it's viable and you are dealing with more than 5 possibilities. When the right option was the 5th one or before that one, sometimes Select..Case is faster, sometimes On..Gosub is faster (like I said, it's weirdly too random), but from the 6th possibility onwards, On..Gosub is always faster.

So, when using Select Case, always try to have the more common possibility before the less common ones.

Last edited by Shatterhand; 11 June 2018 at 00:51.
Shatterhand is offline  
Old 11 June 2018, 00:53   #124
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,926
NEW QUESTION.

What's the MAX value of VPOS?
Shatterhand is offline  
Old 13 June 2018, 13:35   #125
Master484
Registered User
Master484's Avatar
 
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 322
Quote:
What's the MAX value of VPOS?
I quickly tested this and seems like the highest value is 311. And I think the values higher than 256 (or 255 since 0 counts as a value too) are always outside the normal display height of 256.
Master484 is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz basic 2 Help Havie Coders. Blitz Basic 30 08 September 2013 09:15
blitz basic petza request.Apps 11 08 April 2007 01:49
Blitz Basic 2 anyone? jobro request.Apps 12 28 November 2005 18:15
Blitz Basic StopCD32 Tony Landais Coders. General 2 08 May 2003 22:51
Blitz Basic 2 LaundroMat Retrogaming General Discussion 5 24 July 2001 08:10

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 19:49.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.06419 seconds with 16 queries