Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
vedus
- Livecode Opensource Backer

- Posts: 153
- Joined: Tue Feb 26, 2013 9:23 am
Post
by vedus » Wed Dec 11, 2013 9:07 pm
hi guys.

question is...
i have database with row like this in existing datagrid1 (sqlite database)
and here is the xml file
Code: Select all
<name_day>
<Onomastikes>
<Month>4</Month>
<Day>23</Day>
<Name> George </Name>
i want to match the current system date(month-day) with (month+day) from the xml file and after with database first_name
i have the xml file and i pass the data to array and then to datagrid2 (always unicode data).
i do not mind if i get it from xml or the datagrid,i am looking the easy way for now to learn it..
Code: Select all
on mouseUp
set the itemDelimiter to slash
local tPreferencesFile
put item 1 to -2 of the effective filename of this stack & "/birthdays.xml" into mypath
--set the itemDelimiter to comma
# Read the preferences data from the file into a variable. Always check for the result when reading files
# as its possible that the file may have been deleted or moved.
local tPreferencesData, tResult
put url ("file:" & mypath) into tPreferencesData
put the result into tResult
if tResult is not empty then
answer error "Failed to read preferences file at location: " & mypath
return empty
end if
put tPreferencesData into theXML
replace cr with empty in theXML
-- Convert xml to array. Store data in array as UTF8.
put ConvertXMLToArray(theXML, "UTF-8") into theArray -- handler in RevOnline stack
-- Convert to an array that can be assigned to the dgData of a Data Grid (numerically indexed).
put SortArrayKeysWithXMLOrdering(theArray["birthdays"]) into theKeys -- handler in RevOnline stack
put 0 into i
repeat for each line theKey in theKeys
add 1 to i
put theArray["birthdays"][theKey] into theData[i]
end repeat
set the dgdata of group "datagrid1" to theData
--breakpoint -- check values of arrays in debugger
end mouseUp
thannk you

-
MaxV
- Posts: 1580
- Joined: Tue May 28, 2013 2:20 pm
-
Contact:
Post
by MaxV » Fri Dec 13, 2013 11:47 am
Do you want to set up a table with namedays?
Code: Select all
on preOpenStack
set itemDel to "/"
set the defaultFolder to item 1 to -2 of (the effective fileName of this stack)
end preOpenStack
then
Code: Select all
On MouseUp
put revXMLCreateTreeFromFile("birthdays.xml",false,true,false) into XML-ID
#XML-ID is the id of a new xml tree
if the result is not empty then
answer error "Failed to read preferences file"
exit
end if
#... your code
End MouseUp
now you can explore easily your XML with the XMl library that is included in Livecode. (See Dictionary -> Library -> XML)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
vedus
- Livecode Opensource Backer

- Posts: 153
- Joined: Tue Feb 26, 2013 9:23 am
Post
by vedus » Fri Dec 13, 2013 4:30 pm
thank you maxv but the anwser you give is included in my code abobe..
i know to get the data from xml,and to put it if i want in datagrid or array.
I do not know how to match the data from xlm or the datagrid with system date.
-
MaxV
- Posts: 1580
- Joined: Tue May 28, 2013 2:20 pm
-
Contact:
Post
by MaxV » Fri Dec 13, 2013 5:29 pm
Maybe you are looking for this:
Code: Select all
#create an array that KEY are names and values are dates
#all dates in array formatted like DD-MM-YYYY or your system date
put the system date into today
put 0 into check
put false into verify
repeat for each item tempItem of myArray
add 1 to t
if tempItem = today then
put true into check
exit repeat
end if
end repeat
if check then
put myArray[t] into nameday
answer "today is nameday of " & nameday
end if
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
vedus
- Livecode Opensource Backer

- Posts: 153
- Joined: Tue Feb 26, 2013 9:23 am
Post
by vedus » Fri Dec 13, 2013 6:57 pm
thank you maxv i will try it and i post the results
