[Gambas-user] On Goto/GoSub allow multiple line

Brian G brian at westwoodsvcs.com
Fri Feb 26 18:09:19 CET 2021


I am using the on x goto sub1 , ... 
As the implementation of a string value check function 

on goto uses the index to know what label to go to 

This method is about 30% faster than case or string[].find checks 

For example run this gambas script : 

#!/usr/bin/gbs3 

Dim a as collection = ["a":0,"b":1,"c":2] 

a.default = 3 

for each s as string in ["a","b","c","d","e"] 

on a[s] goto LA,LB,LC,LFail 

LA: 

print "a" 

continue 

LB: 

print "b" 

continue 

LC: 

Print "C" 

continue 

LFail: 

Print "Unknown Caracter" 

break 

next 

"Failure is the key to success; 
each mistake teaches us something" .. Morihei Ueshiba 
Brian G 

----- On Feb 26, 2021, at 8:53 AM, Brian <brian at westwoodsvcs.com> wrote: 

> I am using the on x goto sub1 , ...
> As the implementation of a string value check function

> Dim a as collection

> --
> Thanks
> Brian
> Friday, 26 February 2021, 01:03AM -08:00 from KKing [
> mailto:kicking177 at gmail.com | kicking177 at gmail.com ] :

>> > on x goto or on x gosub to have multiple line entries

>> > on x goto lable1, label2, label3, label4
>> could you explain the usage for gosub I could imagine you are saying for
>> certain condition do all these sub routines?
>> But from traditional sense don't see the relevance of multi destinations
>> for an on goto.

>> ----[ [ http://gambaswiki.org/wiki/doc/netiquette |
>> http://gambaswiki.org/wiki/doc/netiquette ] ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210226/ce750d6c/attachment-0001.htm>


More information about the User mailing list