project.Variables are all string, how to declare it as int?

  • Автор темы Автор темы bluescharp
  • Дата начала Дата начала

bluescharp

Client
Регистрация
20.06.2012
Сообщения
35
Реакции
1
Баллы
8
em... I have a variable in project, and I want to change it with some C# code, then use it in project.
but I can't set project.Variables["heartbeat"].Value = -1;
because project.Variables["heartbeat"] is a string. how to declare it as int?
 
Convert.ToInt32(project.Variables["heartbeat"].Value);
 
JavaScript:
Развернуть Свернуть Копировать
string cSharpVariable = project.Variables["heartbeat"].Value;
int numeric = Convert.ToInt32(cSharpVariable);
return numeric;
 
Последнее редактирование:
Hi, and could we convert the string to int in "classic zenno" and not for a C# template ? In order to record integer in a table for example
 
Hi, and could we convert the string to int in "classic zenno" and not for a C# template ? In order to record integer in a table for example
Numbers are automatically int. In classic way, you do not handle variable types. It's all var
You record number in the table and thats number.
What issues do you have?
 
I parse a bad formated json file ( i posted here about it https://zennolab.com/discussion/thr...o-properties-json-to-table.63292/#post-451880 ) However i succeed to deal with but the data parsed are some time like this :

Код:
Развернуть Свернуть Копировать
0.50031072108822885E1
0,45786
3.45784

So i replace some text in order to have only one format which is : (int)(comma)(int)(int)(int) like 0,457
Then i record in a table which saves in a xlsx file.

So everything work great, but when i oopenb the xlsx file it's text in cell instead of number/integer.

upload_2019-8-30_18-53-17.png
 
To work with excel an turn it in numbers you must use excel interop with c# code to convert that columns from text to numbers.
 
Hi,

So how to do that ? I never use C# module/code.
I just need to put the following code :
Код:
Развернуть Свернуть Копировать
Convert.ToInt32(project.Variables["{-Var.Name-}"].Value);

in c# and then record in excel ?
 
int i = int.Parse(project.Variables["vari"].value;
int j = int.Parse(project.Variables["varj"].value;
int k = i * j;
project.Variables["vark"].Value = k.ToString();
 

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