Chip was asking about testing if a set exists or not and put in a feature
request related to this subject. (I voted for it.)

I was just consolidating some old code and ran across something that I
wrote some time back called Set_Exists. No clue. It seems to work, but I
can't say why.

C_BOOLEAN($0;$exists)
C_TEXT($1;$set_name)

$set_name:=$1

Error:=0

ErrorHandler_Install ("ErrorHandler_SuppressError")

C_BOOLEAN($is_in_set)
$is_in_set:=Is in set($set_name)

ErrorHandler_InstallPrevious

$exists:=Error=0  // You could test for error 39 to be a bit more specific.

$0:=$exists

Here's a little routine I wrote to try it out:

ALL RECORDS([Cart])
CREATE SET([Cart];"Cart_All")
REDUCE SELECTION([Cart];0)
UNLOAD RECORD([Cart])

$this_returns_true_correctly:=Set_Exists ("Cart_All")

$this_returns_false_correctly:=Set_Exists ("Foo")

Obviously, you would need to use a table name that exists in your structure
to check this out.

Can anyone confirm/deny that this code is reliable? Seriously, I have no
memory of writing this...Not that unusual for me, frankly...I tend to punch
out reams of code/writing and don't always look back.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to