First I have to get some more logical errors out of my code. The below is 
cleaned up.



C_BOOLEAN($0;$setDoesExist)
C_TEXT($1;$setName)
C_BOOLEAN($testInSet)
C_LONGINT($numInSet)

$setName:=$1

$numInSet:=Records in set($setName)

If ($numInSet>0)
        $setDoesExist:=True
Else 
        
          // two possibilities
          // 1. set does not exist
          // 2. set exists but has no records
        
          // logic: The documentation says: // ADD TO SET ( {aTable ;} set ) … 
ADD TO SET adds the current record of aTable to set. The set must already 
exist; if it does not, an error occurs.
          // if the set does not exist, I will get an error.
          // if it does exist then I will NOT get an error but it is safe 
because I will not have changed the state of anything since adding zero records 
to an existing set does nothing.
        fErrorHappened:=False  // this is a process variable that is created at 
startup
        ON ERR CALL("ErrorIgnore")  // ErrorIgnore is a method that sets 
fErrorHappened to true
        ADD TO SET($setName)  // if the set does not exist, this will throw an 
error. This particular "Set" command is sensitive as to whether the set exists
        ON ERR CALL("")
        
        If (fErrorHappened)
                $setDoesExist:=False
        Else 
                $setDoesExist:=True
        End if 
        
        
End if 

$0:=$setDoesExist


> On Jul 17, 2017, at 1:07 AM, Julio Carneiro via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Just out of curiosity, what happens if there is no current record to add to 
> the set?
> - do you get an error, which might only indicate no record exists to add to 
> an existing set?
> - nothing happens, even if set does not exist?



I am doing the testing in a simple interpreted environment. No server etc.

If there is an empty current selection then the code (interpreted) correctly 
determines whether the set exists or does not exist.

If there is a multi-record current selection but the current record does not 
exist than the code (interpreted) correctly determines whether the set exists 
or does not exist.
**********************************************************************
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