For begginers - making own snippets

aleksa77

Client
Регистрация
30.09.2011
Сообщения
914
Благодарностей
90
Баллы
28
I want to share something, this info, if I had known this, my life would have been easier at the beginning of Zenno.

For different kinds of templates, you need some snippets right, and usually, you search on the forum or need to pay to develop.
Today all codes are on the internet, someone asks on stack over forums, or you have it in documentation in Microsoft.


Ok, for example, you have date

Jan 1, 2009

and need to make snippet to convert for date

1/1/2009

When you ask google

" C# convert date"

you will get this page, for example



ok, we now have the code from this page

C#:
string dateInput = "Jan 1, 2009";
var parsedDate = DateTime.Parse(dateInput);
Console.WriteLine(parsedDate);
// Displays the following output on a system whose culture is en-US:
//       1/1/2009 00:00:00
To convert C# into zenno snippet there is only several rules, first, to make variable

first line will be

string dateInput = project.Variables["date"].Value;

and second, we need to make return option and instead of

Console.WriteLine(parsedDate);

it will be

return parsedDate;

and now, our snippet will be

C#:
string dateInput = project.Variables["date"].Value;
var parsedDate = DateTime.Parse(dateInput);
return parsedDate;
// Displays the following output on a system whose culture is en-US:
//       1/1/2009 00:00:00
For someone who does not know or do not want to learn C#, just right google search keywords, convert variable and give return exit and all snippets are here for you.
 

aleksa77

Client
Регистрация
30.09.2011
Сообщения
914
Благодарностей
90
Баллы
28
Snippets exist and for javascript, the main difference with C# and javascript - C# is core windows language and if you need to manipulate with windows, files on PC it is ultimate, but everything else you can find and snippets for javascript and it is beautiful because you can choose both, on the similar way for example

I need for the current project, take first 4 characters from a string, and after googling:

"javascript - Extract characters from a string "

I get this code from page:

JavaScript:
var str = "Hello world!";
var res = str.substring(0, 4);
and now, our snippet for zenno will be:

JavaScript:
var str = '{-Variable.Text-}';
var res = str.substring(0, 4);
and exit return will be

"Hell"

For beginners, exist and snippets for batch , it is maybe and more easiest language, just googled " my problem - batch file" and you can make
bat file with action in Zenno " write text" put batch code into file .bat, and then execute with option " run program" ( path to bat file ).

Working with bat files- it is an alternative for C# snippets, in my work, some snippets were easier for bat, and you can mixing.
 
Последнее редактирование:
  • Спасибо
Реакции: wildjack и Aronax

wildjack

Client
Регистрация
19.07.2013
Сообщения
93
Благодарностей
8
Баллы
8
you're great
 
  • Спасибо
Реакции: aleksa77

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