Date Math Error

Forum about Domotiga Open Source Home Automation for Linux.

Moderator: RDNZL

Post Reply
tradiuz
Starting Member
Starting Member
Posts: 8
Joined: Fri Mar 30, 2012 3:38 pm

Date Math Error

Post by tradiuz »

When trying to enter the following as a condition, I get a syntax error when I try to Eval, and the editor will not let me save, saying to enter a boolean expression.

Code: Select all

DateDiff(Dev_15_LastChanged,Now(), gb.Minute) > 15

From the Gambas wiki on DateDiff:

Code: Select all

Count = DateDiff ( Date1 AS Date , Date2 AS Date , Period AS Integer ) AS Integer
That would lead me to beleive that DateDiff returns an integer. And IsInteger(DateDiff(Dev_15_LastChanged,Now(), gb.Minute)) will return TRUE. Leaving off the "> 15" makes the Eval work, but since it's not a Boolean expression, it kicks it back when you try and save. I've also noticed that anything at all with DateAdd() fails. Is this a Gambas related issue? I'm using version 2.23 that is packaged for Ubuntu.

apt-cache show gambas2:

Code: Select all

root@hal:~# apt-cache show gambas2
Package: gambas2
Priority: optional
Section: universe/devel
Installed-Size: 127
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: José L. Redrejo Rodríguez <jredrejo@debian.org>
Architecture: amd64
Version: 2.23.1-1ubuntu3
Depends: gambas2-doc (>= 2.23.1-1ubuntu3), gambas2-gb-chart (>= 2.23.1-1ubuntu3), gambas2-gb-compress-bzlib2 (>= 2.23.1-1ubuntu3), gambas2-gb-compress-zlib (>= 2.23.1-1ubuntu3), gambas2-gb-crypt (>= 2.23.1-1ubuntu3), gambas2-gb-db-firebird (>= 2.23.1-1ubuntu3), gambas2-gb-db-form (>= 2.23.1-1ubuntu3), gambas2-gb-db-mysql (>= 2.23.1-1ubuntu3), gambas2-gb-db-postgresql (>= 2.23.1-1ubuntu3), gambas2-gb-db-odbc (>= 2.23.1-1ubuntu3), gambas2-gb-db-sqlite3 (>= 2.23.1-1ubuntu3) | gambas2-gb-db-sqlite2 (>= 2.23.1-1ubuntu3), gambas2-gb-desktop (>= 2.23.1-1ubuntu3), gambas2-gb-form (>= 2.23.1-1ubuntu3), gambas2-gb-form-dialog (>= 2.23.1-1ubuntu3), gambas2-gb-form-mdi (>= 2.23.1-1ubuntu3), gambas2-gb-gtk-ext (>= 2.23.1-1ubuntu3), gambas2-gb-gtk-svg (>= 2.23.1-1ubuntu3), gambas2-gb-gui (>= 2.23.1-1ubuntu3), gambas2-gb-image (>= 2.23.1-1ubuntu3), gambas2-gb-info (>= 2.23.1-1ubuntu3), gambas2-gb-net-curl (>= 2.23.1-1ubuntu3), gambas2-gb-net-smtp (>= 2.23.1-1ubuntu3), gambas2-gb-opengl (>= 2.23.1-1ubuntu3), gambas2-gb-pcre (>= 2.23.1-1ubuntu3), gambas2-gb-pdf (>= 2.23.1-1ubuntu3), gambas2-gb-qt-ext (>= 2.23.1-1ubuntu3), gambas2-gb-qt-opengl, gambas2-gb-report (>= 2.23.1-1ubuntu3), gambas2-gb-sdl-sound (>= 2.23.1-1ubuntu3), gambas2-gb-settings (>= 2.23.1-1ubuntu3), gambas2-gb-vb, gambas2-gb-web, gambas2-gb-xml-rpc (>= 2.23.1-1ubuntu3), gambas2-gb-xml-xslt (>= 2.23.1-1ubuntu3), gambas2-ide (>= 2.23.1-1ubuntu3)
Filename: pool/universe/g/gambas2/gambas2_2.23.1-1ubuntu3_amd64.deb
Size: 2232
MD5sum: e7874e3a5ceecd44e70a395deefa6318
SHA1: 0bbe9f0495688d747a214243c22f02df1c3ec291
SHA256: e12700e82085ebfda70a93eb36d54cb8493467e7542b28ffe4d8659bcb234f57
Description-en: Complete visual development environment for Gambas
 Gambas is a programming language based on a BASIC interpreter with
 object extensions - like Visual Basic, though it is NOT a clone!
 It has many components for developing internationalized,
 desktop-independent, database- and network-enabled applications.
 Even games can be developed very quickly using its RAD environment.
 .
 This package doesn't include anything: it is a metapackage to install the
 IDE and all the available gambas components..
Homepage: http://gambas.sourceforge.net
Description-md5: 98341e4b1e6b0b5bc6ccec229310498f
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
tradiuz
Starting Member
Starting Member
Posts: 8
Joined: Fri Mar 30, 2012 3:38 pm

Re: Date Math Error

Post by tradiuz »

I think I found a workaround:

Code: Select all

Now - Dev_1_LastChanged - Time (0,"10",0) > 0
This will check to see if Dev1 has changed in the last 10 minutes. If you change the 0 to ANYTHING else, it throws a syntax error.

Hopefully this helps anyone else trying to do motion based triggers for lights that wants the lights to stay on as long as there is motion.


Now, back to breaking my version on DomotiGa in new and interesting ways.
Post Reply

Return to “DomotiGa Forum”