Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

Conditional Comparison Plugin...

Place your requests for plugins here

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo

Post Reply
Jaken Veina
Posts: 1
Joined: February 4th, 2010, 2:29 am

Conditional Comparison Plugin...

Post by Jaken Veina »

A useful plugin I find myself wanting, and am surprised has not yet been done. Inline Boolean comparisons.

$dll(compare, func, x, y)
func 1: (x == y)
func 2: (x != y)
func 3: (x < y)
func 4: (x <= y)
func 5: (x > y)
func 6: (x >= y)

The following code was modified from krisp's "if" plugin and ought to do it, but I'm not sure if I have the means to compile it myself, and I don't have the free time to try at the moment. Someone else who already knows how should be able to get it to compile pretty easily. It'd be greatly appreciated.

Code: Select all

using System;

namespace @compare
 {
  public class LCDSmartie
   {
    // Equality comparison
    public int function1(int x, int y)
     {
      try
       {
        if(x == y)
         return 1;
        else
         return 0;
       }
      catch (Exception e)
       {
        return e.ToString();
       }
     }
    // inequality comparison
    public int function2(int x, int y)
     {
      try
       {
        if(x != y)
         return 1;
        else
         return 0;
       }
      catch (Exception e)
       {
        return e.ToString();
       }
     }
    // Less than comparison
    public int function1(int x, int y)
     {
      try
       {
        if(x < y)
         return 1;
        else
         return 0;
       }
      catch (Exception e)
       {
        return e.ToString();
       }
     }
    // Less than or Equal comparison
    public int function1(int x, int y)
     {
      try
       {
        if(x <= y)
         return 1;
        else
         return 0;
       }
      catch (Exception e)
       {
        return e.ToString();
       }
     }
    // Greater than comparison
    public int function1(int x, int y)
     {
      try
       {
        if(x > y)
         return 1;
        else
         return 0;
       }
      catch (Exception e)
       {
        return e.ToString();
       }
     }
    // Greater than or Equal comparison
    public int function1(int x, int y)
     {
      try
       {
        if(x >= y)
         return 1;
        else
         return 0;
       }
      catch (Exception e)
       {
        return e.ToString();
       }
     }
   }
 }
Thanks in advance!

~ Jake

Post Reply