I am trying to write a program to display names of subway stations to stop at or skip when I run my model train. At some stations, I press one of the command buttons to choose subway routes but the program is not working properly. Here is the code:
#compile exe
#register none
#dim all
#include "win32api.inc"
global hdlg as long
global buttonpressed as long
global stationnumber as long
global string01 as string
global string02 as string
global string03 as string
global string04 as string
global string05 as string
global string06 as string
global string07 as string
global string08 as string
global terminal as long
callback function nextstation
buttonpressed=1
incr stationnumber
call selectstation
end function
callback function route01
buttonpressed=2
call cleartextboxes
call command01
end function
callback function route02
buttonpressed=3
call cleartextboxes
call command01
end function
callback function route03
buttonpressed=4
call cleartextboxes
call command01
end function
callback function route04
buttonpressed=5
call cleartextboxes
call command01
end function
callback function route05
buttonpressed=6
call cleartextboxes
call command01
end function
callback function route06
buttonpressed=6
call cleartextboxes
call command01
end function
callback function newroute
msgbox "New route"
end function
callback function expressstops
msgbox "Express stops"
end function
callback function localstops
msgbox "Local stops"
end function
callback function exitprogram
dialog end hdlg,1
end function
sub selectstation
select case stationnumber
Case 1
call textbox01("Stop at Beach 67th Street")
Case 2
call textbox01("Stop at Beach 60th Street")
Case 3
call textbox01("Stop at Beach 44th Street")
Case 4
call textbox01("Stop at Beach 36th Street")
Case 5
call textbox01("Stop at Beach 25th Street")
Case 6
call textbox01("Change Direction at Far Rockaway")
Case 7
call textbox01("Stop at Beach 25th Street")
Case 8
call textbox01("Stop at Beach 36th Street")
Case 9
call textbox01("Stop at Beach 44th Street")
Case 10
call textbox01("Stop at Beach 60th Street")
Case 11
call textbox01("Stop at Beach 67th Street")
call textbox02("2 - To Broad Channel")
call textbox03("3 - To Beach 90th Street")
call command02
If buttonpressed = 2 Then
stationnumber = 18
End If
If buttonpressed = 3 Then
stationnumber = 11
End If
Case 12
call textbox01("Stop at Beach 90th Street")
Case 13
call textbox01("Stop at Beach 98th Street")
Case 14
call textbox01("Stop at Beach 105th Street")
Case 15
call textbox01("Change Direction at Rockaway Park")
Case 16
call textbox01("Stop at Beach 105th Street")
Case 17
call textbox01("Stop at Beach 98th Street")
Case 18
call textbox01("Stop at Beach 90th Street")
call textbox02("2 - To Broad Channel")
call textbox03("3 - To Beach 67th Street")
call command02
If buttonpressed = 2 Then
stationnumber = 18
End If
If buttonpressed = 3 Then
stationnumber = 0
End If
case 19
call textbox01("Stop at Broad Channel")
end select
end sub
sub command01
control enable hdlg,101
control disable hdlg,102
control disable hdlg,103
control disable hdlg,104
control disable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command02
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control disable hdlg,104
control disable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command03
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control disable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command04
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control enable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command05
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control enable hdlg,105
control enable hdlg,106
control disable hdlg,107
end sub
sub command06
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control enable hdlg,105
control enable hdlg,106
control enable hdlg,107
end sub
sub textbox01(string01 as string)
control set text hdlg,112,string01
end sub
sub textbox02(string02 as string)
control set text hdlg,113,string02
end sub
sub textbox03(string03 as string)
control set text hdlg,114,string03
end sub
sub textbox04(string04 as string)
control set text hdlg,115,string04
end sub
sub textbox05(string05 as string)
control set text hdlg,116,string05
end sub
sub textbox06(string06 as string)
control set text hdlg,117,string06
end sub
sub textbox07(string07 as string)
control set text hdlg,118,string07
end sub
sub cleartextboxes
control set text hdlg,113,""
control set text hdlg,114,""
control set text hdlg,115,""
control set text hdlg,116,""
control set text hdlg,117,""
control set text hdlg,118,""
end sub
function pbmain
local hfont as long
dialog new 0,"NYCTA Subway Program",0,0,500,100,%ws_sysmenu + %ws_maximize to hdlg
control add button,hdlg,101,"Next Station",10,15,50,15, call nextstation
control add button,hdlg,102,"Route 1",10,50,50,15,call route01
control add button,hdlg,103,"Route 2",10,85,50,15,call route02
control add button,hdlg,104,"Route 3",10,120,50,15,call route03
control add button,hdlg,105,"Route 4",10,155,50,15,call route04
control add button,hdlg,106,"Route 5",10,190,50,15,call route05
control add button,hdlg,107,"Route 6",10,225,50,15,call route06
control add button,hdlg,108,"New route",10,260,50,15,call newroute
control add button,hdlg,109,"Express stops",75,260,50,15,call expressstops
control add button,hdlg,110,"Local stops",140,260,50,15,call localstops
control add button,hdlg,111,"Exit program",205,260,50,15,call exitprogram
control add textbox,hdlg,112,"",75,10,440,25
control add textbox,hdlg,113,"",75,45,440,25
control add textbox,hdlg,114,"",75,80,440,25
control add textbox,hdlg,115,"",75,115,440,25
control add textbox,hdlg,116,"",75,150,440,25
control add textbox,hdlg,117,"",75,185,440,25
control add textbox,hdlg,118,"",75,220,440,25
hfont=createfont(36,18,0,0,0,0,0,0,0,0,0,0,0,"arial")
control send hdlg,112,%wm_setfont,hfont,%true
control send hdlg,113,%wm_setfont,hfont,%true
control send hdlg,114,%wm_setfont,hfont,%true
control send hdlg, 115,%wm_setfont,hfont,%true
control send hdlg, 116,%wm_setfont,hfont,%true
control send hdlg, 117,%wm_setfont,hfont,%true
control send hdlg, 118,%wm_setfont,hfont,%true
stationnumber=6
call selectstation
dialog show modal hdlg
deleteobject hfont
end function
The code doesn't work properly when I press "Route 1" and Route 2" buttons. Jeffrey.
#compile exe
#register none
#dim all
#include "win32api.inc"
global hdlg as long
global buttonpressed as long
global stationnumber as long
global string01 as string
global string02 as string
global string03 as string
global string04 as string
global string05 as string
global string06 as string
global string07 as string
global string08 as string
global terminal as long
callback function nextstation
buttonpressed=1
incr stationnumber
call selectstation
end function
callback function route01
buttonpressed=2
call cleartextboxes
call command01
end function
callback function route02
buttonpressed=3
call cleartextboxes
call command01
end function
callback function route03
buttonpressed=4
call cleartextboxes
call command01
end function
callback function route04
buttonpressed=5
call cleartextboxes
call command01
end function
callback function route05
buttonpressed=6
call cleartextboxes
call command01
end function
callback function route06
buttonpressed=6
call cleartextboxes
call command01
end function
callback function newroute
msgbox "New route"
end function
callback function expressstops
msgbox "Express stops"
end function
callback function localstops
msgbox "Local stops"
end function
callback function exitprogram
dialog end hdlg,1
end function
sub selectstation
select case stationnumber
Case 1
call textbox01("Stop at Beach 67th Street")
Case 2
call textbox01("Stop at Beach 60th Street")
Case 3
call textbox01("Stop at Beach 44th Street")
Case 4
call textbox01("Stop at Beach 36th Street")
Case 5
call textbox01("Stop at Beach 25th Street")
Case 6
call textbox01("Change Direction at Far Rockaway")
Case 7
call textbox01("Stop at Beach 25th Street")
Case 8
call textbox01("Stop at Beach 36th Street")
Case 9
call textbox01("Stop at Beach 44th Street")
Case 10
call textbox01("Stop at Beach 60th Street")
Case 11
call textbox01("Stop at Beach 67th Street")
call textbox02("2 - To Broad Channel")
call textbox03("3 - To Beach 90th Street")
call command02
If buttonpressed = 2 Then
stationnumber = 18
End If
If buttonpressed = 3 Then
stationnumber = 11
End If
Case 12
call textbox01("Stop at Beach 90th Street")
Case 13
call textbox01("Stop at Beach 98th Street")
Case 14
call textbox01("Stop at Beach 105th Street")
Case 15
call textbox01("Change Direction at Rockaway Park")
Case 16
call textbox01("Stop at Beach 105th Street")
Case 17
call textbox01("Stop at Beach 98th Street")
Case 18
call textbox01("Stop at Beach 90th Street")
call textbox02("2 - To Broad Channel")
call textbox03("3 - To Beach 67th Street")
call command02
If buttonpressed = 2 Then
stationnumber = 18
End If
If buttonpressed = 3 Then
stationnumber = 0
End If
case 19
call textbox01("Stop at Broad Channel")
end select
end sub
sub command01
control enable hdlg,101
control disable hdlg,102
control disable hdlg,103
control disable hdlg,104
control disable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command02
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control disable hdlg,104
control disable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command03
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control disable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command04
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control enable hdlg,105
control disable hdlg,106
control disable hdlg,107
end sub
sub command05
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control enable hdlg,105
control enable hdlg,106
control disable hdlg,107
end sub
sub command06
control disable hdlg,101
control enable hdlg,102
control enable hdlg,103
control enable hdlg,104
control enable hdlg,105
control enable hdlg,106
control enable hdlg,107
end sub
sub textbox01(string01 as string)
control set text hdlg,112,string01
end sub
sub textbox02(string02 as string)
control set text hdlg,113,string02
end sub
sub textbox03(string03 as string)
control set text hdlg,114,string03
end sub
sub textbox04(string04 as string)
control set text hdlg,115,string04
end sub
sub textbox05(string05 as string)
control set text hdlg,116,string05
end sub
sub textbox06(string06 as string)
control set text hdlg,117,string06
end sub
sub textbox07(string07 as string)
control set text hdlg,118,string07
end sub
sub cleartextboxes
control set text hdlg,113,""
control set text hdlg,114,""
control set text hdlg,115,""
control set text hdlg,116,""
control set text hdlg,117,""
control set text hdlg,118,""
end sub
function pbmain
local hfont as long
dialog new 0,"NYCTA Subway Program",0,0,500,100,%ws_sysmenu + %ws_maximize to hdlg
control add button,hdlg,101,"Next Station",10,15,50,15, call nextstation
control add button,hdlg,102,"Route 1",10,50,50,15,call route01
control add button,hdlg,103,"Route 2",10,85,50,15,call route02
control add button,hdlg,104,"Route 3",10,120,50,15,call route03
control add button,hdlg,105,"Route 4",10,155,50,15,call route04
control add button,hdlg,106,"Route 5",10,190,50,15,call route05
control add button,hdlg,107,"Route 6",10,225,50,15,call route06
control add button,hdlg,108,"New route",10,260,50,15,call newroute
control add button,hdlg,109,"Express stops",75,260,50,15,call expressstops
control add button,hdlg,110,"Local stops",140,260,50,15,call localstops
control add button,hdlg,111,"Exit program",205,260,50,15,call exitprogram
control add textbox,hdlg,112,"",75,10,440,25
control add textbox,hdlg,113,"",75,45,440,25
control add textbox,hdlg,114,"",75,80,440,25
control add textbox,hdlg,115,"",75,115,440,25
control add textbox,hdlg,116,"",75,150,440,25
control add textbox,hdlg,117,"",75,185,440,25
control add textbox,hdlg,118,"",75,220,440,25
hfont=createfont(36,18,0,0,0,0,0,0,0,0,0,0,0,"arial")
control send hdlg,112,%wm_setfont,hfont,%true
control send hdlg,113,%wm_setfont,hfont,%true
control send hdlg,114,%wm_setfont,hfont,%true
control send hdlg, 115,%wm_setfont,hfont,%true
control send hdlg, 116,%wm_setfont,hfont,%true
control send hdlg, 117,%wm_setfont,hfont,%true
control send hdlg, 118,%wm_setfont,hfont,%true
stationnumber=6
call selectstation
dialog show modal hdlg
deleteobject hfont
end function
The code doesn't work properly when I press "Route 1" and Route 2" buttons. Jeffrey.
Comment