Live Code Version 4.6.4
The Stack:
One Card, name = "ARRM_UI"
Three Scrolling List Fields, name one = "Year"; name two = "City"; name three = "ARRMdata
One button, name = "submit"
two fields, name one "year_picked" and name two "city_picked"
The database (with 780 rows)
one table, name = "ARRM"
Column one = "RowID"
Column two = "FY" (FY=Fiscal Year)
Column three = "City"
Column four to eight all numerical data
Standalone Application Settings:
General Tab = Selected "Search for required...." and Selected "Remove all profiles..."
Stack Tab = stackname.livecode
Copy Files = databasename.sqlite
Android Tab = Checked "Android"; Basic Application Settings checked SQLite; Requirements and Restrictions all radio buttons "N/A"; Application Permissions none checked; User interface options "landscape"
Menu Bar's --> Development the device is visible and checked.
I have two goals:
1. Get it to deploy on Xoom
2. More efficient live code script: as you will see below I use the fields "year_picked" and "city_picked" to store the user input that should be handled better using global variables but I am not getting it to work
Here is the script for the stack:
Code: Select all
Local tDataBaseID
on preopenstack
databaseConnect
if the environment is "mobile" then
mobileSetAllowedOrientation "portrait, portrait upside down, landscape left, landscape right"
end if
end preopenstack
##Open the connection to the database
on databaseConnect
put SpecialFolderPath ("Desktop") &"/MyAppsFolder/MyDatabaseName.sqlite" into tDatabasePath
put revOpenDatabase ("sqlite", tDatabasePath,,,,) into tDatabaseID
end databaseConnect
##This LiveCode and SQLite script will return the distinct values of FY's (2012, 2013, etc) for a table build into the scrolling list field of "year"
Function FYdata
put SpecialFolderPath ("Desktop") &"/MyAppsFolder/MyDatabaseName.sqlite" into tDatabasePath
put revOpenDatabase ("sqlite", tDatabasePath,,,,) into tDatabaseID
put "SELECT DISTINCT FY FROM ARRM" into tSQL
put revDataFromQuery(tab, return, tDatabaseID, tSQL) into tFYdata
return tFYdata
end FYdata
##This LiveCode and SQLite script will return the distinct values of Cities (Chicago, Boston, etc) for a table build into the scrolling list field of "year"
Function CityNames
put SpecialFolderPath ("Desktop") &"/MyAppsFolder/MyDatabaseName.sqlite" into tDatabasePath
put revOpenDatabase ("sqlite", tDatabasePath,,,,) into tDatabaseID
put "SELECT DISTINCT City FROM ARRM" into tSQL2
put revDataFromQuery(tab, return, tDatabaseID, tSQL2) into tCityNames
return tCityNames
end CityNames
##This live code and SQLite code will return all years and cities who have a value = to tFY and = to tCity
##I use hidden fields here because I am having trouble with making the global variable work
Function AggregateARRMdata
put field "FY_picked" into tFY
put field "City_Picked" into tCity
put SpecialFolderPath ("Desktop") &"/MyAppsFolder/MyDatabaseName.sqlite" into tDatabasePath
put revOpenDatabase ("sqlite", tDatabasePath,,,,) into tDatabaseID
put "SELECT * FROM ARRM where FY = '"& tFY &"' and City = '"& tCity &"'" into tSQL3
put revDataFromQuery(tab, return, tDatabaseID, tSQL3) into tAggregateARRMdata
return tAggregateARRMdata
end AggregateARRMdata
Code: Select all
##Build the distinct lists when the card is opened
on preopencard
buildlistdisplay
end preopencard
##When the card opens the distinct list of fiscal years will be displayed
On buildlistdisplay
put FYdata() into tFYData
put tFYdata into field "Year_Picked"
##When the card opens the distinct list of cities will be displayed
put CityNames() into tCityName
put tCityName into field "City_Picked"
end buildlistdisplay
Code: Select all
##User will select a fiscal year (2012, 2013, 2014, etc)
## the clicked line will be saved as a variable and put into field "year_picked"
on MouseUp
put the value of the clickLine into tFY
put tFY into field "Year_Picked"
end MouseUp
Code: Select all
##User will select a city (Chicago, Boston, New York, etc)
## the clicked line will be saved as a variable and put into field "city_picked"
on MouseUp
put the value of the clickLine into tCity
put tCity into field "City_Picked"
end MouseUp
Code: Select all
on mouseUp
##Calls from the function script in the stack
##From the user input (Year and City) the fields (Year_Picked and City_Picked) are put into variables so that
##the SQL script will Select a list from the table where Year= selected year and City = selected city
##The data returned from the database is put into field "ARRMdata"
put AggregateARRMdata() into tAggregateARRMdata
put tAggregateARRMdata into field "ARRMdata"
end mouseUp