'Conditional Branching - 'GoTo' Kluge ?

 
Trying to figure out a 'kluge' / 'work around' for Conditional Branching/GoTo in MQL4
 
Don't need to kluge. Just code it properly and the problem usually resolves itself. Post the problem and your code.
int nu=0; switch (nu){
   default:
   :
   if (condition) break;
   :
}
for(int nu=0; nu <= 0; nu++){
   :
   if (condition) break;
   :
}
if (nu == 0) Print("break was taken");
 

I think that we are referring to different things here. I'm wanting to be able to jump to ANY place within the program as opposed to just skipping over somethings that doesn't meet the conditions and just goes onto the next sequential statements functions etc.

Most modern day 'structured' programming languages don't allow for the use of GoTo commands as they can be real nightmares. The 'structured' designation in fact refers to the fact that they do not allow the usage of GoTo statements. However IF used with discretion, their are times that they can be very useful. However the problems that can arise from their usage is substantial enough that they need to be used with the caveat of: 'Use at ones own risk!'

Another possibility is to have different external sub-routines, modules, variables, functions etc that one can 'call' when needed. Either within the main program? or in separate ones. Generally these carry out their specific function and then return the resulting data back to the main program to utilize. These are found in some modern structured programming languages and aren't as fraught with danger as using 'GoTo' commands. Perhaps the usage of Include, Library or even .dll files are suitable for this? I haven't found out as of yet how to pass variables, data, functions etc from these other files back into the main program. Nor if in fact I can utilize them in this manner? Maybe in some instances I can achieve this with the usage of Global variables in the EA.

 
Thanks OneWithZachy
 
FourX:
Thanks OneWithZachy

Really ???,

I read your thread back then, saw your rating, have no idea what kluge is, so no reply :)

To pass to function you can pass it's value or pass as parameters, to pass to dll, you may want to see this video from Patrick S Nouvion

Learn more ?

write back if you have more Qs :)

 

I agree if you program in functions you wont need GoTo

 
onewithzachy:

Really ???,

I read your thread back then, saw your rating, have no idea what kluge is, so no reply :)

To pass to function you can pass it's value or pass as parameters, to pass to dll, you may want to see this video from Patrick S Nouvion

Learn more ?

write back if you have more Qs :)

I haven't delved to far into the 'Call' function as of yet. Though for the most part, I'm hoping to figure out how to 'Jump' (!not 'FTL' though (< 8) and 'GoTo' specific places in the EA programs other than sequentially. From what you have said, I don't know if it will work for what I want to do. But most definitely good to learn and know about. All in due time and as I need it.

A 'Kluge' is something that is 'cobbled together' from a variety of things to achieve something that is normally not done. In this case i'm trying to cobble together a 'GoTo' function/command in MQL4 that does not have this as a standard feature, capacity and part of MQL4. As stated there are good reasons why not to have them. This used to be standard part of many programming languages, but as they can very easily cause a LOT of problems, that they took them out of (almost?) all programming languages as far as I know. I don't think C has one does it? They took it out of COBOL and I don't think that their is one in FORTRAN, nor in Visual BASIC ?

Case in point: Decades ago I wrote a small, 5 or 6 line BASIC program (segment) with multiple, nested and conditional branching 'GoTo' commands in it. Even with the 'Tracer' on, I couldn't figure out what it was doing! )< 8) FYI: The command for 'Tracer On' was 'TRON.' Recognize the acronym? This was the name of the first digital animation movie that was VERY lame, made by Walt Disney Studios, that didn't really have much of a story line. Just some supposedly hyper/light speed motorcycles racing around inside a (microscopic?) (light?) maze/matrix. I think they did a remake of it. But as the first one was so bad, I din't see it. GI is still GO = GIGO

 
SDC:

I agree if you program in functions you wont need GoTo

Hi SDC,

As with most programming, MQL4 is virtually all 'Functions' that other than jumping over some lines, doesn't have a true 'GoTo' function that I am trying to figure out how to do within a MQL4 EA So I'm not sure what you are 'agreeing with' and what you mean and are referring to in the context of this search? Please expand and explain. Not being argumentative. It sounds like you have something in mind and I'd like to know what it is and how it might be beneficial to us.

 
I used GOTOs back in the BBC Basic days . . . I even used BBC BASIC in my full time job for approx 7 years . . . even BBC Basic had GOSUB and RETURN so that subroutines (functions) could be used . . . why would you ever want to use anything that resembles a GOTo in MQL4 ? perhaps you can explain your need ?
Reason: