Example Code

Secret Santa App

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW
  • LabVIEW Communications

Code and Documents

Attachment

Overview

This example application can be used to generate a randomized pairing from a list of names for Secret Santa!  The programs prevents you from getting yourself, allows you to put exceptions in so relatives and spouses don't get each other, and the list can be sent via GMail, so the creator doesn't have to know everyones match.

 

Description 

The source code uses the GMail API available in the NI Community to accomplish the emailing. The API is not needed to run the executable, but should be downloaded first if you would like to view and use the source code. The VI creates a random list, matching against duplicates and the exception list, and then emails the match to each recipient, the recipients do not need a GMail account. The exception list is an array of pairs that are entered with combo boxes populated by the main list, so you can select the two names that shouldn't be paired. There is also a second mode of the code if you do not have a GMail account or if you don't want to include your email and password.  In order to use this portion of the code you must rebuild from the source code because the .exe window can not be resized.  In the source code you will be able to expand the Front Panel in order to "Debug" the code and avoid sending emails and using a GMail account.

 

Requirements

 

Steps to Implement or Execute Code

  1. Extract the SecertSantaApp_exe.zip.
  2. Open the "SeceretSantaApp.exe".
  3. Click the Clear the List! to with a fresh sheet.
  4. Add the names and emails of those that would like to participate in the Secret Santa (FYI: The emails do not need to be GMail)\.
  5. If you have more people than the list can hold right click in the box and select "Insert Element Before".
  6. Options: Add your GMail Account and Password(FYI: The password is not securely typed and can be accessed in a normal text display from the VI, it will also be sent to the web as plain text).
    • This is where you add exceptions; select a name in the left column and the person they shouldn't be matched with in the second column.
    • Then click OK

  7. Select Send the List! and all the participants will be sent an email from your GMail account with their Secret Santa Results.

 

Additional Information or References 

Front Pane

secretsantaapp_debug.png

 

VI Snippet

Secret Santa Block Diagram

137.png

SubVI Find Pairs

SubVI Find Pairs.png

SubVI Send the List

SubVI Broadcast List.png

 

If you receive Error -1172 then make sure you have entered a valid GMail Username and Password in Options

 

Setting up the Application without GMail (no emails will be sent)

  1. Download the GMail API.
  2. Download and Extract the SecretSantaApp_source.zip.
    • Save the files where you installed GMail API
  3. Open the SecretSantaApp.vi and expand the Front Panel Window to include the Debug List.
  4. Either rebuild the Application for an executable or run from the VI.
  5. Select the Debug OFF/ON Button so it is on.
  6. Now follow the steps for Running the Executable (either way).
  7. You do not need to add a GMail Account.
  8. The Secret Santa Pairings will appear in the Table verses being emailed out.

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.