A Almog Active Member Licensed User Sep 18, 2018 #1 Hello, Is there a way in code to skip to specific line by goto? For example: Code: Copy If Succes Then Msgbox("","") Else goto gg End If File.WriteString(File.DirInternal,"1.txt","") gg: Msgbox("End","") (what will happen is that if Succes = false then it will directly go to line gg and Msgbox without creating the file "1.txt".) Thanks in advance.
Hello, Is there a way in code to skip to specific line by goto? For example: Code: Copy If Succes Then Msgbox("","") Else goto gg End If File.WriteString(File.DirInternal,"1.txt","") gg: Msgbox("End","") (what will happen is that if Succes = false then it will directly go to line gg and Msgbox without creating the file "1.txt".) Thanks in advance.
Jmu5667 Well-Known Member Licensed User Longtime User Sep 18, 2018 #2 There are no goto statements, use the true/false conditions to control what you do. Code: Copy ' // true If Succes Then Msgbox("","") File.WriteString(File.DirInternal,"1.txt","") ' // false condition Else ' do something End If Upvote 0
There are no goto statements, use the true/false conditions to control what you do. Code: Copy ' // true If Succes Then Msgbox("","") File.WriteString(File.DirInternal,"1.txt","") ' // false condition Else ' do something End If
A Almog Active Member Licensed User Sep 18, 2018 #3 Jmu5667 said: There are no goto statements Click to expand... Thanks Upvote 0
Yayou49 Active Member Licensed User Sep 18, 2018 #4 Or you can use a new sub: Code: Copy ' // true If Succes Then aa ' // false condition Else bb End If Sub aa Msgbox("","") File.WriteString(File.DirInternal,"1.txt","") end sub Sub bb ' do something else End sub Upvote 0
Or you can use a new sub: Code: Copy ' // true If Succes Then aa ' // false condition Else bb End If Sub aa Msgbox("","") File.WriteString(File.DirInternal,"1.txt","") end sub Sub bb ' do something else End sub
A Almog Active Member Licensed User Sep 18, 2018 #5 Yayou49 said: Or you can use a new sub: Code: Copy ' // true If Succes Then aa ' // false condition Else bb End If Sub aa Msgbox("","") File.WriteString(File.DirInternal,"1.txt","") end sub Sub bb ' do something else End sub Click to expand... Thanks Upvote 0
Yayou49 said: Or you can use a new sub: Code: Copy ' // true If Succes Then aa ' // false condition Else bb End If Sub aa Msgbox("","") File.WriteString(File.DirInternal,"1.txt","") end sub Sub bb ' do something else End sub Click to expand... Thanks
M mixdes New Member May 9, 2020 #6 sorry to jump into the issue even though i am just starting my learn in B4A, however, i have been working with Basic Language since around 40 years, and Goto Statement is very essential to control the flow of your application, and your reply regarding the use of IF statements is not a full solution. it can solve the issue if you have limited number of statements in your code, but if you have large related code that is dependent on specific conditions and you have to divert the flow of code to some other location based on that specific conditions then it will be very hard to repeat the IF statements where ever you need to take action based on that value. so i highly recommend to consider this in the compiler. Upvote 0
sorry to jump into the issue even though i am just starting my learn in B4A, however, i have been working with Basic Language since around 40 years, and Goto Statement is very essential to control the flow of your application, and your reply regarding the use of IF statements is not a full solution. it can solve the issue if you have limited number of statements in your code, but if you have large related code that is dependent on specific conditions and you have to divert the flow of code to some other location based on that specific conditions then it will be very hard to repeat the IF statements where ever you need to take action based on that value. so i highly recommend to consider this in the compiler.