Goto Statement
Brian Element
The Goto statement instructs program execution to go to the specified location in the code.
A label itself has no effect on program operation—it serves only as the target of a Goto.
IDEAScript Language
Hi Robert,
Hi Robert,
You can't use Goto statements between functions, the have to be within the same function, that is why you are getting the error. To get this to work you need to add a bit more logic. I added a while loop to keep the first menu open unless the person hits cancel. I also added a boolean variable to indicate if the menu1 should be open and when the menu is closed I set it to false. Here is the code (I didn't change anything in the menus).
Option Explicit
Dim naam As String
Dim exitscript As Boolean
Dim bMenu1 As Boolean
Sub Main
'keep the menu open until the user selects cancel
Do While exitscript = False
Call menu()
'if the user has selected the menu then show menu1
If bMenu1 Then
Call menu1()
End If
Loop
End Sub
Function menu()
Dim dlg As Newdialog
Dim button As Integer
Dim exitdialog As Boolean
button = Dialog(dlg)
Select Case button
Case 1 'Pushbutton 1 open menu1
bMenu1 = True
Case 0 'Cancel Button
exitdialog = TRUE
exitscript = TRUE
Case -1 'Ok Button
exitdialog = TRUE
End Select
End Function
Function menu1()
Dim dlg As Newdialog1
Dim button As Integer
Dim exitdialog As Boolean
button = Dialog(dlg)
Select Case button
Case 1 'Button
'close menu1 and reopen the menu
bMenu1 = False
End Select
End Function
Goto Statement in IDEA 10
Hi, i'am trying the Goto statement to use the button in a dialog to go back to the previous dialog, but i get a Error: Label not defined. What do i wrong or is there a beter way to get back to previously dialogs?
Begin Dialog NewDialog 50,50,150,150,"NewDialog", .NewDialog
OKButton 13,111,40,13, "OK", .OKButton1
CancelButton 94,109,40,14, "Cancel", .CancelButton1
PushButton 16,7,40,14, "Button", .PushButton1
Text 17,29,40,14, "Text", .Text1
End Dialog
Begin Dialog NewDialog1 50,50,150,150,"NewDialog1", .NewDialog1
PushButton 53,106,40,13, "Button", .PushButton1
End Dialog
Option Explicit
Dim naam As String
Dim exitscript As Boolean
Sub Main
Call menu()
If exitscript = False Then
Call menu1()
End If
End Sub
Function menu()
Dim dlg As Newdialog
Dim button As Integer
Dim exitdialog As Boolean
A_1:
button = Dialog(dlg)
Select Case button
Case 0 'Cancel Button
exitdialog = TRUE
exitscript = TRUE
Case -1 'Ok Button
exitdialog = TRUE
End Select
End Function
Function menu1()
Dim dlg As Newdialog1
Dim button As Integer
Dim exitdialog As Boolean
button = Dialog(dlg)
Select Case button
Case 1 'Button
GoTo A_1
End Select
End Function