How to clean/reset several or multiple variables in one time ?

cherubin

Client
Регистрация
06.06.2016
Сообщения
92
Благодарностей
6
Баллы
8
Hi,

I would like to clean my own variables at the begining of the template, and do that each time to have a clean fresh start.
I know how to do it with variable processing snippet, but when you have dozen of variables it's not optimized.
So, does it exist a "master option" to clean them all ?

I think with C# it could be possible (even deleting), but i'm not a dev/coder so it's not easy to me for now to understand the doc without a small example.

Someone would have a solution to reset for example the following variables : "color", "size", "origin", "price" with the fewest steps ? (Then we could add it to the LighWood C# thread)

Thanks
 

mta

Client
Регистрация
12.01.2020
Сообщения
129
Благодарностей
7
Баллы
18
Hello,
At the end of your template i would add a variable processing and set value to 0. For each Variable.

50846
 

LightWood

Moderator
Регистрация
04.11.2010
Сообщения
2 382
Благодарностей
917
Баллы
113
Hi,

I would like to clean my own variables at the begining of the template, and do that each time to have a clean fresh start.
I know how to do it with variable processing snippet, but when you have dozen of variables it's not optimized.
So, does it exist a "master option" to clean them all ?

I think with C# it could be possible (even deleting), but i'm not a dev/coder so it's not easy to me for now to understand the doc without a small example.

Someone would have a solution to reset for example the following variables : "color", "size", "origin", "price" with the fewest steps ? (Then we could add it to the LighWood C# thread)

Thanks
C#:
foreach(string key in project.Variables.Keys)
    project.Variables[key].Value = string.Empty;
I think this code will help you
 

cherubin

Client
Регистрация
06.06.2016
Сообщения
92
Благодарностей
6
Баллы
8
Hi,

@mta yes, that's i used until now but when you have 50 variables to reset it's not optimal.

Thanks @LightWood i will try it and your other solution too :

C#:
project.Variables["NameHere1"].Value = "";
project.Variables["NameHere2"].Value = "";
project.Variables["NameHere3"].Value = "";
 

morpheus93

Client
Регистрация
25.01.2012
Сообщения
1 058
Благодарностей
244
Баллы
63

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)