Conditional Action "Standalone Statement Cannot be used" error

I don’t understand why i am getting this in sdk conditional Action part i have included code in try part but is showing this error “Action cannot be used as a stand alone statement” can somebody help me with this?

Can you share your code?

using System;
using Robin.Core;
using Robin.Core.Attributes;
using System.Net;
using System.Windows.Automation;
using System.Windows.Automation.Text;

namespace CustomSampleModule
{
[ConditionAction(ResultPropertyName = nameof(Result))]
[Throws(“ActionError”)] // TODO: change error name (or delete if not needed)
public class ConditionAction2 : ActionBase
{
public bool Value { get; set; }
#region Properties

    public bool Result { get; private set; }

    [InputArgument]
    public string InputArgument1 { get; set; }

    [OutputArgument]
    public bool OutputArgument1 { get; set; }

    #endregion

    #region Methods Overrides



    public override void Execute(ActionContext context)
    {
        try
        {

            if (System.IO.File.Exists(InputArgument1))
            {
                Value = true;
                
                
            }
            else
            {
                Value = false;
                
            }
            // Add a user agent header in case the 
            // requested URI contains a query.


            //TODO: add action execution code here
        }
        catch (Exception e)
        {
            throw new ActionException("ActionError", e.Message, e.InnerException); // TODO: change error name (or delete if not needed)
        }

        // TODO: set values to Output Arguments and Result here
        // Result = ...
        OutputArgument1 = Value;
        Result = Value;
        // OutputArgument1 = ...
    }

    #endregion
}

}

I have added this small code to test but i am getting "Action cannot be used as a stand alone statement " this error. @Skip @jpap help me out?

Are you perhaps trying to run it from VS?

I would suggest having a look at the official documentation first:
https://robin-language.org/docs/extending-robin-using-the-sdk/

I have write this code on vs and copy its dll file in robin file and run it in robin as shown in documentation after that i am getting this error! @Skip @jpap

@abhi1100, please try this code. I believe your output argument and the result need to go in the ‘Try’ block. Untested code.

using System;
using Robin.Core;
using Robin.Core.Attributes;
using System.Net;
using System.Windows.Automation;
using System.Windows.Automation.Text;

namespace CustomSampleModule
{
[ConditionAction(ResultPropertyName = nameof(Result))]
[Throws(“ActionError”)] // TODO: change error name (or delete if not needed)
public class ConditionAction2 : ActionBase
{
public bool Value { get; set; }
#region Properties

    public bool Result { get; private set; }

    [InputArgument]
    public string InputArgument1 { get; set; }

    [OutputArgument]
    public bool OutputArgument1 { get; set; }

    #endregion

    #region Methods Overrides



    public override void Execute(ActionContext context)
    {
        try
        {

            if (System.IO.File.Exists(InputArgument1))
            {
                Value = true;              
            }
            else
            {
                Value = false;
            }
            // Add a user agent header in case the 
            // requested URI contains a query.

            OutputArgument1 = Value;
            Result = Value;
            //TODO: add action execution code here
        }
        catch (Exception e)
        {
            throw new ActionException("ActionError", e.Message, e.InnerException); // TODO: change error name (or delete if not needed)
        }

        // TODO: set values to Output Arguments and Result here
        // Result = ...
        

        // OutputArgument1 = ...
    }

    #endregion
}

}

Regards,
burque505

1 Like

@abhi1100 welcome to our community.

Please use @burque505’s solution.
You hadn’t declared anywhere “Value” variable, so syntax-wise there is an error.
Did Visual Studio build the solution?
The compiler should produce an error.

Best regards,
J.

1 Like

sir i have declared “Value” above and there is no error shown in Visual studio My error is Solved it was because of Resultproperty name statement on the top of code.
Thank you for your Help. @jpap

2 Likes

Thanks for your Help! I got my Output. @burque505

2 Likes