Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Variable does not exist in the current context

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Variable does not exist in the current context

    The error is:
    Code:
     [TABLE]
    [TR]
    NinjaScript File 			Error 			Code 			Line 			Column 		[/TR]
    [TR]
    [TD]CustomRender16.cs[/TD]
     			[TD]The name 'sj' does not exist in the current context[/TD]
     			[TD]CS0103[/TD]
     			[TD]398[/TD]
     			[TD]14[/TD]
     		[/TR]
    [/TABLE]

    Here is my code:

    Code:
    public class General{
        public bool noWeighting;            
    }
    
    public class Symbol :General {
    
            public Symbol(double weight){
                  Weight = weight;
            }
            public double Weight {
                   get{
                       if(base.noWeighting == true){
                           return 100;
                       }
                       else{
                           return value;
                       }    
                   }
                   set{ Weight = value;}
               }
    }
    
    protected override void OnStateChange(){
        if (State == State.SetDefaults) {
            General sj = new General();
            sj.noWeighting = false; 
            Symbol spy = new Symbol(15.25);       
        }
    }
    
    [Display(Name = "No Weighting", Order = 0, GroupName = "General Settings")]
      public bool NoWeighting{
        get {
          return sj.noWeighting;    //I am getting the error at this line
        }
        set{sj.noWeighting = value;}      //and another error at this line
      }

    #2
    Hello swooke,

    Thanks for your post.

    These sorts of questions referring to custom C# implementations begin to escape the scope of support we provide with NinjaScript.

    The error is letting you know that the object you are referencing does not exist in the context in which you are referencing. To look into this sort of issue the following questions should be asked:
    1. What scope are you trying to access this object?
    2. What scope have you created this object?
    3. Have you tried declaring this object at class level?
    Please let us know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X