<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: хитрости/особенности]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6264&amp;type=atom" />
	<updated>2017-01-15T17:14:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6264</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111095#p111095" />
			<content type="html"><![CDATA[<p>Решил добавить сюда. Это не заготовка полезного инструмента, а только &quot;сэмпл&quot; ещё одного использования вложенных вызовов.<br /></p><div class="codebox"><pre><code>
Option Explicit

&#039;Sample 1
MsgBox New [$].add(&quot;[&quot;).add(&quot;      no spaces      &quot;).trim.add(&quot;]&quot;)

&#039;Sample 2
MsgBox New [$].add(&quot;      test [1] [2] [3]&quot;).replace(&quot;/\d/g&quot;,&quot;!&quot;).replace(&quot;/test/gi&quot;,&quot;-&gt;&quot;).trim

&#039;Sample 3
MsgBox New [$].add(&quot;     IT WAS UPCASE TEXT WITH SPACES &quot;) _
			  .trim() _
			  .toLowerCase() _
			  .add(&quot;    and lower case text&quot;) _
			  .toUpperCase()

Class [$]
	Dim [b$],[s$]

	Function toUpperCase()
		[b$] = UCase([b$])
		Set toUpperCase = Me
	End Function

	Function toLowerCase()
		[b$] = LCase([b$])
		Set toLowerCase = Me
	End Function

	Function trim()
		[b$] = re(&quot;/^\s+|\s+$/g&quot;).replace([b$],&quot;&quot;)
		Set [trim] = Me
	End Function
	
	Public Default Function text()
		text = [s$] &amp; [b$]
	End Function
	
	Function add(text)
		[s$] = [s$] &amp; [b$]
		[b$] = text
		Set add = Me
	End Function
	
	Function replace(pat, rep)
		[b$] = re(pat).replace([b$],rep)
		Set replace = Me
	End Function
	
	Function match(pat)
		Set match = re(pat).execute([b$])
	End Function
	
	Private Function re(pat)
		Set re = New RegExp
		re.Pattern = &quot;^\/(.+)\/([igm]*)$&quot;
		Dim matches: Set matches = re.Execute(pat)
		If matches.Count &lt; 1 Then re.Pattern = pat: Exit Function
		Set matches = matches(0).subMatches
		re.Pattern = matches(0)
		re.Global = InStr(1,matches(1),&quot;g&quot;,1)
		re.IgnoreCase = InStr(1,matches(1),&quot;i&quot;,1)
		re.MultiLine = InStr(1,matches(1),&quot;m&quot;,1)
	End Function
	
End Class
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2017-01-15T17:14:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111095#p111095</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=106468#p106468" />
			<content type="html"><![CDATA[<p>В рамках последнего обсуждения множественного вызова функции с двумя переменными ранее вертелась мысль избавления от сущностей, когда значением (или его частью) переменной может выступать имя самой переменной. Делается это простым присвоением через Execute:<br /></p><div class="codebox"><pre><code>Execute Var &amp; &quot;=&quot;&quot;Var&quot;&quot;&quot;</code></pre></div><p>Что это даёт? Ну, во-первых, в ряде случаев избавление от необходимости задействовать коллекцию или опять же вызывать процедуру/функцию для динамического присвоения (пример c GetRef см. ниже в одном и кодов).<br />Т.е. вместо того, чтобы придумывать переменные с присвоением им значений можно в цикле имплантировать значения в имена и там же обработать:</p><p><strong>Вот простой пример экономии. Привычное представление</strong><br /></p><div class="codebox"><pre><code>&#039; Запись в 139 символов:
C  = &quot; класс&quot;
C1 = &quot;1&quot; &amp; C
C2 = &quot;2&quot; &amp; C
C3 = &quot;3&quot; &amp; C
C4 = &quot;4&quot; &amp; C
C5 = &quot;5&quot; &amp; C
C6 = &quot;6&quot; &amp; C
C7 = &quot;7&quot; &amp; C
C8 = &quot;8&quot; &amp; C
C9 = &quot;9&quot; &amp; C</code></pre></div><p><strong>переводим в</strong><br /></p><div class="codebox"><pre><code>&#039; Запись в 59 символов (полный аналог предыдущего):
For i = 1 To 9: Execute &quot;C&quot; &amp; i &amp; &quot; = i &amp; &quot;&quot; класс&quot;&quot;&quot; :Next

&#039; Теперь у нас на руках все переменные C1-9 c данными. Т.е. их можно
&#039; сравнивать, обрабатывать, вставлять в текст, перетасовывать и т.п.
&#039; Пример:
MsgBox &quot;Маша пошла в &quot; &amp; C5 &amp; &quot;.&quot; &amp; vbCr &amp; _
&quot;Миша из &quot; &amp; C9 &amp; &quot;а решил сложную задачу по алгебре.&quot;</code></pre></div><p>Или, предположим, мы располагаем списком значений, входящих в группу некого свойства объекта.<br /><strong>Примеры:</strong><br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Возвращаем пути спецпапок по их именам:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
With CreateObject(&quot;WScript.Shell&quot;)
  For i = 0 To .SpecialFolders.Count - 1
  	Path = .SpecialFolders(i)
  	Execute Replace(FSO.GetFileName(Path), &quot; &quot;, &quot;&quot;) &amp; &quot; = Path&quot; 
  Next
End With
WScript.Echo &quot;делаем дела с папкой &quot; &amp; Fonts
WScript.Echo &quot;делаем дела с папкой &quot; &amp; SendTo</code></pre></div></div></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Выделяем из списка частоту процессора и оперативную память:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>Set Shell = CreateObject(&quot;Shell.Application&quot;)
GetVar(&quot;DirectoryServiceAvailable&quot;)(&quot;DoubleClickTime&quot;)(&quot;ProcessorLevel&quot;)_
  (&quot;ProcessorSpeed&quot;)(&quot;ProcessorArchitecture&quot;)(&quot;PhysicalMemoryInstalled&quot;)

MsgBox &quot;Частота процессора: &quot; &amp; vbTab &amp; ProcessorSpeed &amp; &quot; MHz&quot; &amp; vbCr &amp;_
     &quot;Физическая память: &quot; &amp; vbTab &amp; PhysicalMemoryInstalled &amp; &quot; байт(а)&quot;

Function GetVar(Var)
  Execute Var &amp; &quot;= Shell.GetSystemInformation(Var)&quot;
  Set GetVar = GetRef(&quot;GetVar&quot;)
End Function</code></pre></div></div></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Отобразим некоторые теги композиции:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>Set Track = CreateObject(&quot;WMPlayer.OCX&quot;)._
NewMedia(&quot;C:\Windows\winsxs\X80C99~1.163\SLEEPA~1.MP3&quot;)

For i = 0 To Track.AttributeCount - 1
	Attr = Track.GetAttributeName(i)
	Execute &quot;i&quot; &amp; Replace(Attr, &quot;WM/&quot;, &quot;&quot;) &amp; &quot;= Track.GetItemInfo(Attr)&quot;
Next

MsgBox  &quot;Номер: &quot;  &amp; vbTab &amp; iTrackNumber &amp; vbCr &amp; _
		&quot;Имя: &quot;    &amp; vbTab &amp; iTitle       &amp; vbCr &amp; _
		&quot;Альбом: &quot; &amp; vbTab &amp; iAlbumTitle  &amp; vbCr &amp; _
		&quot;Автор: &quot;  &amp; vbTab &amp; iAuthor      &amp; vbCr &amp; _
		&quot;Жанр: &quot;   &amp; vbTab &amp; iGenre       &amp; vbCr &amp; _
		&quot;Год: &quot;    &amp; vbTab &amp; iYear, 4160, &quot; MP3-теги&quot;</code></pre></div></div></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Выведем свойства фотографии:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>File = &quot;C:\Windows\winsxs\X828C9~1.163\RU-wp5.jpg&quot;

Set Img = WScript.CreateObject(&quot;WIA.ImageFile&quot;)
Img.LoadFile File

With Img.Properties
  For i = 1 To .Count
    FN = .Item(i).Name : If Not .Item(i).IsVector _
    And Not IsNumeric(FN) Then Execute FN &amp; &quot; = .Item(i).Value&quot;
  Next
End With

Sr = InStrRev(File, &quot;\&quot;) : FN = Mid(File, Sr + 1) : T = vbTab
Set Folder = CreateObject(&quot;Shell.Application&quot;).NameSpace(Left(File, Sr))
For Each P In Split(&quot;Name Directory DocTitle Owner Attributes &quot; &amp;_
                    &quot;Copyright Dimensions Type Create Write Access&quot;)
  Execute &quot;i&quot; &amp; P &amp; &quot; = Folder.ParseName(FN).ExtendedProperty(P)&quot;
Next

MsgBox &quot;Имя файла:&quot;      &amp; T &amp; iName       &amp; vbCr &amp; _
       &quot;Тип файла:&quot;      &amp; T &amp; iType       &amp; vbCr &amp; _
       &quot;Название:&quot;       &amp; T &amp; iDocTitle   &amp; vbCr &amp; _
       &quot;Разрешение:&quot;     &amp; T &amp; XResolution &amp; &quot; x &quot; &amp; YResolution &amp; &quot; dpi&quot; &amp; vbCr &amp; _
       &quot;Размер кадра:&quot;   &amp; T &amp; iDimensions &amp; &quot; пкс&quot; &amp; vbCr &amp; _
       &quot;Ширина кадра:&quot;   &amp; T &amp; ExifPixXDim &amp; &quot; пкс&quot; &amp; vbCr &amp; _
       &quot;Высота кадра:&quot;   &amp; T &amp; ExifPixYDim &amp; &quot; пкс&quot; &amp; vbCr &amp; _
       &quot;Дата съёмки:&quot;    &amp; T &amp; DateTime    &amp; vbCr &amp; _
       &quot;Дата создания:&quot;  &amp; T &amp; iAccess     &amp; vbCr &amp; _
       &quot;Дата изменения:&quot; &amp; T &amp; iCreate     &amp; vbCr &amp; _
       &quot;Автор съёмки:&quot;   &amp; T &amp; Artist      &amp; vbCr &amp; _
       &quot;Владелец:&quot;       &amp; T &amp; iOwner      &amp; vbCr &amp; _
       &quot;Автор. права:&quot;   &amp; T &amp; Copyright</code></pre></div></div></div><p>Приверженцу мелкомягкого эстетизма подобный подход в оптимизации может показаться радикальным и режущим глаз, но, полагаю, не я первый, кто горел желанием проделывать на VBS вещь, которая нативно вплетена в JS.<br />Буду рад, если кто оценит. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-07-30T05:08:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=106468#p106468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=99136#p99136" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong>, понял. Тогда наверное имеет смысл.</p>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2015-11-17T20:11:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=99136#p99136</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98938#p98938" />
			<content type="html"><![CDATA[<p><strong>Xameleon</strong><br />Ну, так очевидно, что в подобном случае Right(&quot;0&quot; &amp; DateT, 2) пришлось бы писать 5 раз вместо одного.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2015-11-11T20:42:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98938#p98938</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98936#p98936" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong></p><div class="quotebox"><blockquote><p>Оно! Спасибо! Плюс это решает проблему обрыва и необходимости повтора последнего вызова в цепочке.</p></blockquote></div><p>Wow. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Да не за что. Рад, что пригодилось. Посмотрел Ваш пример, но пока что не понял почему нельзя его было реализовать по аналогии с этой темой - <a href="http://forum.script-coding.com/viewtopic.php?pid=98891#p98891">VBS: Abby Finereader Bank 6.0. Выгрузка даты в dbf в формате ggggmmdd</a> ?</p>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2015-11-11T17:27:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98936#p98936</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98924#p98924" />
			<content type="html"><![CDATA[<p>Покажу на простом примере:<br /></p><div class="codebox"><pre><code>&#039; Есть некая дата в неподходящем формате (файла, например)
FDate = &quot;5/5/5 5:5:5&quot;

Dy = Day(FDate)  : Mh = Month(FDate)  : Yr = Year(FDate)
Hr = Hour(FDate) : Mn = Minute(FDate) : Sc = Second(FDate)

&#039; Запишем в переменную дату 1-го преобразования
NDate = ReDate(FDate)

&#039; Вызовем функцию 2-го преобразования
Call AddNull(Dy)(Mh)(Hr)(Mn)(Sc)

&#039; Покажем разницу
MsgBox  &quot;До преобразований:&quot; &amp; vbTab &amp; FDate &amp;_
vbCr &amp; &quot;1-е преобразование:&quot; &amp; vbTab &amp; NDate &amp;_
vbCr &amp; &quot;2-е преобразование:&quot; &amp; vbTab &amp; ReDate(FDate)

Function AddNull(DateT)
  DateT = Right(&quot;0&quot; &amp; DateT, 2)
  Set AddNull = GetRef(&quot;AddNull&quot;)
End Function

Function ReDate(FDate)
  ReDate = Dy &amp; &quot;.&quot; &amp; Mh &amp; &quot;.&quot; &amp; Yr &amp; &quot; &quot; &amp; Hr &amp; &quot;:&quot; &amp; Mn &amp; &quot;:&quot; &amp; Sc
End Function</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2015-11-11T12:38:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98924#p98924</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98919#p98919" />
			<content type="html"><![CDATA[<p>Замечательно! В свое время для меня это было просто игра, проверка воможностей активно используемых в других языках.</p>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2015-11-11T09:57:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98919#p98919</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98918#p98918" />
			<content type="html"><![CDATA[<p><strong>Rumata</strong>, да, хватало таких задач.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2015-11-11T09:53:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98918#p98918</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98917#p98917" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong>, Вам попалась задача, где цепочки вызовов в VBS пригодились?</p>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2015-11-11T09:52:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98917#p98917</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98914#p98914" />
			<content type="html"><![CDATA[<p><strong>Xameleon</strong><br />Оно! Спасибо! Плюс это решает проблему обрыва и необходимости повтора последнего вызова в цепочке.<br />И, полагаю, имеет смысл в ряде случаев применять CPS вместо цикла в цикле. <a href="https://ru.wikipedia.org/wiki/%D0%9F%D1%80%D0%BE%D0%B4%D0%BE%D0%BB%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5_(%D0%B8%D0%BD%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D0%B8%D0%BA%D0%B0)#.D0.9E.D0.B3.D1.80.D0.B0.D0.BD.D0.B8.D1.87.D0.B5.D0.BD.D0.BD.D1.8B.D0.B5_.D0.B8_.D0.BD.D0.B5.D0.BE.D0.B3.D1.80.D0.B0.D0.BD.D0.B8.D1.87.D0.B5.D0.BD.D0.BD.D1.8B.D0.B5_.D0.BF.D1.80.D0.BE.D0.B4.D0.BE.D0.BB.D0.B6.D0.B5.D0.BD.D0.B8.D1.8F">Нашёл по теме на русском</a>.</p><p><strong>P.S.:</strong> Это ж надо было столько прождать, чтобы узнать, что всё уткнётся в Call. Столько бы места и времени сэкономил...</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2015-11-11T09:01:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98914#p98914</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98913#p98913" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong>,</p><p>Наверное можно так:<br /></p><div class="codebox"><pre><code>
Call Test(&quot;Text1&quot;, vbInformation, &quot;Title1&quot;)(&quot;Text2&quot;, vbExclamation, &quot;Title2&quot;)

Function Test(Prompt, Buttons, Title)
	MsgBox Prompt, Buttons, Title
	Set Test = GetRef(&quot;Test&quot;)
End Function
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2015-11-11T07:30:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98913#p98913</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98909#p98909" />
			<content type="html"><![CDATA[<p>Давно (уже года 2-3, наверно) хотел спросить по поводу <a href="http://forum.script-coding.com/viewtopic.php?pid=51962#p51962">этой фичи</a>, предложенной <strong>Rumata</strong>.<br />Есть возможность применять при нескольких параметрах?</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2015-11-10T20:44:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98909#p98909</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81491#p81491" />
			<content type="html"><![CDATA[<p>И еще один момент, касающийся <strong>execute</strong>, в дополнение к посту <a href="http://forum.script-coding.com/viewtopic.php?pid=81414#p81414">#39</a>.<br />В то время, как вызов <strong>execute</strong> внутри процедуры или функции (или внутри метода экземпляра класса) создаёт процедуры, функции и классы локально, простое присвоение значения еще не объявленной переменной приводит к созданию переменной с этим значением в глобальном пространстве скрипта. Такое поведение я ожидал от <strong>executeglobal</strong>, но никак не от <strong>execute</strong>.. <img src="//forum.script-coding.com/img/smilies/mad.png" width="15" height="15" /> При чем данное присвоение даже не вызовет ошибку &quot;переменная не определена&quot; при наличии <strong>option explicit</strong> в первой строке скрипта - ошибка появится лишь в том случае, если инструкцию <strong>option explicit</strong> поставить вначале строки, выполняемой <strong>execute</strong>.</p>]]></content>
			<author>
				<name><![CDATA[omegastripes]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29228</uri>
			</author>
			<updated>2014-04-04T20:45:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81491#p81491</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81434#p81434" />
			<content type="html"><![CDATA[<p>Продолжая тему <a href="http://forum.script-coding.com/viewtopic.php?id=4177">VBScript: создание пользовательского объекта</a>, можно использовать еще один вариант. Создание пользовательского объекта как экземпляра локально объявленного класса позволит не засорять глобальное пространство скрипта:<br /></p><div class="codebox"><pre><code>strmytypename = &quot;customobject&quot; &#039; тип объекта
arrmykeys = array(&quot;property1&quot;, &quot;property2&quot;) &#039; массив с названиями свойств объека
arrmyvalues = array(&quot;value1&quot;, createobject(&quot;scripting.dictionary&quot;)) &#039; массив со значениями свойств
&#039; создание объекта
set objmy = getmyobj(strmytypename, arrmykeys, arrmyvalues)
&#039; проверка
msgbox typename(objmy)
msgbox objmy.property1
msgbox typename(objmy.property2)

function getmyobj(strtypename, arrkeys, arrvalues)
    dim i
    execute &quot;class &quot; &amp; strtypename &amp; &quot;: public &quot; &amp; join(arrkeys, &quot;, &quot;) &amp; &quot;: end class: set getmyobj = new &quot; &amp; strtypename
    for i = 0 to ubound(arrkeys)
        if isobject(arrvalues(i)) then
            execute &quot;set getmyobj.&quot; &amp; arrkeys(i) &amp; &quot; = arrvalues(i)&quot;
        else
            execute &quot;getmyobj.&quot; &amp; arrkeys(i) &amp; &quot; = arrvalues(i)&quot;
        end if
    next
end function</code></pre></div>]]></content>
			<author>
				<name><![CDATA[omegastripes]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29228</uri>
			</author>
			<updated>2014-04-02T19:47:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81434#p81434</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: хитрости/особенности]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81421#p81421" />
			<content type="html"><![CDATA[<p><strong>omegastripes</strong>, для меня неожиданно и крайне интересно. ) Возьму на заметку. Мне такой &quot;фокус&quot; был нужен, когда хотел ссылку на <strong>onreadystatechange</strong> зацепить процедуру внутри класса. Сейчас попробую.</p>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2014-04-02T08:34:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81421#p81421</id>
		</entry>
</feed>
