Showing results 1 to 7 of 7

Thread: Add In read/write Project Properties

  1. #1
    Join Date
    02.02.2022
    Posts
    26

    Default Add In read/write Project Properties

    Hi! 
    I am scripting in C# to read for example the "Minimum password length" for starters.
    The idea is to be able to modify this and other parameters in runtime.

    the code I use:

    IProject context;
    context.VariableCollection["Debug1"].SetValue(0, Convert.ToInt32(context.GetDynamicProperty("MinPwLength")));

    Were I am writing the value of the property to a debug variable to show in runtime.

    Not working nevertheless.

     Thanks in advanced!!

  2. #2
    Join Date
    03.11.2015
    Posts
    48

    Default Re: Add In read/write Project Properties

    have you tried using a 'double'?

    For starters: you are trying to do three steps in one go:
     1: reading a dynamic property
     2: converting it 
     3: writing it to a variable

    How about giving yourself some time and do this step by step. maybe the debugger (or a try-catch) can show you the exception which leads to a solution.



     

  3. #3
    Join Date
    02.02.2022
    Posts
    26

    Default Re: Add In read/write Project Properties

    Hi C.F.,

    I have tried to separate the code to debug it better as you said.
    The result is that the  Convert.ToInt32(context.GetDynamicProperty("MinPwLength")); returns 0 and in the project it is set as 4. 
    Not sure if the path is not correct as the GetDynamicProperty gets the path via String and compiles with no error.




    Thanks for your time,
    Attached Thumbnails Attached Thumbnails Captura.PNG   Captura4.PNG  

  4. #4
    Join Date
    02.02.2022
    Posts
    26

    Default Re: Add In read/write Project Properties

    Hi,

    I have just tried with double and same output.

    Thanks

  5. #5
    Join Date
    02.02.2022
    Posts
    26

    Default Re: Add In read/write Project Properties

    Hi!

    Update, the function doesn`t return 0. Returns NULL, but the Convert.Int32() method converts NULL to 0.
    So I Guess that the path used to read the variable is not working.
    I have tried with other project properties and I get the same output.

    Thanks in advanced,

  6. #6
    Join Date
    03.11.2015
    Posts
    48

    Default Re: Add In read/write Project Properties

    Hi,

    exactly!
    This is what I meant by doing it step by step: get the dynamic property. check it for null. if not null, try to convert, and so on....

    The dynamic property is not available in the Service Engine.
    It is only readable in the Engineering Studio.

    You can find out, if a dynamic property is available by calling the 'GetDynamicProperties("")' method using an empty string as filter. This returns all available dynamic properties.

    Click image for larger version

Name:	Screenshot 2022-04-12 100011.jpg
Views:	5
Size:	96.0 KB
ID:	3236

     

  7. #7
    Join Date
    02.02.2022
    Posts
    26

    Default Re: Add In read/write Project Properties

    Thanks for the follow up!

Similar Threads

  1. Read/Write a single bit in a Byte/Word ?
    By EdgyUsername in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 3
    Last Post: 14th September 2016, 17:10
  2. Read and write variables from plc with VBA
    By cibertoni in forum VBA
    Replies: 1
    Last Post: 22nd September 2014, 16:36
  3. Replies: 2
    Last Post: 22nd September 2011, 01:32
  4. Replies: 12
    Last Post: 25th November 2010, 10:54

Tags for this Thread

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •