September 18, 2021, 18:49:22

Author Topic: can we bring back The Goto and #label commands into NG  (Read 2591 times)

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
can we bring back The Goto and #label commands into NG
« on: August 12, 2020, 11:30:32 »
would it be possible for us novices to have the old commands back ????

goto and the #label commands were great and simple

now you have to write upto 20 more lines of code to get it to do a simple jump to a line.

in machine language they use the Jmp command and no one complains

isnt it down to the end user if we would like these features or not

could you add a switch in the ide to turn it on or off for example

Lee

 :D :D :D :D :D :D

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #1 on: August 12, 2020, 12:03:06 »
no i understand it perfectly , but i cant see why two little commands have been taken away
which are not damaging the size of blitzmax source ,i have been working on a few old programs from the vanilla days of blitzmax and its a lot of code to be going through converting the goto's and the labels.

its down to the user if they want to use them or not right ???

so why not leave them in ??

so people that still want to use them can do

you dont go into a shop and buy a pencil and the shop keeper says you cant use that to draw with.


Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #2 on: August 12, 2020, 12:05:12 »
all i want to do is convert my programs to run in 64 bit and doing this i need to use NG i like the look of NG but taking things away is not the way forward for me anyways.


Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #3 on: August 12, 2020, 12:21:03 »
why dont they write a mod for it for user to have if they want it??

another scenario

i have just bought a new car and it had overdrive  , but my car went in for a service and you removed it , but i still want to use it , why did you take it away ???

i paid 80$ for blitzmax and i am not getting the service i paid for
if i want these feature dont i have a right to have them ??

 

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #4 on: August 12, 2020, 12:30:36 »
and explain to me why the goto command is still in the commands list and it still shows the example oh how to use it

i feel the option has been disabled in the compiler (bcc)

just recently learned about this file in the source code
there is a restriction in the compiler code to stop goto correct ??

   stm.cpp
   Removed restriction which didn't allow Goto in strict mode


Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #5 on: August 12, 2020, 12:32:01 »
ok if you cant bring it back is there a 64bit port of blitzmax ???


Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 3225
  • elgol
Re: can we bring back The Goto and #label commands into NG
« Reply #6 on: August 12, 2020, 12:45:42 »
First of all Blitzmax was abandoned by the author and left open source.  So complaining you're not getting the service you paid for is well, tough.  Mr Mark Sibly walked away from BlitzMax so it no longer exists.  Brucey worked hard to bring a new 64-bit version called BlizMax NG or it would have died completely.

Using the Goto command and jumping about all over the place is bad programming practice in a structured or object oriented language, so I can understand why Brucey removed it.  Mark made the mistake of allowing all sorts programming styles to mix, and with all that strict, super strict nonsense too.  So people like yourself can quite rightly feel annoyed because the original author allowed everybody to do whatever they want, rather than being sensible and putting in a standard syntax for everybody to follow.
« Last Edit: August 12, 2020, 12:51:19 by Steve Elliott »
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry pi 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #7 on: August 12, 2020, 13:05:00 »
so again for us novices that dont do this kind of thing day in day out

whats the alternative to goto and labels

my old programs work fine in 32 bit mode no lag or slow down no memory leaks and i can also when it came too debugging errors could always find where i had gone wrong,but i want to update it into the 64 bit market and to migrate onto other platforms like mac os catalina which i know is 64bit also.

typical scenario -

local me
for i = 1 to 1000
if i = 500 then me = 500 then goto me2
next

...... loads more code here say another 1000 lines

#me2
end

i know about functions but you are tied to them as its

function me()
..... do something

end function

then call it

but i have a lot of loops and jump arounds to do

 

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #8 on: August 12, 2020, 14:25:37 »
very positive gfk

all i want to know is can i compile my code in 64bit with ease

seems i have to take 20 turns just to execute a simple 2 step operation

i dont want to be rewriting all my code again and yet i want to upgrade to NG and 64bit

is there any solutions apart from the obvious??


Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #9 on: August 12, 2020, 16:02:37 »
the program i have written in blitzmax works fine

with no errors in 8551 lines of code and no one can help me with a goto alternative

thanks



 

Offline TomToad

  • Hero Member
  • *****
  • Posts: 554
Re: can we bring back The Goto and #label commands into NG
« Reply #10 on: August 12, 2020, 16:14:56 »
I am assuming your scenario is a standin for a more complex function, like searching through an array.

One way to do it would be to set me to a default value representing "value not found" and then testing for that value after exiting the loop.  In my example here, I default to -1.
Code: BlitzMax
  1. Local a:Int[] = [1,3,5,7,9]
  2.  
  3. For Local valueToSearch:Int = 1 To 10
  4.         Local me:Int = -1
  5.  
  6.         For Local i:Int = 0 Until a.length
  7.                 If a[i] = valueToSearch
  8.                         me = i
  9.                         Exit
  10.                 EndIf
  11.         Next
  12.  
  13.         If me < 0
  14.                 Print valueToSearch+" was not found"
  15.         Else
  16.                 Print valueToSearch+" was found at index "+me
  17.         EndIf
  18. Next
  19.  

Another way would be to use loop labels with exit and wrap your function in a Repeat/Until block.

