Here is a brief description of whats happening.
I have an array with various pits and pieces of data in them.
Code: Select all
global PLNListingDetailArray
put "ListDateField" into PLNListingDetailArray[1][1] -- Field Name
put true into PLNListingDetailArray[1][2] -- Validation Required
put "dateListed" into PLNListingDetailArray[1][3] -- Database Field Name
put "INTEGER" into PLNListingDetailArray[1][4] -- Data Type
put "DateEntryField" into PLNListingDetailArray[1][5] -- Control Type
put "ListingExpiryDateField" into PLNListingDetailArray[2][1]
put true into PLNListingDetailArray[2][2]
put "expiryDate" into PLNListingDetailArray[2][3]
put "INTEGER" into PLNListingDetailArray[2][4]
put "DateEntryField" into PLNListingDetailArray[2][5]
more puts......
For each of those input fields that requires a date a button is provided in which a calendar is presented and the user can select the date. Notice the 'callback' as I insure that the "short" date in used.
Code: Select all
on mouseUp
DPpopup
if the result is not empty then answer error the result
end mouseUp
on DPdateClick aDates,pMode,pSourceObj
put aDates["Short"] into field "ListingExpiryDateField"
end DPdateClick
In building this string I do a call to a 'command' to build the structure that is required syntax for the SQL INSERT.
Code: Select all
command buildFieldNameAndValuesVariable
global PLNListingDetailArray, gPLNColumnNames, gPLNFieldValues
local tArrayElement
local tValue, tEnteredDate
local tItemName
repeat for each element tArrayElement in PLNListingDetailArray
put gPLNColumnNames & tArrayElement[3] & "," into gPLNColumnNames
put empty into tValue
switch tArrayElement[5]
case "OptionMenu" -- OptionMenu datatype
if tArrayElement[1] = "PropertyTypeOptionMenu" then
put the label of button "PropertyTypeOptionMenu" into tItemName
put char 1 of tItemName into tValue
break
end if
if tArrayElement[1] = "PropertySubtypeOptionMenu" then
put the label of button "PropertySubtypeOptionMenu" into tItemName
put char 1 of tItemName into tValue
break
end if
if tArrayElement[1] = "AreaOptionMenu" then
put the label of button "AreaOptionMenu" into tItemName
put char 1 of tItemName into tValue
break
end if
case "CheckBox" -- CheckBox datatype
if GetAction() = "Add" then
put 0 into tValue
end if
if tArrayElement[1] = "NoOpenHourCheck" then
if the hilite of button "NoOpenHourCheck" is true then
put 1 into tValue
end if
break
end if
if tArrayElement[1] = "IsRentalCheck" then
if the hilite of button "IsRentalCheck" is true then
put 1 into tValue
end if
break
end if
if tArrayElement[1] = "DontContactOwnerCheck" then
if the hilite of button "DontContactOwnerCheck" is true then
put 1 into tValue
end if
break
end if
case "DateEntryField"
put 0 into tEnteredDate
switch tArrayElement[1]
case "ListDateField"
put myConvertDateToSeconds("ListDateField") into tEnteredDate
put tEnteredDate into tValue
break
case "ListingExpiryDateField"
put myConvertDateToSeconds("ListingExpiryDateField") into tEnteredDate
put tEnteredDate into tValue
break
case "OpenHourDateField"
put myConvertDateToSeconds("OpenHourDateField") into tEnteredDate
put tEnteredDate into tValue
break
end switch
end switch
put gPLNFieldValues & tValue & "," into gPLNFieldValues
end repeat
delete last character of gPLNColumnNames
end buildFieldNameAndValuesVariable
When a date is identified then this portion of the code is executed
Code: Select all
case "DateEntryField"
put 0 into tEnteredDate
switch tArrayElement[1]
case "ListDateField"
put myConvertDateToSeconds("ListDateField") into tEnteredDate
put tEnteredDate into tValue
break
case "ListingExpiryDateField"
put myConvertDateToSeconds("ListingExpiryDateField") into tEnteredDate
put tEnteredDate into tValue
break
case "OpenHourDateField"
put myConvertDateToSeconds("OpenHourDateField") into tEnteredDate
put tEnteredDate into tValue
break
end switch
end switch
Code: Select all
function myConvertDateToSeconds pFieldName
get field pFieldName
convert it to seconds
end myConvertDateToSeconds
However I have just noticed something while typing this out. If I use the CURRENT date then 'convert' works but if I use a another date, say a week ahead then it fails.