Source language: Translate to:

tmEvents help with error

Questions about NeoBook PlugIns

Moderator: Neosoft Support

tmEvents help with error

Postby BRobinsonS » Fri Sep 28, 2007 9:32 pm

I am attempting to pull variables from a database and set events for each of them. I seem to get '09/29/2007' is not a valid date message constantly. Any ideas why this might be considered invalid?

I have tried changing the field to string and date, both seem to return the error.

[Sub] Returns 1
[Date1] Returns 09/29/2007
[Time1] Returns 10:00

dbfQuery "[PubDir]Events.bin" "Type=Once AND Enabled=Checked AND Day=[DayofWeek]"
dbfQueryCount "[PubDir]Events.bin" "[Count]"
Loop "1" "[Count]" "[x]"
dbfSetImportExportOptions "," "UseQuotes"
dbfGotoRecord "[PubDir]Events.bin" "[x]"
dbfRecordToVar "[PubDir]Events.bin" "[SetOnceEventRec[x]]"
dbfFieldToVar "[PubDir]Events.bin" "DATE" "[Date1]" ""
dbfFieldToVar "[PubDir]Events.bin" "MTIME" "[Time1]" ""
tmAlarmEventsCreate "Rectangle1" "VarAlarm"
tmAlarmEventsCreateUnique "Rectangle1" "[Sub]" "[Date1]" "[Time1]"
EndLoop


Thanks for any help or suggestions,

Tom
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Postby TechMedia » Sat Sep 29, 2007 4:29 am

Please try 29/09/2007
TechMedia
 

Postby BRobinsonS » Sat Sep 29, 2007 5:45 am

Tried switching the month and day so as [Date1] returns 29/09/2007, but seems to get the same error.

It may be something to do with the way I have this pub set up. When I start the date picker and time picker already have set variables, I just need to figure out why,


Thanks
Tom
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Postby Gaev » Sat Sep 29, 2007 6:20 am

Tom:

The problem lies in your use of the following commands ...
Code: Select all
dbfFieldToVar "[PubDir]Events.bin" "DATE" "[Date1]" ""
dbfFieldToVar "[PubDir]Events.bin" "MTIME" "[Time1]" ""

According to the Help file, this command will ...
Copy the contents of a single field from each record to a variable. Items will be separated by carriage returns. If a search query is active, only records matching the query will be copied.

