VERSION 5.00
Begin VB.Form Cities 
   AutoRedraw      =   -1  'True
   Caption         =   "City Distances"
   ClientHeight    =   2370
   ClientLeft      =   4185
   ClientTop       =   4890
   ClientWidth     =   5430
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2370
   ScaleWidth      =   5430
   Begin VB.ComboBox Namelist 
      Appearance      =   0  'Flat
      Height          =   315
      Left            =   780
      TabIndex        =   1
      Text            =   "Combo1"
      Top             =   360
      Width           =   2835
   End
   Begin VB.Frame Frame2 
      Caption         =   "Sort By"
      Height          =   1035
      Left            =   2100
      TabIndex        =   5
      Top             =   1140
      Width           =   1695
      Begin VB.OptionButton Distance 
         Caption         =   "By Distance"
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   660
         Width           =   1335
      End
      Begin VB.OptionButton Alphabetic 
         Caption         =   "Alphabetic"
         Height          =   195
         Left            =   120
         TabIndex        =   8
         Top             =   360
         Value           =   -1  'True
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Scale"
      ClipControls    =   0   'False
      Height          =   1035
      Left            =   180
      TabIndex        =   4
      Top             =   1140
      Width           =   1695
      Begin VB.OptionButton Miles 
         Caption         =   "Miles"
         Height          =   375
         Left            =   120
         TabIndex        =   7
         Tag             =   "Miles"
         Top             =   600
         Width           =   1155
      End
      Begin VB.OptionButton Kilometers 
         Caption         =   "Kilometers"
         Height          =   315
         Left            =   120
         TabIndex        =   6
         Top             =   300
         Value           =   -1  'True
         Width           =   1275
      End
   End
   Begin VB.CommandButton OK 
      Caption         =   "OK"
      Height          =   315
      Left            =   4140
      TabIndex        =   2
      Top             =   240
      Width           =   1095
   End
   Begin VB.CommandButton Cancel 
      Caption         =   "Close"
      Height          =   315
      Left            =   4140
      TabIndex        =   3
      Top             =   660
      Width           =   1095
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      Caption         =   "From"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   180
      TabIndex        =   0
      Top             =   360
      Width           =   495
   End
   Begin VB.Menu mnuOptions 
      Caption         =   "&Options"
      Begin VB.Menu mnuDLL 
         Caption         =   "&DLL"
      End
      Begin VB.Menu mnuEXE 
         Caption         =   "&EXE"
      End
      Begin VB.Menu mnuSep1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuShow 
         Caption         =   "&Show"
      End
      Begin VB.Menu mnuLog 
         Caption         =   "&Log"
      End
      Begin VB.Menu mnuSep2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "E&xit"
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "&Help"
      Begin VB.Menu mnuAbout 
         Caption         =   "&About"
      End
   End
End
Attribute VB_Name = "Cities"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub displaynames(s$)
i = 1
Do
  j = InStr(i, s, Chr$(10))
  If j = 0 Then Exit Do
  Namelist.AddItem Mid$(s, i, j - i)
  i = j + 1
Loop
Namelist.Text = "Antwerp"
End Sub

Private Sub displaytext(h$, s$)
View!Header.Caption = h
View!Viewnames.Text = s
View.Show 1
End Sub

Private Sub SetServer(n As Integer)
jinit n
jdo "0!:0 < jsystempath 'system\examples\demo\citycalc.ijs'"
jdo "cityread ''"
End Sub

Private Sub Cancel_Click()
End
End Sub

Private Sub Form_Load()
Dim names$
Dim res As String
SetServer 0
names = jgets("CNAMES")
displaynames names
mnuDLL.Checked = True
End Sub


Private Sub OK_Click()
Dim cmd As String, hdr As String
Dim dtext As String
ifmiles = Str$(Miles.Value)
ifdistance = Str$(Distance.Value)
city = Namelist.Text
cmd = "x=. cityfmts '" & ifmiles & " " & ifdistance & " " & city & "'"
ec = jdo(cmd)
If Miles.Value Then
  hdr = "Miles from "
Else
  hdr = "Kilometers from "
End If
hdr = hdr & city
dtext = jgets("x")
displaytext hdr, dtext
End Sub

Private Sub mnuAbout_Click()
Dim t As String
LF = Chr$(10)
LF2 = LF & LF
t = ""
t = t & "Cities demo using J OLE Server" & LF2
t = t & "Options menu:" & LF2
t = t & "  select EXE for JEXE server " & LF
t = t & "  select DLL for JDLL server" & LF2
t = t & "  select Show to display JEXE session (ignored by DLL)" & LF
t = t & "  select Log to display JEXE log (ignored by DLL)" & LF
About!lblAbout.Caption = t
About.Show 1
End Sub
Private Sub mnuDLL_Click()
If mnuDLL.Checked = False Then
 SetServer 0
 mnuDLL.Checked = True
 mnuEXE.Checked = False
 mnuShow.Enabled = False
 mnuLog.Enabled = False
End If
Cities.SetFocus
End Sub

Private Sub mnuEXE_Click()
If mnuEXE.Checked = False Then
 SetServer 1
 If mnuShow.Checked = True Then js.Show (1)
 If mnuLog.Checked = True Then js.Log (1)
 mnuEXE.Checked = True
 mnuDLL.Checked = False
 mnuShow.Enabled = True
 mnuLog.Enabled = True
End If
Cities.SetFocus
End Sub

Private Sub Exit_Click(Index As Integer)
End
End Sub

Private Sub mnuLog_Click()
mnuLog.Checked = Not mnuLog.Checked
If mnuLog.Checked Then
  js.Log (1)
Else
  js.Log (0)
End If
End Sub

Private Sub mnuShow_Click()
mnuShow.Checked = Not mnuShow.Checked
If mnuShow.Checked Then
  js.Show (1)
Else
  js.Show (0)
End If
End Sub
