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
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.
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.
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 ??
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
ok if you cant bring it back is there a 64bit port of blitzmax ???
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.
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
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??
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
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.
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.
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.
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.
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 :
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
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.
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
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
Just replace labels with functions:
If KeyHit(KEY_1) Then drumplay()
...
function drumplay()
... code here
end function
yeah i tried that
can you call another place from that function ???
can you add a function in a function ??
Quote
yeah i tried that
can you call another place from that function ???
can you add a function in a function ??
You tried that and what? It didn't work?? It should.
Yes, you can call other functions from a function.
Why would you add a function to a function?? Just call several functions from a function if you want.
tried the code you sent
when calling a function do you address it as
program()
or just
program
for example
You would use program() because you pass in data through variables within the brackets. No data is required if you're just emulating a label therefore just use (). But if you wanted to send say, x and y values to a function you could use program( x, y ). Now BlitzMax needs to know what kind of data type it is, so when you define a function with integer (whole numbers) as an example you would say:
x = 10
y = 20
program( x, y )
...
Function program( x:Int, y:Int )
... process x and y here
End Function
' how is this , it works but is this the right way to do it :)
'new specdrum 2
Import BaH.RtMidi
Import BRL.StandardIO
Import brl.D3D9Max2D
Import brl.Max2D
Import BRL.Retro
Import BRL.Random
Import BRL.Math
Import BRL.LinkedList
Import MaxGui.Drivers
Const GFX_WIDTH = 1024, GFX_HEIGHT = 768, BIT_DEPTH = 0, HERTZ = 75
AppTitle ="SpecDrum2 64bit Version "
'Center the screen on startup
SetGraphicsDriver GLMax2DDriver()
Graphics GFX_WIDTH, GFX_HEIGHT, BIT_DEPTH, HERTZ
Function begin()
Local hiya
hiya=0
Repeat
Cls
DrawText"Press 1 or 2 or 3 to quit",20,40
If KeyHit(KEY_1) Then test1
If KeyHit(KEY_2) Then test2
If KeyHit(KEY_3) Then End
Flip
Until hiya=1
End Function
Function test1()
Cls
DrawText "you have reached test 1",60,60
Flip
Delay 1500
begin()
End Function
Function test2()
Cls
DrawText "you have reached test 2",60,60
Flip
Delay 1500
begin()
End Function
begin() ' this is the main call of the functions
Well it works is a good thing! :D
I would re-write it a bit differently, but it works is the main thing. Maybe somebody will jump in here as I don't have time right now.
ahhhhhh i see
so once its called and ended it will have to be called again if i want to go back to that part of code
right ?
There is a stack trace of sorts when using the debugger. As you step through a program, line by line, the function call stack will be in the "debug" tab on the right.