David,
I wrote a complete collection of set operation routines
here : 
https://www.dropbox.com/s/075k0ap7afervs8/Sets_Component_v1.0.zip?dl=0

Distributed as shareware $15 ($35 for source & a suite testing 
routines), it is a compiled/built component created in v13. If you like 
it you are free to reuse/distribute etc.

it includes a method to test if the set exists, and does not require 
error handlers.

On Sat, 15 Jul 2017 10:10:21 +1000, David Adams via 4D_Tech wrote:
> 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
> **********************************************************************
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**********************************************************************
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