So, with each iteration of the loop, your variables [Date1] and [Time1] end up containing the same set of dates and times for ALL selected (queried) records ... separated by carriage returns (i.e. [#13]) ... my assumption is that the plugin commands are expecting to find just one date (time) value ... hence the error about an invalid date.

Try and replace the two commands with ...
Code: Select all
SetVar "[Date1]" "[Events.date]"
SetVar "[Time1]" "[Events.mtime]"

You may also need to change you database file's extension to dbf ... I am not sure if the reference syntax for fields in the current database record ... i.e. [databaseFilePrefix.FieldName] ... will work when the databaseFileExtension is not dbf.

Perhaps, during testing you might place ...
Code: Select all
AlertBox "This Date and Time" "[Date1]|[Time1]"
... just after the two commands ... to verify what is being passed to the plugin.
User avatar
Gaev
 
Posts: 3735
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby BRobinsonS » Sat Sep 29, 2007 6:40 am

Hi Gaev,

Thanks for the suggestions, I think you may be on to something as running this:

. Loop Database Results for once query
Loop "1" "[Count]" "[x]"
dbfSetImportExportOptions "," "UseQuotes"
dbfGotoRecord "[PubDir]Events.bin" "[x]"
dbfRecordToVar "[PubDir]Events.bin" "[SetOnceEventRec[x]]"
dbfFieldToVar "[PubDir]Events.bin" "DATE" "[Date1]" ""
dbfFieldToVar "[PubDir]Events.bin" "MTIME" "[Time1]" ""
AlertBox "message box" "[Date1] Date||[Time1] Time"
ClearVariables "[Date1],[Time1]"
EndLoop

my alert box shows all the records dates and times at once instead of what I thought would show only one of each on each loop. I will try your suggestions and let you know.


Thanks
Tom
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Postby BRobinsonS » Sat Sep 29, 2007 6:52 am

Gaev,

Worked much better,

just had to add a ! on the ![Events.Date] to make it act as text.

SetVar "[Date1]" "![Events.Date]"
SetVar "[Time1]" "[Events.Mtime]"


tmAlarmEventsCreateUnique "Rectangle1" "[Sub]" "[Date1]" "[Time1]"
does seem to run through each queried record now, but seems to only play the last event.

Any Ideas??

Thanks very much.
Tom
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Postby BRobinsonS » Sat Sep 29, 2007 8:15 pm

I have cleaned up the code some, put still cannot seem to get more then one event set. If I place an alert box in the equation with the [Events.Date] and [Event.Mtime] variables, the loop steps through the right number of records and displays the correct info each time.


I am using this code for the loop:

dbfQuery "[PubDir]Events.bin" "Type=Once AND Enabled=Checked AND Day=[DayofWeek]"
dbfQueryCount "[PubDir]Events.bin" "[Count]"
dbfFirst "[PubDir]Events.bin"
Loop "1" "[Count]" "[loop]"
tmAlarmEventsCreate "Rectangle1" ""
tmAlarmEventsCreateUnique "Rectangle1" "1" "[Events.Date]" "[Events.Mtime]"
ClearVariables "[Events.Date],[Events.Mtime]"
dbfNext "[PubDir]Events.bin"
EndLoop

tmevents does not error now, but the following show up in the neobook debugger with red x next to them.

- tmAlarmEventsCreate "Rectangle1" ""
- tmAlarmEventsCreateUnique "Rectangle1" "1" "[Events.Date]" "[Events.Mtime]"
- ClearVariables "[Events.Date],[Events.Mtime]"
- dbfNext "[PubDir]Events.bin"


Anyone have any suggestions?

Thanks in advance for any help or suggestions.
Tom
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Postby Gaev » Sun Sep 30, 2007 6:09 am

Tom:
... still cannot seem to get more then one event set. If I place an alert box in the equation with the [Events.Date] and [Event.Mtime] variables, the loop steps through the right number of records and displays the correct info each time.

You do not show where you placed the AlertBox so I am not completely sure about what is happening but I am guessing that the problem is with the ClearVariables command.

tmevents does not error now, but the following show up in the neobook debugger with red x next to them.

The red x next to a command indicates that a command was not executed due to a previously specified condition ... you see this most often in an If/Else/EndIf type of block ... but also in a Loop/EndLoop or While/EndWhile block.

This will show in your example when the value of [loop] is larger than [count] ... so it would be a good idea to wrap your Loop/EndLoop block inside an If/EndIf block anyway ... in case the query resulted in no matching records.

ClearVariables was designed to be used with regular variables ... I am not sure what would happen when you specify names that are really database fields ... it might end up blanking out the date and time fields in the database record ... but perhaps it is ignoring these non-fields ... and since there are no real variables, it might be interpreting this as the same as Clearvariables "" ... which causes ALL variables (including [count] and [loop]) to be cleared ... which in turn causes the iterations of the Loop/EndLoop block to be terminated.

If you want to clear the database fields after the call to the plugin, just do ...
Code: Select all
SetVar "[Events.Date]" ""
SetVar "[Events.MTime]" ""

... instead of the ClearVariables command.
User avatar
Gaev
 
Posts: 3735
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby BRobinsonS » Sun Sep 30, 2007 6:57 am

Hi Gaev,

Thanks for the reply.

I had the alert box in place of:

tmAlarmEventsCreate "Rectangle1" ""
tmAlarmEventsCreateUnique "Rectangle1" "1" "[Events.Date]" "[Events.Mtime]"


The clearvariables I just thew in to see if that helped.


Maybe now knowing what the red x might be caused from I can track it down.


Thanks
Tom
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Postby Gaev » Sun Sep 30, 2007 11:11 am

Tom:

Try this first ... to ensure that you are finding the matching records and accessing them one at a time ...
Code: Select all
dbfQuery "[PubDir]Events.bin" "Type=Once AND Enabled=Checked AND Day=[DayofWeek]"
dbfQueryCount "[PubDir]Events.bin" "[Count]"
If "[Count]" ">" "0"
   dbfFirst "[PubDir]Events.bin"
   Loop "1" "[Count]" "[loop]"
      AlertBox "Hello ..." "[loop] of [count]|[Events.Date] ... [Events.Mtime]"
      dbfNext "[PubDir]Events.bin"
   EndLoop
Else
   AlertBox "hey you ..." "No matching records"
EndIf


Then insert the plugin commands before the inner AlertBox command ... and perhaps add the name of the variable where the plugin command's response is returned.
User avatar
Gaev
 
Posts: 3735
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron