Adding and removing facts one at a time
u: (add)
@0 = ^query( direct_sv "Dutch Royal Archives" "Lord of the Rings")
if (@0)
{
$qty = first(@0object) + 1
^delete(@0)
^createfact( "Dutch Royal Archives" "Lord of the Rings" $qty)
$qty books in archive
}
else
{
^createfact( "Dutch Royal Archives" "Lord of the Rings" 1)
1 book in archive
}
u: ("remove xxx")
@0 = ^query( direct_sv "Dutch Royal Archives" "Lord of the Rings")
if (@0)
{
$qty = first(@0object) - 1
if ($qty >= 0)
{
^delete(@0)
^createfact( "Dutch Royal Archives" "Lord of the Rings" $qty)
$qty books in archive xxx
}
else
{
No book to remove.
}
}
else
{
No book to remove.
}
u: (book 1)
@0 = ^query( direct_sv "Dutch Royal Archives" "Lord of the Rings")
if (!@0) {We have no copies.}
else {We have @0object copies.}