Go Faster
Go Faster is simple and really useful application write in Basic4ppc. Basic4ppc is cool and smart app to create exe files for windows 6.0 etc.
Go Faster was created to help people who use public transport. If you are one of them maybe you found sth useful. This app showing current train/bus traffic in simple table. You can easy generate your own bus-stop traffic! App use XML files. If you live in Wrocław you can use this source to generate your XML files also if you’re developer you can transform this script. To regenerate app you have to have Basic4ppc created by Anywhere Software.
Generate XML files
0,1,2
train - number of train
time - time in minuts
*/
$tab['busstop_id']='24214';
$tab['train']=$id;
$xml='';
$html = file_get_contents($filename);
//select wariant
preg_match_all('#(.*?)#si', $html, $przystanek);
//pobieram kod dni
preg_match_all('#(.*?)#si', $przystanek[0][0], $dzien);
/*
dzien array
1 - nazwa dnia
2 - rozkład dla dnia
*/
for($i=0;$i<count($dzien[1]);$i++)
{
//declare day type
if($dzien[1][$i] == 'w dni robocze')
{
$tab['type_of_day']=0;
}elseif($dzien[1][$i] == 'Sobota'){
$tab['type_of_day']=1;
}else{
$tab['type_of_day']=2;
}
//explode by hour
preg_match_all('#(.*?)#si', $dzien[2][$i], $godz);
for($j=0;$j<count($godz[1]);$j++)
{
//explode by min
preg_match_all('##si', $godz[2][$j], $min);
for($k=0;$k<count($min[1]);$k++)
{
//set time - haurs to min
$tab['time']=$godz[1][$j]*60;
$tab['show_time']=$godz[1][$j];
//set time - haurs to min
$tab['time']+=$min[1][$k];
$tab['show_time'].=':'.$min[1][$k];
//generate xml
$xml.='';
$xml.=''.$tab['train'].'';
$xml.=''.$tab['show_time'].'';
$xml.=''.$tab['type_of_day'].'';
$xml.=''.$tab['time'].'';
$xml.='>';
}
}
}
return $xml;
}
//set line number
$xml='';
//generate heders
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
//make lines
$xml.=doit('line9.xml','9');
$xml.=doit('line17.xml','17');
$xml.=doit('line12.xml','12');
$xml.='';
//save it!
$handle = fopen('default.xml', 'w+');
fwrite($handle, $xml);
fclose($handle);
?>
Application source (download)
Sub Globals
constval=False
End Sub
Sub App_Start
Form1.Show
If constval = False Then
Table1.LoadXML("default.xml")
End If
today = DateDayOfweek(Now)
If today = "Monday" Then
datetype=0
Else If today = "Tuesday" Then
datetype=0
Else If today = "Wednesday" Then
datetype=0
Else If today = "Thursday" Then
datetype=0
Else If today = "Friday" Then
datetype=0
Else If today = "Saturday" Then
datetype=1
Else If today = "Sunday" Then
datetype=2
End If
Table1.Filter(Table1.ColName(2) & " = '" & datetype & "'")
Table1.TableSort(Table1.ColName(3) & " ASC")
'show sellected current
timenow=(TimeH*60)+TimeM-1
'Dim i As Integer
i = Table1.RowCount-1
Do While i > 2
If timenow <= Table1.Cell(Table1.ColName(3),i) Then j=i End If If Table1.Cell(Table1.ColName(3),i)-timenow => 0 Then
Table1.Cell(Table1.ColName(0),i)=Table1.Cell(Table1.ColName(0),i) & " (" & Table1.Cell(Table1.ColName(3),i)-timenow & ")"
End If
i=i-1
Loop
Table1.SelectCell(Table1.ColName(0), j)
constval=True
End Sub
Sub mnuLoadXML_Click
OpenXML.Filter = "XML Files|*.xml"
If OpenXML.Show = cCancel Then Return
Table1.Clear
Table1.LoadXML(OpenXML.File)
App_Start
End Sub
Sub btnPrevious_Click
'priev
If Table1.SelectedRow = -1 Then
Table1.SelectCell(Table1.ColName(0),0)
Else
If Table1.SelectedRow-10 >= 0 Then
Table1.SelectCell(Table1.ColName(0),Table1.SelectedRow-10)
Else
Table1.SelectCell(Table1.ColName(0),0)
End If
End If
End Sub
Sub btnNext_Click
'next
If Table1.SelectedRow = -1 Then
Table1.SelectCell(Table1.ColName(0),11)
Else
If Table1.SelectedRow+11 <= Table1.RowCount-1 Then
Table1.SelectCell(Table1.ColName(0),Table1.SelectedRow+11)
Else
Table1.SelectCell(Table1.ColName(0),Table1.RowCount-1)
End If
End If
End Sub
Sub Menu2_Click
Table1.Clear
Table1.LoadXML("default.xml")
App_Start
End Sub
Sub btnNow_Click
Menu2_Click
End Sub
Advertisement
Categories: application
pocket pc, vb