Help to convert Basic4ppc code

tcgoh

Active Member
Licensed User
Longtime User
Hi all,

Could anyone here help me to convert the code below from B4ppc to Basic4android? My B4ppc program is on my old computer and I'm trying to creat a .sl3 file from a text database file.

con.New1
cmd.New1("", con.Value)

If FileExist (AppPath & "\alldata.tmp") = True Then
FileDel(AppPath & "\alldata.tmp")
End If

con.Open("Data Source = " & AppPath & "\alldata.tmp")

cmd.CommandText = "CREATE Table 'CREW' ('SN' TEXT,'NAME' TEXT,'FL' TEXT,'RK' TEXT,'COP' TEXT,'DEP' TEXT,'TM' TEXT,'FLTNO' TEXT,'ARR' TEXT,'TM2' TEXT)"
cmd.ExecuteNonQuery

If FileExist (AppPath & "\Allcrew") = True Then
FileOpen (c1,AppPath & "\Allcrew",cRead ,, cASCII)

r = FileRead (c1)

Do Until r = EOF
If StrCompare(SubString(r,0,8)," ") = 0 Then
r = FileRead (c1)
Else

SN = SubString(r,0,8)
NAME = SubString(r,9,22)
FL = SubString(r,32,3)
RK = SubString(r,36,3)
COP = SubString(r,40,4)
DEP = SubString(r,45,8)
TM = SubString(r,54,4)
FLTNO = SubString(r,59,8)
ARR = SubString(r,68,8)
TM2 = SubString(r,77,4)

If StrIndexOf(NAME , "'",0) > -1 Then
NAME = StrInsert(NAME,StrIndexOf(NAME , "'",0),"'")
End If

cmd.CommandText = "INSERT INTO `CREW` VALUES ('" & SN & "','" & NAME & "','" & FL & "','" & RK & "','" & COP & "','" & DEP & "','" & TM & "','" & FLTNO & "','" & ARR & "','" & TM2 & "');"
cmd.ExecuteNonQuery

r = FileRead (c1)
End If

Loop
FileClose (c1)
Else
Msgbox("Allcrew file not found")
AppClose
End If

con.Close
WaitCursor(False)


If cPPC Then
FileCopy(AppPath & "\alldata.tmp", "\My Documents\alldata.sl3")
FileDel(AppPath & "\alldata.tmp")

Else
opendialog1.File = AppPath & "\alldata.tmp"
SaveDialog1.File = AppPath & "\alldata.sl3"
If SaveDialog1.Show = cCancel Then
Return
End If

FileCopy(OpenDialog1.File, SaveDialog1.File)
FileDel(AppPath & "\alldata.tmp")
End If
AppClose

Thanks
 
Top