can we bring back The Goto and #label commands into NG

Started by wadmixfm, August 12, 2020, 11:30:32

Previous topic - Next topic

wadmixfm

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

wadmixfm

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.


wadmixfm

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.


wadmixfm

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 ??


wadmixfm

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


wadmixfm

ok if you cant bring it back is there a 64bit port of blitzmax ???


Steve Elliott

#6
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.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

wadmixfm

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

 

wadmixfm

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??


wadmixfm

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




TomToad

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) Select
Local a:Int[] = [1,3,5,7,9]

For Local valueToSearch:Int = 1 To 10
Local me:Int = -1

For Local i:Int = 0 Until a.length
If a[i] = valueToSearch
me = i
Exit
EndIf
Next

If me < 0
Print valueToSearch+" was not found"
Else
Print valueToSearch+" was found at index "+me
EndIf
Next


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

Code (blitzmax) Select
Local a:Int[] = [1,3,5,7,9]

For Local valueToSearch:Int = 1 To 10
Local me:Int = -1

#looplabel
Repeat
For Local i:Int = 0 Until a.length
If a[i] = valueToSearch
me = i
Exit looplabel
EndIf
Next
Print valueToSearch+" was not found"
Until True
If me >= 0
Print valueToSearch+" was found at index "+me
EndIf
Next


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) Select
Local a:Int[] = [1,3,5,7,9]

For Local valueToSearch:Int = 1 To 10
Local me:Int = getArrayIndex(a, valueToSearch)
If me < 0
Print valueToSearch+" was not found"
Else
Print valueToSearch+" was found at index "+me
EndIf
Next

Function getArrayIndex:Int(a:Int[], valueToSearch:Int)
For Local i:Int = 0 Until a.length
If a[i] = valueToSearch Then Return i
Next
Return -1
End Function

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.

Qube

Quote from: wadmixfm 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
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) Select

local me
for i = 1 to 1000
if i = 500
me = 500
me2( 500 )
endif
if i = 750
me = 750
me2( 750 )
endif
next

' loads more code here say another 1000 lines

' nothing below this line will run except when called

function me2( value )
if value = 500
' do funky stuff
endif
if value = 750
' do funky stuff followed by
me3()
endif
end function

function me3()
' do more funky stuff
end function
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

MikeHart

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.

Henri

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

wadmixfm

#14
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