Some suggestions:
1) make sure you've turned off any "hide extensions" option in your OS.
2) Create a named FolderItem as a test (instead of asking for the
filename in the "Save As..." dialog), as:
f = GetFolderItem("test.wpt")
and see if your code correctly creates a .wpt file afterwards.
On May 1, 2007, at 4:29 PM, Dobbs, Paul wrote:
> I have a program, one of whose functions is to convert between two
> similar file formats. Its normal format is wpt files, but it can
> import
> inw files and then save them as wpt files. The problem is that when I
> import an inw file, then save it, the inw extension is added to the
> file
> name. I can't figure out why this is happening, especially since the
> folderitems for the two routines are completely separate.
>
> Here is the import routine:
>
> Dim F As FolderItem
> Dim S As TextInputStream
> Dim Line As String
> Dim RoutePlanTypes as New FileType
> Dim Plus As Integer = 0
>
> RoutePlanTypes.Name= "Route Plans"
> RoutePlanTypes.Extensions=".inw"
>
> F = GetOpenFolderItem(RoutePlanTypes)
> If F <> Nil Then
>
> WaypointLst.DeleteAllRows
>
> NumberEdt.Text = "1"
>
> S = F.OpenAsTextFile
> If S <> Nil Then
> While Not S.EOF
> Line = S.ReadLine
> If Line = "// Waypoints" Then Exit
> Wend
> While Not S.EOF
> Line = S.ReadLine
> Plus = 0
> WaypointLst.AddRow Line.NthField(" ", 1)
> For i As Integer = 1 To WaypointLst.ColumnCount - 1
> If i = 3 Then Plus = 1
> WaypointLst.Cell(WaypointLst.LastIndex, i + Plus) =
> Line.NthField(" ", i + 1)
> Next
>
> Wend
> S.Close
>
> For i As Integer = 0 To WaypointLst.ListCount - 1
> WaypointLst.Cell(i, 3) = "0.00"
> WaypointLst.Cell(i, 14) = "0"
> Next
>
> WaypointLst.Cell(WaypointLst.ListCount - 1, 10) = "4" //put end
> command in last waypoint
> Else
> MsgBox "Unable to open " + F.Name
> End If
> End If
>
> FixWaypointNumbers
> WaypointLst.FixWidth
>
> And here is the save routine:
>
> Dim F As FolderItem
> Dim S As TextOutputStream
> Dim Dlg As New SaveAsDialog
> Dim D As New Date
> Dim MD As New MessageDialog
> Dim WaypointPlanTypes as New FileType
>
> WaypointPlanTypes.Name= "Waypoint Plans"
> WaypointPlanTypes.Extensions="wpt"
>
> Dlg.SuggestedFileName = "Plan" + NumberEdt.Text
> Dlg.Filter = "WaypointPlanTypes"
>
> F = Dlg.ShowModal
> If F <> Nil Then
> S = F.CreateTextFile
> If S <> Nil Then
> S.WriteLine "// WptPlanTool Route File - " + D.LongDate +" " +
> D.LongTime
> S.WriteLine
> S.WriteLine "// Fields: Wpt ID; Latitude; Longitude; Traversal
> Time; Easting; Northing;"
> S.WriteLine "// UTMZone; Elevation; Corridor Width; Max
> Velocity;
> ArrivalCommand;"
> S.WriteLine "// Arrival Heading; Pause Time; Mission Code; Event
> Point ID"
> S.WriteLine
> S.WriteLine "// Plan ID"
> S.WriteLine NumberEdt.Text
> S.WriteLine
> S.WriteLine "// Number of Waypoints"
> S.WriteLine CStr(WaypointLst.ListCount)
> S.WriteLine
> S.WriteLine "// Waypoints"
> For i As Integer = 0 To WaypointLst.ListCount - 1
> S.Write WaypointLst.Cell(i,0) + " "
> S.Write WaypointLst.Cell(i,1) + " "
> S.Write WaypointLst.Cell(i,2) + " "
> S.Write WaypointLst.Cell(i,3) + " "
> S.Write WaypointLst.Cell(i,4) + " "
> S.Write WaypointLst.Cell(i,5) + " "
> S.Write WaypointLst.Cell(i,6) + " "
> S.Write WaypointLst.Cell(i,7) + " "
> S.Write WaypointLst.Cell(i,8) + " "
> S.Write WaypointLst.Cell(i,9) + " "
> S.Write WaypointLst.Cell(i,10) + " "
> S.Write WaypointLst.Cell(i,11) + " "
> S.Write WaypointLst.Cell(i,12) + " "
> S.Write WaypointLst.Cell(i,13) + " "
> S.Write WaypointLst.Cell(i,14) + " "
> S.WriteLine
> Next
> S.Close
>
> Else
> MD.Icon = MessageDialog.GraphicCaution
> MD.Explanation = "Unable to create the text file " + F.Name
> MD.Title = "Save Error"
> Call MD.ShowModal
> End If
> End If
> Return True
>
> Paul Dobbs
> Software Engineer, Staff
> Lockheed Martin Missiles and Fire Control
> Phone (972) 603-1244
> Fax (972) 603-2017
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>