Code: BlitzMax
  1. Local a:Int[] = [1,3,5,7,9]
  2.  
  3. For Local valueToSearch:Int = 1 To 10
  4.         Local me:Int = -1
  5.  
  6. #looplabel
  7.         Repeat
  8.                 For Local i:Int = 0 Until a.length
  9.                         If a[i] = valueToSearch
  10.                                 me = i
  11.                                 Exit looplabel
  12.                         EndIf
  13.                 Next
  14.                 Print valueToSearch+" was not found"
  15.         Until True
  16.         If me >= 0
  17.                 Print valueToSearch+" was found at index "+me
  18.         EndIf
  19. Next
  20.  

Of the two, I prefer the first version as it is more clear as to what you are trying to do.

Better than either would be to put the routine in its own function.
Code: BlitzMax
  1. Local a:Int[] = [1,3,5,7,9]
  2.  
  3. For Local valueToSearch:Int = 1 To 10
  4.         Local me:Int = getArrayIndex(a, valueToSearch)
  5.         If me < 0
  6.                 Print valueToSearch+" was not found"
  7.         Else
  8.                 Print valueToSearch+" was found at index "+me
  9.         EndIf
  10. Next
  11.  
  12. Function getArrayIndex:Int(a:Int[], valueToSearch:Int)
  13.         For Local i:Int = 0 Until a.length
  14.                 If a[i] = valueToSearch Then Return i
  15.         Next
  16.         Return -1
  17. End Function
  18.  
This way, the routine can be used multiple times throughout your program, with different arrays and different values, without having to rewrite the same routine over again.
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2766
  • I mostly code at night... Mostly.
    • SyntaxBomb - Indie Coders
Re: can we bring back The Goto and #label commands into NG
« Reply #11 on: August 12, 2020, 16:27:45 »
the program i have written in blitzmax works fine

with no errors in 8551 lines of code and no one can help me with a goto alternative

thanks
You will have to ditch goto and instead think of functions as your goto label.

I do not know what me = 500 is about ( or your code, lol ) but...

So something on the lines of :

Code: BlitzMax
  1. local me
  2. for i = 1 to 1000
  3.         if i = 500
  4.                 me = 500
  5.                 me2( 500 )
  6.         endif
  7.         if i = 750
  8.                 me = 750
  9.                 me2( 750 )
  10.         endif
  11. next
  12.  
  13. ' loads more code here say another 1000 lines
  14.  
  15. ' nothing below this line will run except when called
  16.  
  17. function me2( value )
  18.         if value = 500
  19.                 ' do funky stuff
  20.         endif
  21.         if value = 750
  22.                 ' do funky stuff followed by
  23.                 me3()
  24.         endif
  25. end function
  26.  
  27. function me3()
  28.         ' do more funky stuff
  29. end function
  30.  
Mac mini ( 2018 / 2020 ), 3 GHz 6-Core Intel Core i5, 16 GB 2667 MHz DDR4, 1TB NVMe, eGPU Radeon Pro 580 8 GB, LG Ultragear 27GL83A-B 27 Inch
Mac mini (2020 ), M1 SoC, 8 GB LPDDR4, 512GB NVMe 
Commodore VIC-20, 1.1Mhz MOS 6502 CPU, 5KB RAM, VIC ( 6560 ) GPU

Until the next time.

Offline MikeHart

  • Hero Member
  • *****
  • Posts: 804
Re: can we bring back The Goto and #label commands into NG
« Reply #12 on: August 12, 2020, 18:59:23 »
If i understood Blitzmax and NG correctly, the original created assembler where you could support Goto essily as a compiler. NG on the other hand translates to C++ which gets compiled by a Compiler. and there Goto and Gosub doesn't exist.

Offline Henri

  • Sr. Member
  • ****
  • Posts: 353
Re: can we bring back The Goto and #label commands into NG
« Reply #13 on: August 12, 2020, 21:53:16 »
NG produces C code and goto is possible in C as far as I know (although all the people using it in higher level languages are looked down upon :-)).

Another matter is that goto is a legacy feature of basic to begin with and was only supported in non-strict mode or the 'hippie mode' in the original Blitzmax and ng is strict by default. I would give it a snowballs chance to ever surface in ng...

The good news is that it is not really needed. Every possible scenario can be done without it. And, I bet you don't even have to write 10 times more code to achieve the same. At the end you might even develop a different way of structuring your code, evolve as a programmer. At least I did..
 
 Anyways, good luck.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Offline wadmixfm

  • Full Member
  • ***
  • Posts: 137
Re: can we bring back The Goto and #label commands into NG
« Reply #14 on: August 13, 2020, 12:33:37 »
thanks for the great replies

so here is what i am looking for

for example :-

repeat

If KeyHit(KEY_1) Then goto drumplay
If KeyHit(KEY_2) Then goto kited
If KeyHit(KEY_3) Then goto loadnsave
If KeyHit(KEY_4) Then goto quit

until


#drumplay

..... code here


#kited

........ code here


#loadnsave

........ code here



#quit

end program code here

if there is an alternative to this then i will be very happy

lee

sorry to cause issues


ps the me was a variable

if i = 500 then me = 500

lee

its not part of my original code i just threw that in




« Last Edit: August 13, 2020, 12:44:50 by wadmixfm »

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal