Search is not available for this dataset
content
stringlengths 0
376M
|
---|
<reponame>NicoBaumann454/alsp.net.api<filename>alps .net api/obj/.cache/build/aglw3apg.sou/xhukrxws.vbs<gh_stars>0
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Namespace alps_.net_api
</title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Namespace alps_.net_api
">
<meta name="generator" content="docfx 2.51.0.0">
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="toc.html">
</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="alps_.net_api">
<h1 id="alps__net_api" data-uid="alps_.net_api" class="text-break">Namespace alps_.net_api
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>
<div class="markdown level0 remarks"></div>
<h3 id="classes">Classes
</h3>
<h4><a class="xref" href="alps_.net_api.Action.html">Action</a></h4>
<section><p>Class that represents a Action</p>
</section>
<h4><a class="xref" href="alps_.net_api.BehaviorDescriptionComponent.html">BehaviorDescriptionComponent</a></h4>
<section><p>Class that represents a BehaviorDescriptionComponent</p>
</section>
<h4><a class="xref" href="alps_.net_api.BuisnessDayTimerTransition.html">BuisnessDayTimerTransition</a></h4>
<section><p>Class that represents a BuisnessDayTimerTransition</p>
</section>
<h4><a class="xref" href="alps_.net_api.BusinessDayTimerTransitionCondition.html">BusinessDayTimerTransitionCondition</a></h4>
<section><p>Class that represents a IBusinessDayTimerTransitionCondition</p>
</section>
<h4><a class="xref" href="alps_.net_api.CalenderBasedReminderTransition.html">CalenderBasedReminderTransition</a></h4>
<section><p>Class that represents an CalenderBasedReminderTransition</p>
</section>
<h4><a class="xref" href="alps_.net_api.CalenderBasedReminderTransitionCondition.html">CalenderBasedReminderTransitionCondition</a></h4>
<section><p>Class that represents an CalenderBasedReminderTransitionCondition</p>
</section>
<h4><a class="xref" href="alps_.net_api.ChoiceSegment.html">ChoiceSegment</a></h4>
<section><p>Class that represents a Choice Segment</p>
</section>
<h4><a class="xref" href="alps_.net_api.ChoiceSegmentPath.html">ChoiceSegmentPath</a></h4>
<section><p>Class that represents a Choice Segment Path</p>
</section>
<h4><a class="xref" href="alps_.net_api.CommunicationAct.html">CommunicationAct</a></h4>
<section><p>Class that represents a communication act</p>
</section>
<h4><a class="xref" href="alps_.net_api.CommunicationTransition.html">CommunicationTransition</a></h4>
<section><p>Class that represents a communication transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.CustomOrExternalDataTypeDefintion.html">CustomOrExternalDataTypeDefintion</a></h4>
<section><p>Class that represents a custom or external data type definition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataDescribingComponent.html">DataDescribingComponent</a></h4>
<section><p>Class that represents a data describing component</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataMappingFunction.html">DataMappingFunction</a></h4>
<section><p>Class that represents a data mapping function</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataMappingIncomingToLocal.html">DataMappingIncomingToLocal</a></h4>
<section><p>Class that represents a data mapping incoming to local</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataMappingLocalToOutgoing.html">DataMappingLocalToOutgoing</a></h4>
<section><p>Class that represents a data mapping local to outgoing</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataObjectDefiniton.html">DataObjectDefiniton</a></h4>
<section><p>Class that represents a data object definition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataObjectListDefiniton.html">DataObjectListDefiniton</a></h4>
<section><p>Class that represents a data object list definition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DataTypeDefintion.html">DataTypeDefintion</a></h4>
<section><p>Class that represents a Data Type Definition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DayTimerTransitionCondition.html">DayTimerTransitionCondition</a></h4>
<section><p>Class that represents a DayTimerTranstitionCondition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DayTimeTimerTransition.html">DayTimeTimerTransition</a></h4>
<section><p>Class that represents a DayTimeTimerTransition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DoFunction.html">DoFunction</a></h4>
<section><p>Class that represents an DoFunction</p>
</section>
<h4><a class="xref" href="alps_.net_api.DoState.html">DoState</a></h4>
<section><p>Class that represents a DoState</p>
</section>
<h4><a class="xref" href="alps_.net_api.DoTransition.html">DoTransition</a></h4>
<section><p>Class that represents a DoTransition</p>
</section>
<h4><a class="xref" href="alps_.net_api.DoTransitionCondition.html">DoTransitionCondition</a></h4>
<section><p>Class that represents an DoTransitionCondtition</p>
</section>
<h4><a class="xref" href="alps_.net_api.EndState.html">EndState</a></h4>
<section><p>Class that represents an EndState</p>
</section>
<h4><a class="xref" href="alps_.net_api.FullySpecifiedSubject.html">FullySpecifiedSubject</a></h4>
<section><p>Class that represents an FullySpecifiedSubject</p>
</section>
<h4><a class="xref" href="alps_.net_api.FunctionSpecification.html">FunctionSpecification</a></h4>
<section><p>Class that represents an FunctionSpecification</p>
</section>
<h4><a class="xref" href="alps_.net_api.GenericReturnToOriginReference.html">GenericReturnToOriginReference</a></h4>
<section><p>Class that represents an GenericReturnToOriginReference</p>
</section>
<h4><a class="xref" href="alps_.net_api.GuardBehavior.html">GuardBehavior</a></h4>
<section><p>Class that represents an GuardBehavior</p>
</section>
<h4><a class="xref" href="alps_.net_api.InitialStateOfBehavior.html">InitialStateOfBehavior</a></h4>
<section><p>Class that represents an InitialStateOfBehavior</p>
</section>
<h4><a class="xref" href="alps_.net_api.InitialStateOfChoiceSegmentPath.html">InitialStateOfChoiceSegmentPath</a></h4>
<section><p>Class that represents InitialStateOfChoiceSegmentPath</p>
</section>
<h4><a class="xref" href="alps_.net_api.InputPoolConstraint.html">InputPoolConstraint</a></h4>
<section><p>Class that represents an InputPoolConstraint</p>
</section>
<h4><a class="xref" href="alps_.net_api.InputPoolConstraintHandlingStrategy.html">InputPoolConstraintHandlingStrategy</a></h4>
<section><p>Class that represents an InputConstraintHandlingStrategy</p>
</section>
<h4><a class="xref" href="alps_.net_api.InteractionDescriptionComponent.html">InteractionDescriptionComponent</a></h4>
<section><p>Class that represents an InteractionDescriptionComponten </p>
</section>
<h4><a class="xref" href="alps_.net_api.InterfaceSubject.html">InterfaceSubject</a></h4>
<section><p>Class that represents an interface subject</p>
</section>
<h4><a class="xref" href="alps_.net_api.JSONDataTypeDefintion.html">JSONDataTypeDefintion</a></h4>
<section><p>Class that represents an JSONDataTypeDefinition</p>
</section>
<h4><a class="xref" href="alps_.net_api.MacroBehavior.html">MacroBehavior</a></h4>
<section><p>Class that represents an Macro behavior of a Subject</p>
</section>
<h4><a class="xref" href="alps_.net_api.MacroState.html">MacroState</a></h4>
<section><p>Class that represents an macro state</p>
</section>
<h4><a class="xref" href="alps_.net_api.MandatoryToEndChoiceSegment.html">MandatoryToEndChoiceSegment</a></h4>
<section><p>Class that represents an mandatory to end choice segment path </p>
</section>
<h4><a class="xref" href="alps_.net_api.MandatoryToStartChoiceSegment.html">MandatoryToStartChoiceSegment</a></h4>
<section><p>Class that represents an mandatory to start choice segment path</p>
</section>
<h4><a class="xref" href="alps_.net_api.MessageExchange.html">MessageExchange</a></h4>
<section><p>Class that represents an message exchange</p>
</section>
<h4><a class="xref" href="alps_.net_api.MessageExchangeCondition.html">MessageExchangeCondition</a></h4>
<section><p>Class that represents an message exchange conditon</p>
</section>
<h4><a class="xref" href="alps_.net_api.MessageExchangeList.html">MessageExchangeList</a></h4>
<section><p>Class that represents an message exchange list</p>
</section>
<h4><a class="xref" href="alps_.net_api.MessageSenderTypeConstraint.html">MessageSenderTypeConstraint</a></h4>
<section><p>Class that represents an message sender type constraint</p>
</section>
<h4><a class="xref" href="alps_.net_api.MessageSpecification.html">MessageSpecification</a></h4>
<section><p>Class that contains a certain message specification</p>
</section>
<h4><a class="xref" href="alps_.net_api.MessageTypeConstraint.html">MessageTypeConstraint</a></h4>
<section><p>Class that represents a message type constraint</p>
</section>
<h4><a class="xref" href="alps_.net_api.ModelBuiltInDataTypes.html">ModelBuiltInDataTypes</a></h4>
<section><p>Class that represents a model built in data type</p>
</section>
<h4><a class="xref" href="alps_.net_api.MultiSubject.html">MultiSubject</a></h4>
<section><p>Class that represents a multi subject</p>
</section>
<h4><a class="xref" href="alps_.net_api.OptionalToEndChoiceSegmentPath.html">OptionalToEndChoiceSegmentPath</a></h4>
<section><p>Class that represents a optional to end choice segment path </p>
</section>
<h4><a class="xref" href="alps_.net_api.OptionalToStartChoiceSegmentPath.html">OptionalToStartChoiceSegmentPath</a></h4>
<section><p>Class that represents a optional to start choice segment path</p>
</section>
<h4><a class="xref" href="alps_.net_api.OWLDataTypeDefintion.html">OWLDataTypeDefintion</a></h4>
<section><p>Class that represents a OWL data type definition</p>
</section>
<h4><a class="xref" href="alps_.net_api.OwlGraph.html">OwlGraph</a></h4>
<section><p>The main Class of the alps_.net_api. Controlles all the </p>
</section>
<h4><a class="xref" href="alps_.net_api.OwlThing.html">OwlThing</a></h4>
<section><p>The base class within the owl onthology
Builds the base of all the inherited classes but has no attributes</p>
</section>
<h4><a class="xref" href="alps_.net_api.PASSProcessModelElement.html">PASSProcessModelElement</a></h4>
<section><p>Root class for the inheritans graphs</p>
</section>
<h4><a class="xref" href="alps_.net_api.PassProcessModell.html">PassProcessModell</a></h4>
<section><p>Class that represents a Pass process modell</p>
</section>
<h4><a class="xref" href="alps_.net_api.PayloadDataObjectDefinition.html">PayloadDataObjectDefinition</a></h4>
<section><p>Class that represents a payload data object definition</p>
</section>
<h4><a class="xref" href="alps_.net_api.PayloadDescription.html">PayloadDescription</a></h4>
<section><p>Class that represents a payload description</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReceiveFunction.html">ReceiveFunction</a></h4>
<section><p>Class that represents a receive function class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReceiveState.html">ReceiveState</a></h4>
<section><p>Class that represents a receive state</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReceiveTransition.html">ReceiveTransition</a></h4>
<section><p>Class that represents a receive transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReceiveTransitionCondition.html">ReceiveTransitionCondition</a></h4>
<section><p>Class that represents a receive transition condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReceiveType.html">ReceiveType</a></h4>
<section><p>Class that represents a receive type</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReminderEventTransitionCondition.html">ReminderEventTransitionCondition</a></h4>
<section><p>Class that represents a reminder event transition condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.ReminderTransition.html">ReminderTransition</a></h4>
<section><p>Class that represents a reminder transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.SenderTypeConstraint.html">SenderTypeConstraint</a></h4>
<section><p>Class that represents a sender type constraint</p>
</section>
<h4><a class="xref" href="alps_.net_api.SendFunction.html">SendFunction</a></h4>
<section><p>Class that represents a send function</p>
</section>
<h4><a class="xref" href="alps_.net_api.SendingFailedCondition.html">SendingFailedCondition</a></h4>
<section><p>Class that represents a sending failed condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.SendingFailedTransition.html">SendingFailedTransition</a></h4>
<section><p>Class that represents a sending failed transition </p>
</section>
<h4><a class="xref" href="alps_.net_api.SendState.html">SendState</a></h4>
<section><p>Class that represents a send state</p>
</section>
<h4><a class="xref" href="alps_.net_api.SendTransition.html">SendTransition</a></h4>
<section><p>Class that represents a send transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.SendTransitionCondition.html">SendTransitionCondition</a></h4>
<section><p>Class that represents a send transition condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.SendType.html">SendType</a></h4>
<section><p>Class that represents a send type</p>
</section>
<h4><a class="xref" href="alps_.net_api.SingleSubject.html">SingleSubject</a></h4>
<section><p>Class that represents a single subject</p>
</section>
<h4><a class="xref" href="alps_.net_api.StandartPASSState.html">StandartPASSState</a></h4>
<section><p>Class that represents a standart PASS state</p>
</section>
<h4><a class="xref" href="alps_.net_api.StartSubject.html">StartSubject</a></h4>
<section><p>Class that represents a start subject</p>
</section>
<h4><a class="xref" href="alps_.net_api.State.html">State</a></h4>
<section><p>Class that represents a state</p>
</section>
<h4><a class="xref" href="alps_.net_api.StateReference.html">StateReference</a></h4>
<section><p>Class that represents a state reference class</p>
</section>
<h4><a class="xref" href="alps_.net_api.Subject.html">Subject</a></h4>
<section><p>Class that represents a subject</p>
</section>
<h4><a class="xref" href="alps_.net_api.SubjectBaseBehavior.html">SubjectBaseBehavior</a></h4>
<section><p>Class that represents a subject base behavior class</p>
</section>
<h4><a class="xref" href="alps_.net_api.SubjectBehavior.html">SubjectBehavior</a></h4>
<section><p>Class that represents a subject behavior</p>
</section>
<h4><a class="xref" href="alps_.net_api.SubjectDataDefinition.html">SubjectDataDefinition</a></h4>
<section><p>Class that represents a subject data definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.TimeBasedReminderTransition.html">TimeBasedReminderTransition</a></h4>
<section><p>Class that represents a time based reminder transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.TimeBasedReminderTransitionCondition.html">TimeBasedReminderTransitionCondition</a></h4>
<section><p>Class that represents a time based reminder transition condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.TimerTransition.html">TimerTransition</a></h4>
<section><p>Class that represents a timer transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.TimerTransitionCondition.html">TimerTransitionCondition</a></h4>
<section><p>Class that represents a timer transition condition </p>
</section>
<h4><a class="xref" href="alps_.net_api.TimeTransition.html">TimeTransition</a></h4>
<section><p>Class that represents a time transition </p>
</section>
<h4><a class="xref" href="alps_.net_api.TimeTransitionCondition.html">TimeTransitionCondition</a></h4>
<section><p>Class that represents a time transition condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.Transition.html">Transition</a></h4>
<section><p>Class that represents a transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.TransitionCondition.html">TransitionCondition</a></h4>
<section><p>Class that represents a transition condition</p>
</section>
<h4><a class="xref" href="alps_.net_api.TreeNode.html">TreeNode</a></h4>
<section><p>Class that represents a tree node</p>
</section>
<h4><a class="xref" href="alps_.net_api.UserCancelTransition.html">UserCancelTransition</a></h4>
<section><p>Class that represents a user cancel transition </p>
</section>
<h4><a class="xref" href="alps_.net_api.XSDDataTypeDefintion.html">XSDDataTypeDefintion</a></h4>
<section><p>Class that represents a XSD data type defintion</p>
</section>
<h4><a class="xref" href="alps_.net_api.YearMonthTimerTransition.html">YearMonthTimerTransition</a></h4>
<section><p>Class that represents a year month timer transition </p>
</section>
<h4><a class="xref" href="alps_.net_api.YearMonthTimerTransitionCondition.html">YearMonthTimerTransitionCondition</a></h4>
<section><p>Class that represents a year month timer transition condition</p>
</section>
<h3 id="interfaces">Interfaces
</h3>
<h4><a class="xref" href="alps_.net_api.abstracPass.html">abstracPass</a></h4>
<section><p>hier sollte die Beschreibung der AbstractPass kommen, mal schauen was ich davon
brauche, vermutlich alles</p>
</section>
<h4><a class="xref" href="alps_.net_api.IAction.html">IAction</a></h4>
<section><p>Interface to the Action class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IBehaviorDescriptionComponent.html">IBehaviorDescriptionComponent</a></h4>
<section><p>Interface to the BehaviorDescriptionComponent class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IBuisnessDayTimerTransition.html">IBuisnessDayTimerTransition</a></h4>
<section><p>Interface to the BuisnessDayTimerTransition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IBusinessDayTimerTransitionCondition.html">IBusinessDayTimerTransitionCondition</a></h4>
<section><p>Interface to the BusinessDayTimerTransitionCondition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ICalenderBasedReminderTransition.html">ICalenderBasedReminderTransition</a></h4>
<section><p>Interface to the CalenderBasedReminderTransition Class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ICalenderBasedReminderTransitionCondition.html">ICalenderBasedReminderTransitionCondition</a></h4>
<section><p>Interface to the Class CalenderBasedReminderTransitionCondition</p>
</section>
<h4><a class="xref" href="alps_.net_api.IChoiceSegment.html">IChoiceSegment</a></h4>
<section><p>Interface to the choice segment class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IChoiceSegmentPath.html">IChoiceSegmentPath</a></h4>
<section><p>Interface to the choice segment path class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ICommunicationAct.html">ICommunicationAct</a></h4>
<section><p>Interface to the communication act class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ICommunicationTransition.html">ICommunicationTransition</a></h4>
<section><p>Interface to the communication transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ICustomOrExternalDataTypeDefintion.html">ICustomOrExternalDataTypeDefintion</a></h4>
<section><p>Interface to the custom or external data type definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataDescribingComponent.html">IDataDescribingComponent</a></h4>
<section><p>Interface to the data describing component class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataMappingFunction.html">IDataMappingFunction</a></h4>
<section><p>Interface to the data mapping function class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataMappingIncomingToLocal.html">IDataMappingIncomingToLocal</a></h4>
<section><p>Interface to the data mapping incoming to local class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataMappingLocalToOutgoing.html">IDataMappingLocalToOutgoing</a></h4>
<section><p>Interface to the data mapping local to outgoing class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataObjectDefiniton.html">IDataObjectDefiniton</a></h4>
<section><p>Interace to the data object definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataObjectListDefiniton.html">IDataObjectListDefiniton</a></h4>
<section><p>Interface to the data object list definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDataTypeDefintion.html">IDataTypeDefintion</a></h4>
<section><p>Interface to the data type definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDayTimerTransitionCondition.html">IDayTimerTransitionCondition</a></h4>
<section><p>Interface to the DayTimerTransitionCondition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDayTimeTimerTransition.html">IDayTimeTimerTransition</a></h4>
<section><p>Interface to the DayTimeTimerTransition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDoFunction.html">IDoFunction</a></h4>
<section><p>Interface to the DoFunction class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDoState.html">IDoState</a></h4>
<section><p>Interface to the DoState class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDoTransition.html">IDoTransition</a></h4>
<section><p>Interface to the DoTransition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IDoTransitionCondition.html">IDoTransitionCondition</a></h4>
<section><p>Interface to the DoTransitionCondition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IEndState.html">IEndState</a></h4>
<section><p>Interface to the EndState class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IFullySpecifiedSubject.html">IFullySpecifiedSubject</a></h4>
<section><p>Interface to the FullySpecifiedSubject class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IFunctionSpecification.html">IFunctionSpecification</a></h4>
<section><p>Interface to the FunctionSpecification class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IGenericReturnToOriginRefrence.html">IGenericReturnToOriginRefrence</a></h4>
<section><p>Interface to the GenericReturnToOriginReference class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IGuardBehavior.html">IGuardBehavior</a></h4>
<section><p>Interface to the GuardBehavior class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IInitialStateOfBehavior.html">IInitialStateOfBehavior</a></h4>
<section><p>Interface to the InitialStateOfBehavior class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IInitialstateOfChoiceSegmentPath.html">IInitialstateOfChoiceSegmentPath</a></h4>
<section><p>Interface to the InitialStateOfChoiceSegmentPath class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IInputPoolConstraint.html">IInputPoolConstraint</a></h4>
<section><p>Interface to the InputPoolConstraint class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IInputPoolConstraintHandlingStrategy.html">IInputPoolConstraintHandlingStrategy</a></h4>
<section><p>Interface to the InputPoolConstraintHandlingStrategyClass</p>
</section>
<h4><a class="xref" href="alps_.net_api.IInteractionDescriptionComponent.html">IInteractionDescriptionComponent</a></h4>
<section><p>Interface to the interaction description component class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IInterfaceSubject.html">IInterfaceSubject</a></h4>
<section><p>Interface to the interface subject class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IJSONDataTypeDefintion.html">IJSONDataTypeDefintion</a></h4>
<section><p>Interface to the JSONDataTypeDefinition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMacroBehavior.html">IMacroBehavior</a></h4>
<section><p>Interface to the macro bahvior class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMacroState.html">IMacroState</a></h4>
<section><p>Interface to the macro state class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMandatoryToEndChoiceSegmentPath.html">IMandatoryToEndChoiceSegmentPath</a></h4>
<section><p>Interface to the mandatory to end choice segment path class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMandatoryToStartChoiceSegmentPath.html">IMandatoryToStartChoiceSegmentPath</a></h4>
<section><p>Interface to the mandatory to start choice segment path class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMessageExchange.html">IMessageExchange</a></h4>
<section><p>Interface to the message exchange class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMessageExchangeCondition.html">IMessageExchangeCondition</a></h4>
<section><p>Interface to the message exchange condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMessageExchangeList.html">IMessageExchangeList</a></h4>
<section><p>Interface to the message exchange list class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMessageSenderTypeConstraint.html">IMessageSenderTypeConstraint</a></h4>
<section><p>Interface to the MessageSenderTypeConstraint Class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMessageSpecification.html">IMessageSpecification</a></h4>
<section><p>Interface for the MessageSpecification class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMessageTypeConstraint.html">IMessageTypeConstraint</a></h4>
<section><p>Interface to the message type constraint class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IModelBuiltInDataTypes.html">IModelBuiltInDataTypes</a></h4>
<section><p>Interface to the model built in data type class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IMultiSubject.html">IMultiSubject</a></h4>
<section><p>Interface to the multi subject class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IOptionalToEndChoiceSegmentPath.html">IOptionalToEndChoiceSegmentPath</a></h4>
<section><p>Interface to the optional to end choice segment path class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IOptionalToStartChoiceSegmentPath.html">IOptionalToStartChoiceSegmentPath</a></h4>
<section><p>Interface to the optional to start choice segment path class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IOWLDataTypeDefintion.html">IOWLDataTypeDefintion</a></h4>
<section><p>Interface to the OWL data type definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IOwlThing.html">IOwlThing</a></h4>
<section><p>Interface of the Owl thing class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IPassProcessModell.html">IPassProcessModell</a></h4>
<section><p>Interface of the pass process model class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IPASSProcessModellElement.html">IPASSProcessModellElement</a></h4>
<section><p>Interface to the PASS process modell element class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IPayloadDataObjectDefinition.html">IPayloadDataObjectDefinition</a></h4>
<section><p>Interface to the payload data object definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IPayloadDescription.html">IPayloadDescription</a></h4>
<section><p>Interface of the payload description class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReceiveFunction.html">IReceiveFunction</a></h4>
<section><p>Interface of the receive function class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReceiveState.html">IReceiveState</a></h4>
<section><p>Interface of the receive state class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReceiveTransition.html">IReceiveTransition</a></h4>
<section><p>interface of the receive transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReceiveTransitionCondition.html">IReceiveTransitionCondition</a></h4>
<section><p>Interface to the receive transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReceiveType.html">IReceiveType</a></h4>
<section><p>Interface to the receive type class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReminderEventTransitionCondition.html">IReminderEventTransitionCondition</a></h4>
<section><p>Interface to the reminder event transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IReminderTransition.html">IReminderTransition</a></h4>
<section><p>Interface to the reminder transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISenderTypeConstraint.html">ISenderTypeConstraint</a></h4>
<section><p>Interface to the sender type constraint class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendFunction.html">ISendFunction</a></h4>
<section><p>Interface to the send function class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendingFailedCondition.html">ISendingFailedCondition</a></h4>
<section><p>Interface to the sending failed condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendingFailedTransition.html">ISendingFailedTransition</a></h4>
<section><p>Interface to the sending failed transition </p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendState.html">ISendState</a></h4>
<section><p>Interface to the send type class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendTransition.html">ISendTransition</a></h4>
<section><p>Interface to the send transition</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendTransitionCondition.html">ISendTransitionCondition</a></h4>
<section><p>Interface to the send transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISendType.html">ISendType</a></h4>
<section><p>Interface to the send type class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISingleSubject.html">ISingleSubject</a></h4>
<section><p>Interface to the single subject class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IStandartPASSState.html">IStandartPASSState</a></h4>
<section><p>Interface to the stadart PASS state class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IStartSubject.html">IStartSubject</a></h4>
<section><p>Interface to the start subject class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IState.html">IState</a></h4>
<section><p>Interface to the state class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IStateReference.html">IStateReference</a></h4>
<section><p>Interface to the state reference class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISubject.html">ISubject</a></h4>
<section><p>Interface to the subject class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISubjectBaseBehavior.html">ISubjectBaseBehavior</a></h4>
<section><p>Interface to the subject base behavior class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISubjectBehavior.html">ISubjectBehavior</a></h4>
<section><p>Interface to the Subject behavior class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ISubjectDataDefinition.html">ISubjectDataDefinition</a></h4>
<section><p>Interface of the subject data definition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITimeBasedReminderTransition.html">ITimeBasedReminderTransition</a></h4>
<section><p>Interface to the time based reminder transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITimeBasedReminderTransitionCondition.html">ITimeBasedReminderTransitionCondition</a></h4>
<section><p>Interface to the time based reminder transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITimerTransition.html">ITimerTransition</a></h4>
<section><p>Interface to the timer transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITimerTransitionCondition.html">ITimerTransitionCondition</a></h4>
<section><p>Interface to the timer transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITimeTransition.html">ITimeTransition</a></h4>
<section><p>Interface to the time transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITimeTransitionCondition.html">ITimeTransitionCondition</a></h4>
<section><p>Interface to the time transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITransition.html">ITransition</a></h4>
<section><p>Interface to the transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITransitionCondition.html">ITransitionCondition</a></h4>
<section><p>Interface of the transition condition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.ITreeNode.html">ITreeNode</a></h4>
<section><p>Interface to the tree node class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IUserCancelTransition.html">IUserCancelTransition</a></h4>
<section><p>Interface to the user cancel transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IXSDDataTypeDefintion.html">IXSDDataTypeDefintion</a></h4>
<section><p>Interface to the XSD data type defintion class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IYearMonthTimerTransition.html">IYearMonthTimerTransition</a></h4>
<section><p>Interface to the year month timer transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.IYearMonthTimerTransitionCondition.html">IYearMonthTimerTransitionCondition</a></h4>
<section><p>Interface to the year month timer transition class</p>
</section>
<h4><a class="xref" href="alps_.net_api.SimplePASSElement.html">SimplePASSElement</a></h4>
<section><p>Dies ist die Beschreibung der einfachen Element wobei diese an sich nicht unbedingt
notwending ist, mal schauen ob diese in der Bibliothek verbleiben, vermutlich schon </p>
</section>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>
</body>
</html>
|
<gh_stars>1-10
Option Explicit
Sub Main()
Debug.Print "Input : " & "we,are;not,in,kansas;any,more."
Debug.Print "First way : " & OddWordFirst("we,are;not,in,kansas;any,more.")
Debug.Print "Second way : " & OddWordSecond("we,are;not,in,kansas;any,more.")
Debug.Print ""
Debug.Print "Input : " & "what,is,the;meaning,of:life."
Debug.Print "First way : " & OddWordFirst("what,is,the;meaning,of:life.")
Debug.Print "Second way : " & OddWordSecond("what,is,the;meaning,of:life.")
End Sub
|
<filename>Task/Middle-three-digits/VBA/middle-three-digits.vba
Option Explicit
Sub Main_Middle_three_digits()
Dim Numbers, i&
Numbers = Array(123, 12345, 1234567, 987654321, 10001, -10001, -123, -100, _
100, -12345, 1, 2, -1, -10, 2002, -2002, 0)
For i = 0 To 16
Debug.Print Numbers(i) & " Return : " & Middle3digits(CStr(Numbers(i)))
Next
End Sub
Function Middle3digits(strNb As String) As String
If Left(strNb, 1) = "-" Then strNb = Right(strNb, Len(strNb) - 1)
If Len(strNb) < 3 Then
Middle3digits = "Error ! Number of digits must be >= 3"
ElseIf Len(strNb) Mod 2 = 0 Then
Middle3digits = "Error ! Number of digits must be odd"
Else
Middle3digits = Mid(strNb, 1 + (Len(strNb) - 3) / 2, 3)
End If
End Function
|
Function pick_random(arr)
Set objRandom = CreateObject("System.Random")
pick_random = arr(objRandom.Next_2(0,UBound(arr)+1))
End Function
WScript.Echo pick_random(Array("a","b","c","d","e","f"))
|
<reponame>LaudateCorpus1/RosettaCodeData
Function pow(x,y)
pow = 1
If y < 0 Then
For i = 1 To Abs(y)
pow = pow * (1/x)
Next
Else
For i = 1 To y
pow = pow * x
Next
End If
End Function
WScript.StdOut.Write "2 ^ 0 = " & pow(2,0)
WScript.StdOut.WriteLine
WScript.StdOut.Write "7 ^ 6 = " & pow(7,6)
WScript.StdOut.WriteLine
WScript.StdOut.Write "3.14159265359 ^ 9 = " & pow(3.14159265359,9)
WScript.StdOut.WriteLine
WScript.StdOut.Write "4 ^ -6 = " & pow(4,-6)
WScript.StdOut.WriteLine
WScript.StdOut.Write "-3 ^ 5 = " & pow(-3,5)
WScript.StdOut.WriteLine
|
<gh_stars>1-10
Function comb_sort(ByVal s As Variant) As Variant
Dim gap As Integer: gap = UBound(s)
Dim swapped As Integer
Do While True
gap = WorksheetFunction.Max(WorksheetFunction.Floor_Precise(gap / 1.3), 1)
swapped = False
For i = 0 To UBound(s) - gap
si = Val(s(i))
If si > Val(s(i + gap)) Then
s(i) = s(i + gap)
s(i + gap) = CStr(si)
swapped = True
End If
Next i
If gap = 1 And Not swapped Then Exit Do
Loop
comb_sort = s
End Function
Public Sub main()
Dim s(9) As Variant
For i = 0 To 9
s(i) = CStr(Int(1000 * Rnd))
Next i
Debug.Print Join(s, ", ")
Debug.Print Join(comb_sort(s), ", ")
End Sub
|
<gh_stars>1-10
Function pf(p)
If p < 0.06 Then
pf = 0.10
ElseIf p < 0.11 Then
pf = 0.18
ElseIf p < 0.16 Then
pf = 0.26
ElseIf p < 0.21 Then
pf = 0.32
ElseIf p < 0.26 Then
pf = 0.38
ElseIf p < 0.31 Then
pf = 0.44
ElseIf p < 0.36 Then
pf = 0.50
ElseIf p < 0.41 Then
pf = 0.54
ElseIf p < 0.46 Then
pf = 0.58
ElseIf p < 0.51 Then
pf = 0.62
ElseIf p < 0.56 Then
pf = 0.66
ElseIf p < 0.61 Then
pf = 0.70
ElseIf p < 0.66 Then
pf = 0.74
ElseIf p < 0.71 Then
pf = 0.78
ElseIf p < 0.76 Then
pf = 0.82
ElseIf p < 0.81 Then
pf = 0.86
ElseIf p < 0.86 Then
pf = 0.90
ElseIf p < 0.91 Then
pf = 0.94
ElseIf p < 0.96 Then
pf = 0.98
Else
pf = 1.00
End If
End Function
WScript.Echo pf(0.7388727)
WScript.Echo pf(0.8593103)
WScript.Echo pf(0.826687)
WScript.Echo pf(0.3444635)
|
<filename>tests/examplefiles/test.vb
' Copyright (c) 2008 Silken Web - Free BSD License
' All rights reserved.
'
' Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
' * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer
' * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
' * Neither the name of Silken Web nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
'
' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
' BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
' GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
' LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
' DAMAGE.
Imports System.Net.Mail
Imports SilkenWeb.Entities
Imports System.Text.RegularExpressions
Imports System.Reflection
Imports SilkenWeb.Validation
Imports System.Globalization
Imports SilkenWeb.Reflection
Namespace SilkenWeb
''' <summary>
''' Represents an Email and what you can do with it.
''' </summary>
''' <remarks>
''' <NAME>
''' 11/04/2008
'''
''' This class is intended to be inherrited for providing all manner of system generated emails, each represented by it's own class.
''' </remarks>
Public MustInherit Class EmailBase : Implements IValidatable, IDisposable
#Region " Constants "
Public Const LenientRegexPattern As String = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Public Const StrictRegexPattern As String = "^(([^<>()[\]\\.,;:\s@\""]+(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$"
Public Const InvalidEmailAddressError As String = "The Email address provided was invalid"
Public Const InvalidEmailAddressErrorWithAddress As String = "The Email address, {0}, provided was invalid"
Public Const NullEmailAddressError As String = "The Email address was not provided"
#End Region
#Region " Fields "
Private disposedValue As Boolean
Private _message As MailMessage = New MailMessage()
Private _mailClient As SmtpClient
Private _useStrictValidation As Boolean
#End Region
#Region " Construction "
''' <summary>
''' Instantiates a new Email of the derived type.
''' </summary>
''' <param name="sender">The email address of the sender of the message.</param>
''' <param name="recipients">The email addresses of the recipients of the message.</param>
''' <param name="subject">The subject of the message.</param>
''' <param name="body">The body of the message.</param>
Protected Sub New(ByVal sender As String, ByVal subject As String, ByVal body As String, ByVal ParamArray recipients As String())
_message.From = New MailAddress(sender)
For i As Integer = 0 To recipients.Length - 1
_message.To.Add(recipients(i))
Next
_message.Subject = subject
_message.Body = body
End Sub
#End Region
#Region " Properties "
''' <summary>
''' Gets the Attachments for the message.
''' </summary>
Protected Overridable ReadOnly Property Attachments() As AttachmentCollection
Get
Return _message.Attachments
End Get
End Property
''' <summary>
''' The email addresses of the BCC recipients of the message.
''' </summary>
Public Property BccRecipients() As String()
Get
Return _message.Bcc.ToAddressStringArray()
End Get
Set(ByVal value As String())
_message.Bcc.Clear()
_message.Bcc.Add(value.ToDelimitedString())
End Set
End Property
''' <summary>
''' The body of the message.
''' </summary>
Protected Overridable Property Body() As String
Get
Return _message.Body
End Get
Set(ByVal value As String)
_message.Body = value
End Set
End Property
''' <summary>
''' The email addresses of the CC recipients of the message.
''' </summary>
Public Property CCRecipients() As String()
Get
Return _message.CC.ToAddressStringArray()
End Get
Set(ByVal value As String())
_message.CC.Clear()
_message.CC.Add(value.ToDelimitedString())
End Set
End Property
''' <summary>
''' Gets or Sets a flag to indicate if the body of the message is HTML.
''' </summary>
Public Property IsBodyHtml() As Boolean
Get
Return _message.IsBodyHtml
End Get
Set(ByVal value As Boolean)
_message.IsBodyHtml = value
End Set
End Property
''' <summary>
''' Gets the Mail message wrapped by the EmailBase class.
''' </summary>
Protected ReadOnly Property Message() As MailMessage
Get
Return _message
End Get
End Property
''' <summary>
''' Gets or Sets the Priority of the message.
''' </summary>
Public Property Priority() As MailPriority
Get
Return _message.Priority
End Get
Set(ByVal value As MailPriority)
_message.Priority = value
End Set
End Property
''' <summary>
''' The email addresses of the recipients of the message.
''' </summary>
Public Property Recipients() As String()
Get
Return _message.To.ToAddressStringArray()
End Get
Set(ByVal value As String())
_message.To.Clear()
_message.To.Add(value.ToDelimitedString())
End Set
End Property
''' <summary>
''' The reply email address of the sender of the message.
''' </summary>
Public Property ReplyTo() As String
Get
If _message.ReplyTo Is Nothing Then
Return String.Empty
Else
Return _message.ReplyTo.Address
End If
End Get
Set(ByVal value As String)
If _message.ReplyTo Is Nothing Then
_message.ReplyTo = New MailAddress(value)
Else
_message.ReplyTo = New MailAddress(value, _message.ReplyTo.DisplayName)
End If
End Set
End Property
''' <summary>
''' The reply display name of the sender of the message.
''' </summary>
Public Property ReplyToDisplayName() As String
Get
If _message.ReplyTo Is Nothing Then
Return String.Empty
Else
Return _message.ReplyTo.DisplayName
End If
End Get
Set(ByVal value As String)
If _message.ReplyTo Is Nothing Then
_message.ReplyTo = New MailAddress(_message.From.Address, value)
Else
_message.ReplyTo = New MailAddress(_message.ReplyTo.Address, value)
End If
End Set
End Property
''' <summary>
''' The email address of the sender of the message.
''' </summary>
Public Overridable Property Sender() As String
Get
Return _message.From.Address
End Get
Protected Set(ByVal value As String)
_message.From = New MailAddress(value, _message.From.DisplayName)
End Set
End Property
''' <summary>
''' The display name of the sender of the message.
''' </summary>
Public Overridable Property SenderDisplayName() As String
Get
Return _message.From.DisplayName
End Get
Protected Set(ByVal value As String)
_message.From = New MailAddress(_message.From.Address, value)
End Set
End Property
''' <summary>
''' The subject of the message.
''' </summary>
Public Overridable Property Subject() As String
Get
Return _message.Subject
End Get
Protected Set(ByVal value As String)
_message.Subject = value
End Set
End Property
#End Region
#Region " Methods "
#Region " Send Methods "
''' <summary>
''' Sends this email
''' </summary>
''' <param name="mailServer">The SMTP server to use to send the email.</param>
Public Sub Send(ByVal mailServer As String)
_mailClient = New SmtpClient(mailServer)
_mailClient.Send(_message)
End Sub
''' <summary>
''' Sends this email asynchronously.
''' </summary>
''' <param name="mailServer">The SMTP server to use to send the email.</param>
''' <param name="userToken">A user defined token passed to the recieving method on completion of the asynchronous task.</param>
Public Sub SendAsync(ByVal mailServer As String, ByVal userToken As Object)
_mailClient = New SmtpClient(mailServer)
_mailClient.SendAsync(_message, userToken)
End Sub
''' <summary>
''' Cancels an attempt to send this email asynchronously.
''' </summary>
Public Sub SendAsyncCancel()
_mailClient.SendAsyncCancel()
End Sub
#End Region
#End Region
#Region " IValidatable Implementation "
''' <summary>
''' gets and Sets a flag to indicate whether to use strict validation.
''' </summary>
Public Property UseStrictValidation() As Boolean
Get
Return _useStrictValidation
End Get
Set(ByVal value As Boolean)
_useStrictValidation = value
End Set
End Property
''' <summary>
''' Validates this email.
''' </summary>
''' <returns>A ValidationResponse, containing a flag to indicate if validation was passed and a collection of Property Names and validation errors.</returns>
Public Function Validate() As ValidationResponse Implements IValidatable.Validate
Dim retVal As New ValidationResponse()
Dim mailRegEx As String = If(_useStrictValidation, StrictRegexPattern, LenientRegexPattern)
ValidateAddress("Sender", retVal, mailRegEx, True)
ValidateAddresses("Recipients", retVal, mailRegEx, True)
ValidateAddresses("CcRecipients", retVal, mailRegEx)
ValidateAddresses("BccRecipients", retVal, mailRegEx)
ValidateAddress("ReplyTo", retVal, mailRegEx)
Return retVal
End Function
''' <summary>
''' Validates a single Email Address property.
''' </summary>
''' <param name="propertyName">The name of the property to validate.</param>
''' <param name="retVal">The validation response object.</param>
''' <param name="mailRegEx">The regular expression pattern to use for validation.</param>
Private Overloads Sub ValidateAddress(ByVal propertyName As String, ByRef retVal As ValidationResponse, ByVal mailRegEx As String)
ValidateAddress(propertyName, retVal, mailRegEx, False)
End Sub
''' <summary>
''' Validates a single Email Address property.
''' </summary>
''' <param name="propertyName">The name of the property to validate.</param>
''' <param name="retVal">The validation response object.</param>
''' <param name="mailRegEx">The regular expression pattern to use for validation.</param>
''' <param name="required">Indicates if the address is required; False if not specified.</param>
Private Overloads Sub ValidateAddress(ByVal propertyName As String, ByRef retVal As ValidationResponse, ByVal mailRegEx As String, ByVal required As Boolean)
Dim emailAddress As String = ReflectionHelper.Properties.GetProperty(Of String)(Me, propertyName)
If emailAddress Is Nothing OrElse emailAddress.Length = 0 Then
If required Then retVal.Add(New KeyValuePair(Of String, String)(propertyName, NullEmailAddressError))
Else
If (Not Regex.IsMatch(emailAddress, mailRegEx)) Then
retVal.Add(New KeyValuePair(Of String, String)(propertyName, InvalidEmailAddressError))
End If
End If
End Sub
''' <summary>
''' Validates a string array of Email Address property.
''' </summary>
''' <param name="propertyName">The name of the property to validate.</param>
''' <param name="retVal">The validation response object.</param>
''' <param name="mailRegEx">The regular expression pattern to use for validation.</param>
Private Overloads Sub ValidateAddresses(ByVal propertyName As String, ByRef retVal As ValidationResponse, ByVal mailRegEx As String)
ValidateAddresses(propertyName, retVal, mailRegEx, False)
End Sub
''' <summary>
''' Validates a string array of Email Address property.
''' </summary>
''' <param name="propertyName">The name of the property to validate.</param>
''' <param name="retVal">The validation response object.</param>
''' <param name="mailRegEx">The regular expression pattern to use for validation.</param>
''' <param name="required">Indicates if the address is required; False if not specified.</param>
Private Overloads Sub ValidateAddresses(ByVal propertyName As String, ByRef retVal As ValidationResponse, ByVal mailRegEx As String, ByVal required As Boolean)
Dim emailAddresses() As String = ReflectionHelper.Properties.GetProperty(Of String())(Me, propertyName)
If emailAddresses Is Nothing OrElse emailAddresses.Length = 0 Then
If required Then retVal.Add(New KeyValuePair(Of String, String)(propertyName, String.Format(CultureInfo.CurrentCulture, NullEmailAddressError)))
Else
For i As Integer = 0 To emailAddresses.Length - 1
If (Not Regex.IsMatch(emailAddresses(i), mailRegEx)) Then
retVal.Add(New KeyValuePair(Of String, String)(propertyName, String.Format(CultureInfo.CurrentCulture, InvalidEmailAddressErrorWithAddress, emailAddresses(i))))
End If
Next
End If
End Sub
#End Region
#Region " IDisposable Implementation "
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
_message.Dispose()
End If
_mailClient = Nothing
_message = Nothing
End If
Me.disposedValue = True
End Sub
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
End Namespace
|
Function Dec2Bin(n)
q = n
Dec2Bin = ""
Do Until q = 0
Dec2Bin = CStr(q Mod 2) & Dec2Bin
q = Int(q / 2)
Loop
Dec2Bin = Right("00000" & Dec2Bin,6)
End Function
Sub Combination(n,k)
Dim arr()
ReDim arr(n-1)
For h = 0 To n-1
arr(h) = h + 1
Next
Set list = CreateObject("System.Collections.Arraylist")
For i = 1 To 2^n
bin = Dec2Bin(i)
c = 0
tmp_combo = ""
If Len(Replace(bin,"0","")) = k Then
For j = Len(bin) To 1 Step -1
If CInt(Mid(bin,j,1)) = 1 Then
tmp_combo = tmp_combo & arr(c) & ","
End If
c = c + 1
Next
list.Add Mid(tmp_combo,1,(k*2)-1)
End If
Next
list.Sort
For l = 0 To list.Count-1
WScript.StdOut.Write list(l)
WScript.StdOut.WriteLine
Next
End Sub
'Testing with n = 5 / k = 3
Call Combination(5,3)
|
VERSION 5.00
Begin VB.Form frmExt
BorderStyle = 4 'Fixed ToolWindow
Caption = "Extension Information"
ClientHeight = 5400
ClientLeft = 1770
ClientTop = 1725
ClientWidth = 6135
ControlBox = 0 'False
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5400
ScaleWidth = 6135
ShowInTaskbar = 0 'False
Begin VB.TextBox txtSourceFolder
Enabled = 0 'False
Height = 315
Left = 1755
TabIndex = 24
TabStop = 0 'False
Top = 2745
Width = 4305
End
Begin VB.TextBox txtExtensionFolder
Height = 315
Left = 1755
TabIndex = 5
Top = 2415
Width = 4305
End
Begin VB.TextBox txtOwner
Height = 315
Left = 1755
TabIndex = 2
Top = 1530
Width = 4305
End
Begin VB.CommandButton cmdCancel
Caption = "&Cancel"
CausesValidation= 0 'False
Height = 420
Left = 4080
TabIndex = 16
Top = 4890
Width = 975
End
Begin VB.CommandButton cmdOK
Caption = "&OK"
Height = 420
Left = 5070
TabIndex = 15
Top = 4890
Width = 975
End
Begin VB.CheckBox chkModifiesCab
Caption = "Executable Modifies Original CAB"
Height = 270
Left = 1755
TabIndex = 4
Top = 2175
Width = 3210
End
Begin VB.TextBox txtExecutable
Height = 315
Left = 1755
TabIndex = 3
Top = 1860
Width = 4305
End
Begin VB.Frame fraSKU
Caption = "SKU"
Height = 1575
Left = 1755
TabIndex = 17
Top = 3165
Width = 4305
Begin VB.CheckBox chkSku
Caption = "32-bit Standard"
Height = 255
Index = 0
Left = 150
TabIndex = 7
Top = 495
Width = 1695
End
Begin VB.CheckBox chkSku
Caption = "32-bit Professional"
Height = 255
Index = 1
Left = 150
TabIndex = 8
Top = 750
Width = 1695
End
Begin VB.CheckBox chkSku
Caption = "32-bit Server"
Height = 255
Index = 2
Left = 1920
TabIndex = 10
Top = 240
Width = 2055
End
Begin VB.CheckBox chkSku
Caption = "32-bit Advanced Server"
Height = 255
Index = 3
Left = 1920
TabIndex = 11
Top = 492
Width = 2055
End
Begin VB.CheckBox chkSku
Caption = "32-bit Datacenter Server"
Height = 255
Index = 4
Left = 1920
TabIndex = 13
Top = 996
Width = 2055
End
Begin VB.CheckBox chkSku
Caption = "64-bit Professional"
Height = 255
Index = 5
Left = 150
TabIndex = 9
Top = 1005
Width = 1695
End
Begin VB.CheckBox chkSku
Caption = "64-bit Advanced Server"
Height = 255
Index = 6
Left = 1920
TabIndex = 12
Top = 744
Width = 2055
End
Begin VB.CheckBox chkSku
Caption = "64-bit Datacenter Server"
Height = 255
Index = 7
Left = 1920
TabIndex = 14
Top = 1245
Width = 2055
End
Begin VB.CheckBox chkSku
Caption = "Windows Me"
Height = 255
Index = 8
Left = 150
TabIndex = 6
Top = 240
Width = 1320
End
End
Begin VB.TextBox Text2
Height = 1095
Left = 1755
MultiLine = -1 'True
TabIndex = 1
Top = 420
Width = 4305
End
Begin VB.TextBox txtDisplayName
Height = 315
Left = 1755
TabIndex = 0
Top = 75
Width = 4305
End
Begin VB.Label Label4
Caption = "Extension copied from:"
Height = 330
Left = 105
TabIndex = 23
Top = 2745
Width = 1725
End
Begin VB.Label Label5
Caption = "Extension copied to:"
Height = 255
Left = 105
TabIndex = 22
Top = 2415
Width = 1620
End
Begin VB.Label Label6
Caption = "Extension owner"
Height = 255
Left = 105
TabIndex = 21
Top = 1530
Width = 1380
End
Begin VB.Label Label3
Caption = "Executable name:"
Height = 285
Left = 105
TabIndex = 20
Top = 1860
Width = 1335
End
Begin VB.Label Label2
Caption = "Comment:"
Height = 345
Left = 105
TabIndex = 19
Top = 405
Width = 1050
End
Begin VB.Label Label1
Caption = "Display name:"
Height = 345
Left = 105
TabIndex = 18
Top = 75
Width = 1050
End
End
Attribute VB_Name = "frmExt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_oFs As Scripting.FileSystemObject
Private m_oHssExt As HssExt
Const MAX_SKUS = 8
Private m_aSkuIds(8) As String, m_ocollSkus As Scripting.Dictionary
Sub DropFile(n As Node, ByVal strFN As String, ByVal strOwner As String)
' Me.Caption = "Drop of: " & strFN
With Me
.txtExecutable.Text = m_oFs.GetFileName(strFN)
m_oHssExt.ExtensionFolder = m_oFs.GetParentFolderName(strFN)
.txtSourceFolder = m_oHssExt.ExtensionFolder
.txtExtensionFolder = HssX.txtExtensionsFolder + "\" + m_oFs.GetBaseName(.txtExecutable)
.Show Modal:=vbModal
End With
End Sub
Private Sub chkSku_Click(Index As Integer)
If (Me.chkSku(Index).Value = vbChecked) Then
If (Not m_ocollSkus.Exists(m_aSkuIds(Index))) Then
m_ocollSkus.Add m_aSkuIds(Index), m_aSkuIds(Index)
End If
Else
If (m_ocollSkus.Exists(m_aSkuIds(Index))) Then
m_ocollSkus.Remove m_aSkuIds(Index)
End If
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
On Error GoTo Error_Handler
' OK, now it's time to persist this guy to disk
' Here we create the New Extension Node...
' WE validate the SKUs here because it's useless before
m_oHssExt.ApplicableSkus = m_ocollSkus
m_oHssExt.SaveToDisk Me.txtExtensionFolder
Unload Me
Common_Exit:
Exit Sub
Error_Handler:
MsgBox Err.Description, vbInformation, Me.Caption
GoTo Common_Exit
End Sub
Private Sub Form_Activate()
' Stop
End Sub
Private Sub Form_Initialize()
Set m_oFs = New Scripting.FileSystemObject
Set m_oHssExt = New HssExt
m_aSkuIds(0) = "STD": m_aSkuIds(1) = "PRO": m_aSkuIds(2) = "SRV"
m_aSkuIds(3) = "ADV": m_aSkuIds(4) = "DAT"
m_aSkuIds(5) = "PRO64": m_aSkuIds(6) = "ADV64": m_aSkuIds(7) = "DAT64"
m_aSkuIds(8) = "WINME":
Set m_ocollSkus = New Scripting.Dictionary
' Stop
End Sub
Private Sub Form_Load()
' Stop
End Sub
Private Sub txtDisplayName_Validate(Cancel As Boolean)
Cancel = False
On Error Resume Next
m_oHssExt.DisplayName = Me.txtDisplayName
If (Err.Number <> 0) Then
MsgBox Err.Description, vbInformation, "Error Entering Data"
Cancel = True
End If
End Sub
Private Sub txtExecutable_Validate(Cancel As Boolean)
Cancel = False
On Error Resume Next
m_oHssExt.ExecutableName = Me.txtExecutable
If (Err.Number <> 0) Then
MsgBox Err.Description, vbInformation, "Error Entering Data"
Cancel = True
End If
End Sub
Private Sub txtExtensionFolder_Validate(Cancel As Boolean)
Cancel = False
Dim strExtFolder As String
strExtFolder = Trim$(Me.txtExtensionFolder)
If ((StrComp(HssX.txtExtensionsFolder, _
m_oFs.GetParentFolderName(strExtFolder), _
vbTextCompare) <> 0) _
) Then
MsgBox "Extension Folder MUST be a Sub-directory " + vbCrLf + _
"under Main extensions Directory", vbInformation, "Error Entering Data"
Cancel = True
GoTo Common_Exit
End If
Common_Exit:
Exit Sub
End Sub
Private Sub txtOwner_Validate(Cancel As Boolean)
Cancel = False
On Error Resume Next
m_oHssExt.Owner = Me.txtOwner
If (Err.Number <> 0) Then
MsgBox Err.Description, vbInformation, "Error Entering Data"
Cancel = True
End If
End Sub
|
<filename>net/unimodem/tools/src/frmgeneratemode.frm
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Begin VB.Form frmGenerateInf
BorderStyle = 0 'None
Caption = "Generate Inf"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 9480
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 5730
ScaleWidth = 9480
ShowInTaskbar = 0 'False
Begin VB.Frame framePort
Height = 5055
Index = 3
Left = 120
TabIndex = 2
Top = 360
Width = 6255
Begin VB.ComboBox Combo5
Height = 315
Index = 3
ItemData = "frmGenerateMode.frx":0000
Left = 1200
List = "frmGenerateMode.frx":000D
Style = 2 'Dropdown List
TabIndex = 13
Top = 1620
Width = 1815
End
Begin VB.ComboBox Combo4
Height = 315
Index = 3
ItemData = "frmGenerateMode.frx":001C
Left = 1200
List = "frmGenerateMode.frx":002F
Style = 2 'Dropdown List
TabIndex = 12
Top = 1170
Width = 1815
End
Begin VB.ComboBox Combo3
Height = 315
Index = 3
ItemData = "frmGenerateMode.frx":0051
Left = 1200
List = "frmGenerateMode.frx":0064
Style = 2 'Dropdown List
TabIndex = 11
Top = 690
Width = 1815
End
Begin VB.TextBox Text2
Height = 315
Index = 3
Left = 4320
TabIndex = 10
Text = "AT&FE0"
Top = 1170
Width = 1815
End
Begin VB.TextBox Text1
Height = 315
Index = 3
Left = 4320
TabIndex = 9
Text = "1.5"
Top = 690
Width = 1815
End
Begin VB.ComboBox Combo2
Height = 315
Index = 3
ItemData = "frmGenerateMode.frx":0077
Left = 4320
List = "frmGenerateMode.frx":00A2
Style = 2 'Dropdown List
TabIndex = 8
Top = 240
Width = 1815
End
Begin VB.ComboBox Combo1
Height = 315
Index = 3
ItemData = "frmGenerateMode.frx":00FA
Left = 1200
List = "frmGenerateMode.frx":012E
Style = 2 'Dropdown List
TabIndex = 7
Top = 240
Width = 1815
End
Begin VB.CommandButton cmdGo
Caption = "&Connect"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 3120
TabIndex = 6
Top = 1560
Width = 975
End
Begin VB.CommandButton cmdStop
Caption = "D&isconnect"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 4200
TabIndex = 5
Top = 1560
Width = 1215
End
Begin VB.CommandButton cmdExit
Caption = "E&xit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 5520
TabIndex = 4
Top = 1560
Width = 615
End
Begin VB.ComboBox cmbChipSet
Height = 315
ItemData = "frmGenerateMode.frx":01A9
Left = 1200
List = "frmGenerateMode.frx":01B3
TabIndex = 3
Text = "Combo6"
Top = 2160
Width = 1815
End
Begin VB.Label Label2
Caption = "&Reset:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 3120
TabIndex = 21
Top = 1200
Width = 1095
End
Begin VB.Label Label1
Caption = "&Interval:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 3120
TabIndex = 20
Top = 720
Width = 1095
End
Begin VB.Label Label7
Caption = "&Stop bits:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 120
TabIndex = 19
Top = 1680
Width = 975
End
Begin VB.Label Label6
Caption = "&Parity:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 120
TabIndex = 18
Top = 1200
Width = 975
End
Begin VB.Label Label5
Caption = "&Data bits:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 120
TabIndex = 17
Top = 720
Width = 975
End
Begin VB.Label Label4
Caption = "Port &speed:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 3120
TabIndex = 16
Top = 270
Width = 1095
End
Begin VB.Label Label3
Caption = "&Port:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 120
TabIndex = 15
Top = 270
Width = 975
End
Begin VB.Label Label8
Caption = "Chipset:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 14
Top = 2160
Width = 975
End
End
Begin VB.TextBox Text1
Height = 285
Index = 0
Left = 0
Locked = -1 'True
TabIndex = 1
Text = "Text1"
Top = 0
Width = 9495
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 0
Top = 5430
Width = 9480
_ExtentX = 16722
_ExtentY = 529
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 3
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 13070
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "4/19/98"
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "4:14 PM"
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "frmGenerateInf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub EditCopy()
ActiveForm.Text1.SelStart = 0
ActiveForm.Text1.SelLength = Len(ActiveForm.Text1.Text)
ActiveForm.Text1.SetFocus
Clipboard.Clear
Clipboard.SetText ActiveForm.Text1.Text
End Sub
Public Sub EditPaste()
ActiveForm.Paste (Clipboard.GetText)
End Sub
|
<reponame>djgoku/RosettaCodeData<filename>Task/Tokenize-a-string/Visual-Basic/tokenize-a-string.vb<gh_stars>0
Sub Main()
Dim parseMe As String, parsed As Variant
parseMe = "Hello,How,Are,You,Today"
parsed = Split(parseMe, ",")
Dim L0 As Long, outP As String
outP = parsed(0)
For L0 = 1 To UBound(parsed)
outP = outP & "." & parsed(L0)
Next
MsgBox outP
End Sub
|
Option Explicit
Sub Main()
Dim Primes() As Long, n As Long, temp$
Dim t As Single
t = Timer
n = 133218295 'limit for an Array of Longs with VBA on my computer
Primes = ListPrimes(n)
Debug.Print "For N = " & Format(n, "#,##0") & ", execution time : " & _
Format(Timer - t, "0.000 s") & ", " & _
Format(UBound(Primes) + 1, "#,##0") & " primes numbers."
'First twenty primes
For n = 0 To 19
temp = temp & ", " & Primes(n)
Next
Debug.Print "First twenty primes : "; Mid(temp, 3)
'Primes between 100 and 150
n = 0: temp = vbNullString
Do While Primes(n) < 100
n = n + 1
Loop
Do While Primes(n) < 150
temp = temp & ", " & Primes(n)
n = n + 1
Loop
Debug.Print "Primes between 100 and 150 : " & Mid(temp, 3)
'Number of primes between 7,700 and 8,000
Dim ccount As Long
n = 0
Do While Primes(n) < 7700
n = n + 1
Loop
Do While Primes(n) < 8000
ccount = ccount + 1
n = n + 1
Loop
Debug.Print "Number of primes between 7,700 and 8,000 : " & ccount
'The 10 x Xth prime
n = 1
Do While n <= 100000
n = n * 10
Debug.Print "The " & n & "th prime: "; Format(Primes(n - 1), "#,##0")
Loop
Debug.Print "VBA has a limit in array's dim"
Debug.Print "With my computer, the limit for an array of Long is : 133 218 295"
Debug.Print "The last prime I could find is the : " & _
Format(UBound(Primes), "#,##0") & "th, Value : " & _
Format(Primes(UBound(Primes)), "#,##0")
End Sub
Function ListPrimes(MAX As Long) As Long()
Dim t() As Boolean, L() As Long, c As Long, s As Long, i As Long, j As Long
ReDim t(2 To MAX)
ReDim L(MAX \ 2)
s = Sqr(MAX)
For i = 3 To s Step 2
If t(i) = False Then
For j = i * i To MAX Step i
t(j) = True
Next
End If
Next i
L(0) = 2
For i = 3 To MAX Step 2
If t(i) = False Then
c = c + 1
L(c) = i
End If
Next i
ReDim Preserve L(c)
ListPrimes = L
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Sub Main()
Dim HttpReq As WinHttp.WinHttpRequest
' in the "references" dialog of the IDE, check
' "Microsoft WinHTTP Services, version 5.1" (winhttp.dll)
Const HTTPREQUEST_PROXYSETTING_PROXY As Long = 2
Const WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 As Long = &H80&
Const WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 As Long = &H200&
Const WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 As Long = &H800&
#Const USE_PROXY = 1
Set HttpReq = New WinHttp.WinHttpRequest
HttpReq.Open "GET", "https://groups.google.com/robots.txt"
HttpReq.Option(WinHttpRequestOption_SecureProtocols) = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 Or _
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 Or _
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2
#If USE_PROXY Then
HttpReq.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "my_proxy:80"
#End If
HttpReq.SetTimeouts 1000, 1000, 1000, 1000
HttpReq.Send
Debug.Print HttpReq.ResponseText
End Sub
|
Sub Main
MsgBox Command$
End Sub
|
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' VBScript Source File
'
' Script Name: IIsFtpDr.vbs
'
Option Explicit
On Error Resume Next
' Error codes
Const ERR_OK = 0
Const ERR_GENERAL_FAILURE = 1
'''''''''''''''''''''
' Messages
Const L_FtpDir_Message = "Ftp directory %1 has been DELETED"
Const L_InvalidPath_ErrorMessage = "Invalid site path."
Const L_VPath_Message = "Virtual Path"
Const L_Root_Message = "ROOT"
Const L_MetabasePath_Message = "Metabase Path"
Const L_AliasName_Text = "Alias"
Const L_Path_Text = "Physical Root"
Const L_Error_ErrorMessage = "Error &H%1: %2"
Const L_VDirDel_ErrorMessage = "Could not delete ftp directory."
Const L_CannotCreateDir_ErrorMessage = "Could not create root directory."
Const L_DirFormat_ErrorMessage = "Root directory format unknown. Please use the"
Const L_DirFormat2_ErrorMessage = "'<drive>:\<path>' format."
Const L_OperationRequired_ErrorMessage = "Please specify an operation before the arguments."
Const L_NotEnoughParam_ErrorMessage = "Not enough parameters."
Const L_Query_ErrorMessage = "Error occurred while querying WMI provider."
Const L_CmdLib_ErrorMessage = "Could not create an instance of the CmdLib object."
Const L_ChkCmdLibReg_ErrorMessage = "Please register the Microsoft.CmdLib component."
Const L_VDirExists1_ErrorMessage = "The FTP virtual directory %1 does not exist."
Const L_VDirExists2_ErrorMessage = "The FTP virtual directory %1 already exists."
Const L_VDirDoesntExist_ErrorMessage = "Virtual directory doesn't exist (%1)"
Const L_OnlyOneOper_ErrorMessage = "Please specify only one operation at a time."
Const L_ScriptHelper_ErrorMessage = "Could not create an instance of the IIsScriptHelper object."
Const L_ChkScpHelperReg_ErrorMessage = "Please register the Microsoft.IIsScriptHelper component."
Const L_VDirsNotFound_ErrorMessage = "No virtual sub-directories available."
Const L_SiteNotFound_ErrorMessage = "Could not find ftpsite %1"
Const L_PassWithoutUser_ErrorMessage = "Please specify /u switch before using /p."
Const L_WMIConnect_ErrorMessage = "Could not connect to WMI provider."
Const L_MapDrive_ErrorMessage = "Could not map network drive."
Const L_GetSetting_ErrorMessage = "Unable to get Setting class from IIS namespace."
Const L_CannotDelRoot_ErrorMessage = "Cannot delete the ROOT virtual directory. Please specify"
Const L_CannotDelRoot2_ErrorMessage = "another one."
Const L_KeyIsntVDir_ErrorMessage = "Specified metabase path is not a virtual directory."
Const L_CannotGetVDir_ErrorMessage = "Either the path specified does not exist or it is not an"
Const L_CannotGetVDir2_ErrorMessage = "FTP virtual directory. Please make sure the path specified"
Const L_CannotGetVDir3_ErrorMessage = "is valid."
Const L_InvalidAlias_ErrorMessage = "Alias contains invalid character(s)."
Const L_CannotGetParentVDir_ErrorMessage = "Error getting parent virtual directory."
Const L_ParentVDirNotPresent_ErrorMessage = "Parent virtual directory doesn't exist."
Const L_NotEnoughParams_ErrorMessage = "Not enough parameters."
Const L_InvalidSwitch_ErrorMessage = "Invalid switch: %1"
Const L_Admin_ErrorMessage = "You cannot run this command because you are not an"
Const L_Admin2_ErrorMessage = "administrator on the server you are trying to configure."
'''''''''''''''''''''
' Help
' General help messages
Const L_SeeHelp_Message = "Type IIsFtpDr /? for help."
Const L_SeeCreateHelp_Message = "Type IIsFtpDr /create /? for help."
Const L_SeeDeleteHelp_Message = "Type IIsFtpDr /delete /? for help."
Const L_SeeQueryHelp_Message = "Type IIsFtpDr /query /? for help."
Const L_Help_HELP_General01_Text = "Description: Create, delete, or query a ftp directory"
Const L_Help_HELP_General02_Text = "Syntax: IIsFtpDr [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_General03_Text = " /<operation> [arguments]"
Const L_Help_HELP_General04_Text = "Parameters:"
Const L_Help_HELP_General06_Text = "Value Description"
Const L_Help_HELP_General07_Text = "/s <server> Connect to machine <server>"
Const L_Help_HELP_General07a_Text = " [Default: this system]"
Const L_Help_HELP_General08_Text = "/u <username> Connect as <domain>\<username> or"
Const L_Help_HELP_General09_Text = " <username> [Default: current user]"
Const L_Help_HELP_General10_Text = "/p <password> Password for the <username> user"
Const L_Help_HELP_General11_Text = "<operation> /create Creates a ftp virtual directory"
Const L_Help_HELP_General12_Text = " on a specified ftp site."
Const L_Help_HELP_General13_Text = " /delete Deletes a ftp virtual directory"
Const L_Help_HELP_General14_Text = " from a specified ftp site."
Const L_Help_HELP_General15_Text = " /query Lists all virtual directories"
Const L_Help_HELP_General16_Text = " under the specified path."
Const L_Help_HELP_General17_Text = "For detailed usage:"
Const L_Help_HELP_General18_Text = "IIsFtpDr /create /?"
Const L_Help_HELP_General19_Text = "IIsFtpDr /delete /?"
Const L_Help_HELP_General20_Text = "IIsFtpDr /query /?"
' Common to all status change commands
Const L_Help_HELP_Common03_Text = "Parameters:"
Const L_Help_HELP_Common09_Text = "<ftpsite> Use either the site name or metabase"
Const L_Help_HELP_Common09p1_Text = " path to specify the site. (""Default"
Const L_Help_HELP_Common09p2_Text = " Ftp Site"" or msftpsvc/1)"
Const L_Help_HELP_Common10_Text = "<path> Virtual path for the new virtual"
Const L_Help_HELP_Common10p1_Text = " directory's parent. This virtual"
Const L_Help_HELP_Common10p2_Text = " path must already exist."
Const L_Help_HELP_Common11_Text = "Examples:"
' Delete help messages
Const L_Help_HELP_Delete01_Text = "Description: Deletes a ftp virtual directory from a"
Const L_Help_HELP_Delete01p1_Text = " specified ftp site."
Const L_Help_HELP_Delete02_Text = "Syntax: IIsFtpDr [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_Delete02p1_Text = " /delete <ftpsite>[/path]<alias>"
Const L_Help_HELP_Delete11_Text = "IIsFtpDr /delete ""My Site""/Mydir"
Const L_Help_HELP_Delete12_Text = "IIsFtpDr /delete msftpsvc/1/ROOT/Users/Public/Mydir"
Const L_Help_HELP_Delete13_Text = "IIsFtpDr /s Server1 /u Administrator /p p@ssWOrd /delete ""My Site""/Mydir"
' Query help messages
Const L_Help_HELP_Query01_Text = "Description: Lists all virtual directories under a given"
Const L_Help_HELP_Query01p1_Text = " path."
Const L_Help_HELP_Query02_Text = "Syntax: IIsFtpDr [/s <server> [/u <username> [/p <password>]]] /query"
Const L_Help_HELP_Query02p1_Text = " <ftpsite>[/path]"
Const L_Help_HELP_Query11_Text = "IIsFtpDr /query ""My Site"""
Const L_Help_HELP_Query12_Text = "IIsFtpDr /query msftpsvc/1/ROOT"
Const L_Help_HELP_Query13_Text = "IIsFtpDr /query ""My Site""/Users/Public"
Const L_Help_HELP_Query14_Text = "IIsFtpDr /s Server1 /u Administrator /p p@ssWOrd /query ""My Site""/Users"
' Create help messages
Const L_Help_HELP_Create01_Text = "Description: Creates a ftp virtual directory on a specified"
Const L_Help_HELP_Create01p1_Text = " ftp site."
Const L_Help_HELP_Create02_Text = "Syntax: IIsFtpDr [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_Create02p1_Text = " /create <ftpsite>[/path] <alias> <root>"
Const L_Help_HELP_Create11_Text = "<alias> The name of the virtual directory"
Const L_Help_HELP_Create12_Text = "<root> Physical path of the virtual"
Const L_Help_HELP_Create12p1_Text = " directory. If the physical path does"
Const L_Help_HELP_Create12p2_Text = " not exist, it will be created."
Const L_Help_HELP_Create15_Text = "IIsFtpDr /create ""My Site"" Mydir c:\mydir"
Const L_Help_HELP_Create16_Text = "IIsFtpDr /create msftpsvc/1/ROOT MyDir c:\mydir"
Const L_Help_HELP_Create17_Text = "IIsFtpDr /create ""My Site""/Users/Public Mydir c:\mydir"
Const L_Help_HELP_Create18_Text = "IIsFtpDr /s Server1 /u Administrator /p p@assWOrd /create ""My Site"" Mydir"
Const L_Help_HELP_Create19_Text = " c:\mydir"
''''''''''''''''''''''''
' Operation codes
Const OPER_DELETE = 1
Const OPER_CREATE = 2
Const OPER_QUERY = 3
'
' Main block
'
Dim oScriptHelper, oCmdLib
Dim strServer, strUser, strPassword, strSite
Dim strPath, strVPath, strAlias, strRoot
Dim intOperation, intResult
Dim aArgs, arg
Dim strCmdLineOptions
Dim oError
' Default values
strServer = "."
strUser = ""
strPassword = ""
intOperation = 0
strSite = ""
strPath = ""
' Instantiate the CmdLib for output string formatting
Set oCmdLib = CreateObject("Microsoft.CmdLib")
If Err.Number <> 0 Then
WScript.Echo L_CmdLib_ErrorMessage
WScript.Echo L_ChkCmdLibReg_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oCmdLib.ScriptingHost = WScript.Application
' Instantiate script helper object
Set oScriptHelper = CreateObject("Microsoft.IIsScriptHelper")
If Err.Number <> 0 Then
WScript.Echo L_ScriptHelper_ErrorMessage
WScript.Echo L_ChkScpHelperReg_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oScriptHelper.ScriptHost = WScript
' Check if we are being run with cscript.exe instead of wscript.exe
oScriptHelper.CheckScriptEngine
' Minimum number of parameters must exist
If WScript.Arguments.Count < 1 Then
WScript.Echo L_NotEnoughParam_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
strCmdLineOptions = "[server:s:1;user:u:1;password:p:1];delete:d:1;create:c:3;query:q:1"
Set oError = oScriptHelper.ParseCmdLineOptions(strCmdLineOptions)
If Not oError Is Nothing Then
If oError.ErrorCode = oScriptHelper.ERROR_NOT_ENOUGH_ARGS Then
' Not enough arguments for a specified switch
WScript.Echo L_NotEnoughParams_ErrorMessage
Select Case LCase(oError.SwitchName)
Case "create"
WScript.Echo L_SeeCreateHelp_Message
Case "delete"
WScript.Echo L_SeeDeleteHelp_Message
Case "query"
WScript.Echo L_SeeQueryHelp_Message
Case Else
WScript.Echo L_SeeHelp_Message
End Select
Else
' Invalid switch
oCmdLib.vbPrintf L_InvalidSwitch_ErrorMessage, Array(oError.SwitchName)
WScript.Echo L_SeeHelp_Message
End If
WScript.Quit(ERR_GENERAL_FAILURE)
End If
If oScriptHelper.GlobalHelpRequested Then
DisplayHelpMessage
WScript.Quit(ERR_OK)
End If
For Each arg In oScriptHelper.Switches
Select Case arg
Case "server"
' Server information
strServer = oScriptHelper.GetSwitch(arg)
Case "user"
' User information
strUser = oScriptHelper.GetSwitch(arg)
Case "password"
' Password information
strPassword = oScriptHelper.GetSwitch(arg)
Case "create"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_CREATE
If oScriptHelper.IsHelpRequested(arg) Then
DisplayCreateHelpMessage
WScript.Quit(ERR_OK)
End If
aArgs = oScriptHelper.GetSwitch(arg)
strVPath = aArgs(0)
strAlias = aArgs(1)
strRoot = aArgs(2)
Case "delete"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_DELETE
If oScriptHelper.IsHelpRequested(arg) Then
DisplayDeleteHelpMessage
WScript.Quit(ERR_OK)
End If
strPath = oScriptHelper.GetSwitch(arg)
Case "query"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_QUERY
If oScriptHelper.IsHelpRequested(arg) Then
DisplayQueryHelpMessage
WScript.Quit(ERR_OK)
End If
strPath = oScriptHelper.GetSwitch(arg)
End Select
Next
' Check Parameters
If (intOperation = 0) Then
WScript.Echo L_OperationRequired_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
' Check if /p is specified but /u isn't. In this case, we should bail out with an error
If oScriptHelper.Switches.Exists("password") And Not oScriptHelper.Switches.Exists("user") Then
WScript.Echo L_PassWithoutUser_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
' Check if /u is specified but /p isn't. In this case, we should ask for a password
If oScriptHelper.Switches.Exists("user") And Not oScriptHelper.Switches.Exists("password") Then
strPassword = oCmdLib.GetPassword
End If
' Initializes authentication with remote machine
intResult = oScriptHelper.InitAuthentication(strServer, strUser, strPassword)
If intResult <> 0 Then
WScript.Quit(intResult)
End If
' Choose operation
Select Case intOperation
Case OPER_CREATE
intResult = CreateFtpVDir(strVPath, strAlias, strRoot)
Case OPER_DELETE
intResult = DeleteFtpVDir(strPath)
Case OPER_QUERY
intResult = QueryFtpVDir(strPath)
End Select
' Return value to command processor
WScript.Quit(intResult)
'''''''''''''''''''''''''
' End Of Main Block
'''''''''''''''''''''
'''''''''''''''''''''''''''
' ParseSitePath
'''''''''''''''''''''''''''
Function ParseSitePath(strSitePath)
Dim iFirstSlash, iSecondSlash, iIndex
Dim strSite, strPath
Dim aPath, aFtpSites
On Error Resume Next
' Replace any existing back-slashes with forward-slashes
strSitePath = Replace(strSitePath, "\", "/")
aPath = Split(strSitePath, "/", -1)
' Fills strPath
If (UCase(aPath(0)) = "MSFTPSVC") Then
' First argument is a metabase path
If (UBound(aPath) < 1) Then
WScript.Echo L_InvalidPath_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
' Second array element must be a number (site ID)
If Not IsNumeric(aPath(1)) Then
WScript.Echo L_InvalidPath_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
' Second element of aPath should be the site number so ...
strPath = "MSFTPSVC/" & aPath(1)
' Call FindFtpSite to make sure ftp site exists
aFtpSites = oScriptHelper.FindSite("Ftp", Array(strPath))
If IsArray(aFtpSites) Then
If UBound(aFtpSites) = -1 Then
oCmdLib.vbPrintf L_SiteNotFound_ErrorMessage, Array(strPath)
ParseSitePath = Empty
Exit Function
End If
End If
strPath = strPath & "/ROOT"
strSitePath = strPath
' Check for ROOT string and grab the rest for strPath
iIndex = 1
If (UBound(aPath) > 1) Then
If (UCase(aPath(2)) = "ROOT") Then
iIndex = 2
End If
End If
Else
' First argument is a site name (server comment property)
' Call FindFtpSite to resolve site name to metabase path
aFtpSites = oScriptHelper.FindSite("Ftp", Array(aPath(0)))
If IsArray(aFtpSites) Then
If UBound(aFtpSites) = -1 Then
oCmdLib.vbPrintf L_SiteNotFound_ErrorMessage, Array(aPath(0))
ParseSitePath = Empty
Exit Function
Else
strPath = aFtpSites(0)
End If
Else
' Got duplicate sites. We should quit.
ParseSitePath = Empty
Exit Function
End If
strPath = strPath & "/ROOT"
strSitePath = aPath(0) & "/ROOT"
' Check for ROOT string and grab the rest for strPath
iIndex = 0
If (UBound(aPath) > 0) Then
If (UCase(aPath(1)) = "ROOT") Then
iIndex = 1
End If
End If
End If
' Build strPath
iIndex = iIndex + 1
Do While iIndex <= UBound(aPath)
If (aPath(iIndex) = "") Then
Exit Do
End If
strPath = strPath & "/" & aPath(iIndex)
strSitePath = strSitePath & "/" & aPath(iIndex)
iIndex = iIndex + 1
Loop
ParseSitePath = strPath
End Function
'''''''''''''''''''''''''''
' DisplayHelpMessage
'''''''''''''''''''''''''''
Sub DisplayHelpMessage()
WScript.Echo L_Help_HELP_General01_Text
WScript.Echo
WScript.Echo L_Help_HELP_General02_Text
WScript.Echo L_Help_HELP_General03_Text
WScript.Echo
WScript.Echo L_Help_HELP_General04_Text
WScript.Echo
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07a_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_General11_Text
WScript.Echo L_Help_HELP_General12_Text
WScript.Echo L_Help_HELP_General13_Text
WScript.Echo L_Help_HELP_General14_Text
WScript.Echo L_Help_HELP_General15_Text
WScript.Echo L_Help_HELP_General16_Text
WScript.Echo
WScript.Echo L_Help_HELP_General17_Text
WScript.Echo
WScript.Echo L_Help_HELP_General18_Text
WScript.Echo L_Help_HELP_General19_Text
WScript.Echo L_Help_HELP_General20_Text
End Sub
Sub DisplayDeleteHelpMessage()
WScript.Echo L_Help_HELP_Delete01_Text
WScript.Echo L_Help_HELP_Delete01p1_Text
WScript.Echo
WScript.Echo L_Help_HELP_Delete02_Text
WScript.Echo L_Help_HELP_Delete02p1_Text
WScript.Echo
WScript.Echo L_Help_HELP_Common03_Text
WScript.Echo
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07a_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_Common09_Text
WScript.Echo L_Help_HELP_Common09p1_Text
WScript.Echo L_Help_HELP_Common09p2_Text
WScript.Echo L_Help_HELP_Common10_Text
WScript.Echo L_Help_HELP_Common10p1_Text
WScript.Echo L_Help_HELP_Common10p2_Text
WScript.Echo
WScript.Echo L_Help_HELP_Common11_Text
WScript.Echo
WScript.Echo L_Help_HELP_Delete11_Text
WScript.Echo L_Help_HELP_Delete12_Text
WScript.Echo L_Help_HELP_Delete13_Text
End Sub
Sub DisplayCreateHelpMessage()
WScript.Echo L_Help_HELP_Create01_Text
WScript.Echo L_Help_HELP_Create01p1_Text
WScript.Echo
WScript.Echo L_Help_HELP_Create02_Text
WScript.Echo L_Help_HELP_Create02p1_Text
WScript.Echo
WScript.Echo L_Help_HELP_Common03_Text
WScript.Echo
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07a_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_Common09_Text
WScript.Echo L_Help_HELP_Common09p1_Text
WScript.Echo L_Help_HELP_Common09p2_Text
WScript.Echo L_Help_HELP_Common10_Text
WScript.Echo L_Help_HELP_Common10p1_Text
WScript.Echo L_Help_HELP_Common10p2_Text
WScript.Echo L_Help_HELP_Create11_Text
WScript.Echo L_Help_HELP_Create12_Text
WScript.Echo L_Help_HELP_Create12p1_Text
WScript.Echo L_Help_HELP_Create12p2_Text
WScript.Echo
WScript.Echo L_Help_HELP_Common11_Text
WScript.Echo
WScript.Echo L_Help_HELP_Create15_Text
WScript.Echo L_Help_HELP_Create16_Text
WScript.Echo L_Help_HELP_Create17_Text
WScript.Echo L_Help_HELP_Create18_Text
WScript.Echo L_Help_HELP_Create19_Text
End Sub
Sub DisplayQueryHelpMessage()
WScript.Echo L_Help_HELP_Query01_Text
WScript.Echo L_Help_HELP_Query01p1_Text
WScript.Echo
WScript.Echo L_Help_HELP_Query02_Text
WScript.Echo L_Help_HELP_Query02p1_Text
WScript.Echo
WScript.Echo L_Help_HELP_Common03_Text
WScript.Echo
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07a_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_Common09_Text
WScript.Echo L_Help_HELP_Common09p1_Text
WScript.Echo L_Help_HELP_Common09p2_Text
WScript.Echo L_Help_HELP_Common10_Text
WScript.Echo L_Help_HELP_Common10p1_Text
WScript.Echo L_Help_HELP_Common10p2_Text
WScript.Echo
WScript.Echo L_Help_HELP_Common11_Text
WScript.Echo
WScript.Echo L_Help_HELP_Query11_Text
WScript.Echo L_Help_HELP_Query12_Text
WScript.Echo L_Help_HELP_Query13_Text
WScript.Echo L_Help_HELP_Query14_Text
End Sub
'''''''''''''''''''''''''''
' DeleteFtpVDir
'''''''''''''''''''''''''''
Function DeleteFtpVDir(strVPath)
Dim strPath, ServiceObj
Dim rootVDirObj, providerObj
On Error Resume Next
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
ChangeFtpSiteStatus = Err.Number
Exit Function
End If
Set providerObj = oScriptHelper.ProviderObj
' Quick check to see if we have permission
Set ServiceObj = providerObj.Get("IIsFtpService='MSFTPSVC'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Admin2_ErrorMessage
Case Else
WScript.Echo Err.Description
End Select
DeleteFtpVDir = Err.Number
Exit Function
End If
strPath = ParseSitePath(strVPath)
If IsEmpty(strPath) Then
' Got problems parsing the path
WScript.Echo L_SeeDeleteHelp_Message
DeleteFtpVDir = ERR_GENERAL_FAILURE
Exit Function
End If
' Don't delete ROOT Vdir
If UCase(Right(strPath, 5)) = "/ROOT" Then
WScript.Echo L_CannotDelRoot_ErrorMessage
WScript.Echo L_CannotDelRoot2_ErrorMessage
DeleteFtpVDir = ERR_GENERAL_FAILURE
Exit Function
End If
' Check vdir existance
Set rootVDirObj = providerObj.Get("IIsFtpVirtualDir='" & strPath & "'")
If Err.Number Then
Select Case Err.Number
Case &H80041002
oCmdLib.vbPrintf L_VDirDoesntExist_ErrorMessage, Array(strVPath)
Case &H8004103A
WScript.Echo L_KeyIsntVDir_ErrorMessage
Case Else
oCmdLib.vbPrintf L_VDirExists1_ErrorMessage, Array(strVPath)
WScript.Echo L_CannotGetVDir_ErrorMessage
WScript.Echo L_CannotGetVDir2_ErrorMessage
WScript.Echo L_CannotGetVDir3_ErrorMessage
End Select
DeleteFtpVDir = Err.Number
Exit Function
End If
rootVDirObj.Delete_()
If Err.Number Then
WScript.Echo L_VDirDel_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
DeleteFtpVDir = Err.Number
Exit Function
End If
oCmdLib.vbPrintf L_FtpDir_Message, Array(strVPath)
DeleteFtpVDir = ERR_OK
End Function
'''''''''''''''''''''''''''
' CreateFtpVDir
'''''''''''''''''''''''''''
Function CreateFtpVDir(strVPath, strAlias, strRoot)
Dim strPath, strStatus, strNewVdir, strRootVDir
Dim vdirClassObj, serverObj, vdirObj, providerObj
Dim intResult, ServiceObj
On Error Resume Next
' Parse Alias for correctness
If InStr(strAlias, "/") <> 0 Or InStr(strAlias, "\") <> 0 Then
WScript.Echo L_InvalidAlias_ErrorMessage
WScript.Echo L_SeeCreateHelp_Message
CreateWebVDir = ERR_GENERAL_FAILURE
Exit Function
End If
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
CreateFtpVDir = Err.Number
Exit Function
End If
Set providerObj = oScriptHelper.ProviderObj
' Quick check to see if we have permission
Set ServiceObj = providerObj.Get("IIsFtpService='MSFTPSVC'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Admin2_ErrorMessage
Case Else
WScript.Echo Err.Description
End Select
CreateFtpVDir = Err.Number
Exit Function
End If
' Extract options from array to the correspondent variables
strPath = ParseSitePath(strVPath)
If IsEmpty(strPath) Then
' Got problems parsing the path
WScript.Echo L_SeeCreateHelp_Message
CreateFtpVDir = ERR_GENERAL_FAILURE
Exit Function
End If
' Build new vdir name
strNewVdir = strPath & "/" & strAlias
' Check if vdir already exists
Set vdirObj = providerObj.Get("IIsFtpVirtualDirSetting='" & strNewVdir & "'")
If Err.Number = 0 Then
oCmdLib.vbPrintf L_VDirExists2_ErrorMessage, Array(strNewVdir)
CreateFtpVDir = ERR_GENERAL_FAILURE
Exit Function
End If
Err.Clear
' Check if parent vdir exists
' We need to do this because FTP doesn't have the concept similar to a WebDirectory
Set vdirObj = providerObj.Get("IIsFtpVirtualDirSetting='" & strPath & "'")
If Err.Number Then
Select Case Err.Number
Case &H80041002
WScript.Echo L_ParentVDirNotPresent_ErrorMessage
Case Else
WScript.Echo L_CannotGetParentVDir_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
End Select
CreateFtpVDir = Err.Number
Exit Function
End If
' Create physical directory
oScriptHelper.CreateFSDir strRoot
If Err.Number Then
Select Case Err.Number
Case &H8007000C
WScript.Echo L_DirFormat_ErrorMessage
WScript.Echo L_DirFormat2_ErrorMessage
WScript.Echo L_SeeCreateHelp_Message
Case &H8007000F
WScript.Echo L_MapDrive_ErrorMessage
Case Else
WScript.Echo L_CannotCreateDir_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
End Select
CreateFtpVDir = Err.Number
Exit Function
End If
' Remove trailing slash (if present)
If (Right(strRoot, 1) = "\") Then
strRoot = Left(strRoot, Len(strRoot) - 1)
End If
' Create new ftp virtual directory
Set vdirClassObj = providerObj.Get("IIsFtpVirtualDirSetting")
Set vdirObj = vdirClassObj.SpawnInstance_()
vdirObj.Name = strNewVdir
vdirObj.Path = strRoot
' Set ftp virtual directory properties
vdirObj.AccessFlags = 1 ' read access
vdirObj.Put_()
' Remove trailing slash (if present)
If (Right(strVPath, 1) = "/") Then
strVPath = Left(strVPath, Len(strVPath) - 1)
End If
If (strServer = ".") Then
strServer = oScriptHelper.GetEnvironmentVar("%COMPUTERNAME%")
End If
' Post summary
WScript.Echo L_Server_Message & Space(14 - Len(L_Server_Message)) & "= " & UCase(strServer)
WScript.Echo L_VPath_Message & Space(14 - Len(L_VPath_Message)) & "= " & strVPath & "/" & strAlias
WScript.Echo L_Root_Message & Space(14 - Len(L_Root_Message)) & "= " & strRoot
WScript.Echo L_MetabasePath_Message & Space(14 - Len(L_MetabasePath_Message)) & "= " & strNewVdir
CreateFtpVDir = intResult
End Function
'''''''''''''''''''''''''''
' Helper Functions
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
' QueryFtpVDir
'''''''''''''''''''''''''''
Function QueryFtpVDir(strVDir)
Dim Servers, Server, strQuery
Dim bFirstIteration, ServiceObj
Dim vdirObj, providerObj
Dim strServer, strPath, strVDirName
Dim firstLen
On Error Resume Next
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
QueryFtpVDir = Err.Number
Exit Function
End If
Set providerObj = oScriptHelper.ProviderObj
' Quick check to see if we have permission
Set ServiceObj = providerObj.Get("IIsFtpService='MSFTPSVC'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Admin2_ErrorMessage
Case Else
WScript.Echo Err.Description
End Select
QueryFtpVDir = Err.Number
Exit Function
End If
strPath = ParseSitePath(strVDir)
If IsEmpty(strPath) Then
' Got problems parsing the path
WScript.Echo L_SeeQueryHelp_Message
QueryFtpVDir = ERR_GENERAL_FAILURE
Exit Function
End If
' Semi-sync query. (flags = ForwardOnly Or ReturnImediately = &H30)
strQuery = "ASSOCIATORS OF {IIsFtpVirtualDir=""" & strPath & """} WHERE ResultClass = IIsFtpVirtualDir " & _
"ResultRole = PartComponent"
Set Servers = providerObj.ExecQuery(strQuery, , &H30)
If (Err.Number <> 0) Then
WScript.Echo L_Query_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
QueryFtpVDir = Err.Number
Exit Function
End If
bFirstIteration = True
For Each Server in Servers
If Server.Name = "" Then
WScript.Echo L_CannotGetVDir_ErrorMessage
WScript.Echo L_CannotGetVDir2_ErrorMessage
WScript.Echo L_CannotGetVDir3_ErrorMessage
Exit Function
End If
If bFirstIteration Then
WScript.Echo L_AliasName_Text & Space(25 - Len(L_AliasName_Text)) & L_Path_Text
WScript.Echo "=============================================================================="
End If
Set vdirObj = providerObj.get("IIsFtpVirtualDirSetting=""" & Server.Name & """")
If (Err.Number <> 0) Then
WScript.Echo L_GetSetting_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
QueryFtpVDir = Err.Number
Exit Function
End If
' If this is the first binding list, print server comment and server name
strVDirName = Replace(vdirObj.Name, strPath, "") ', , , vbTextCompare)
firstLen = 25 - Len(strVDirName)
If (firstLen < 1) Then
firstLen = 1
End If
WScript.Echo strVDirName & Space(firstLen) & vdirObj.Path
bFirstIteration = False
Next
If bFirstIteration Then
WScript.Echo L_VDirsNotFound_ErrorMessage
End If
QueryFtpVDir = ERR_OK
End Function
|
<filename>admin/adminpak/dllsource/wistream.vbs<gh_stars>10-100
' Windows Installer utility to manage binary streams in an installer package
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) 1999-2001, Microsoft Corporation
' Demonstrates the use of the database _Streams table
' Used for entering non-database binary streams such as compressed file cabinets
' Streams that persist database binary values should be managed with table views
' Streams that persist database tables and system data are invisible in _Streams
'
Option Explicit
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Const msiOpenDatabaseModeCreate = 3
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const msiViewModifyAssign = 3
Const msiViewModifyReplace = 4
Const msiViewModifyDelete = 6
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
Const TristateTrue = -1
' Check arg count, and display help if argument not present or contains ?
Dim argCount:argCount = Wscript.Arguments.Count
If argCount > 0 Then If InStr(1, Wscript.Arguments(0), "?", vbTextCompare) > 0 Then argCount = 0
If (argCount = 0) Then
Wscript.Echo "Windows Installer database stream import utility" &_
vbNewLine & " 1st argument is the path to MSI database (installer package)" &_
vbNewLine & " 2nd argument is the path to a file containing the stream data" &_
vbNewLine & " If the 2nd argument is missing, streams will be listed" &_
vbNewLine & " 3rd argument is optional, the name used for the stream" &_
vbNewLine & " If the 3rd arugment is missing, the file name is used" &_
vbNewLine & " To remove a stream, use /D or -D as the 2nd argument" &_
vbNewLine & " followed by the name of the stream in the 3rd argument" &_
vbNewLine &_
vbNewLine & "Copyright (C) Microsoft Corporation, 1999-2001. All rights reserved."
Wscript.Quit 1
End If
' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
' Evaluate command-line arguments and set open and update modes
Dim databasePath:databasePath = Wscript.Arguments(0)
Dim openMode : If argCount = 1 Then openMode = msiOpenDatabaseModeReadOnly Else openMode = msiOpenDatabaseModeTransact
Dim updateMode : If argCount > 1 Then updateMode = msiViewModifyAssign 'Either insert or replace existing row
Dim importPath : If argCount > 1 Then importPath = Wscript.Arguments(1)
Dim streamName : If argCount > 2 Then streamName = Wscript.Arguments(2)
If streamName = Empty And importPath <> Empty Then streamName = Right(importPath, Len(importPath) - InStrRev(importPath, "\",-1,vbTextCompare))
If UCase(importPath) = "/D" Or UCase(importPath) = "-D" Then updateMode = msiViewModifyDelete : importPath = Empty 'Stream will be deleted if no input data
' Open database and create a view on the _Streams table
Dim sqlQuery : Select Case updateMode
Case msiOpenDatabaseModeReadOnly: sqlQuery = "SELECT `Name` FROM _Streams"
Case msiViewModifyAssign: sqlQuery = "SELECT `Name`,`Data` FROM _Streams"
Case msiViewModifyDelete: sqlQuery = "SELECT `Name` FROM _Streams WHERE `Name` = ?"
End Select
Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError
Dim view : Set view = database.OpenView(sqlQuery)
Dim record
If openMode = msiOpenDatabaseModeReadOnly Then 'If listing streams, simply fetch all records
Dim message, name
view.Execute : CheckError
Do
Set record = view.Fetch
If record Is Nothing Then Exit Do
name = record.StringData(1)
If message = Empty Then message = name Else message = message & vbNewLine & name
Loop
Wscript.Echo message
Else 'If adding a stream, insert a row, else if removing a stream, delete the row
Set record = installer.CreateRecord(2)
record.StringData(1) = streamName
view.Execute record : CheckError
If importPath <> Empty Then 'Insert stream - copy data into stream
record.SetStream 2, importPath : CheckError
Else 'Delete stream, fetch first to provide better error message if missing
Set record = view.Fetch
If record Is Nothing Then Wscript.Echo "Stream not present:", streamName : Wscript.Quit 2
End If
view.Modify updateMode, record : CheckError
database.Commit : CheckError
Set view = Nothing
Set database = Nothing
CheckError
End If
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText
End If
Wscript.Echo message
Wscript.Quit 2
End Sub
|
Debug.Print "Tom said, ""The fox ran away."""
Debug.Print "Tom said, 'The fox ran away.'"
|
Function pangram2(s As String) As Boolean
Const sKey As String = "<KEY>"
Dim sLow As String
Dim i As Integer
sLow = LCase(s)
For i = 1 To 26
If InStr(sLow, Mid(sKey, i, 1)) = 0 Then
pangram2 = False
Exit Function
End If
Next
pangram2 = True
End Function
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/pchealth/helpctr/bugrept/whistler/errcodes.vbs
'******************************************************************
' Copyright (c) 1999 Microsoft Corporation
'
' Module Name:
' ErrCodes.vbs
'
' Abstract:
' Error handling codes
'
'******************************************************************
'
' For example:
' 8xxxyyyy = Warning
' Cxxxyyyy = Error
' x007yyyy = Win32
' x009yyyy = Security
' x004yyyy = ITF
' x00Cyyyy = Internet
' x002yyyy = Dispatch
'
'
' Error return codes defined by Win32 in winerror.h
'
Const ERROR_INVALID_FUNCTION = &H1
Const ERROR_FILE_NOT_FOUND = &H80070002
Const ERROR_PATH_NOT_FOUND = &H80070003
Const ERROR_TOO_MANY_OPEN_FILES = &H4
Const ERROR_ACCESS_DENIED = &H5
Const ERROR_INVALID_HANDLE = &H6
Const ERROR_SHARING_VIOLATION = &H80070020
'
' Error return codes defined by COM in winerror.h
'
Const NOERROR = &H0
Const E_UNEXPECTED = &H8000FFFF
Const E_NOTIMPL = &H80004001
Const E_OUTOFMEMORY = &H8007000E
Const E_INVALIDARG = &H80070057
Const E_NOINTERFACE = &H80004002
Const E_POINTER = &H80004003
Const E_HANDLE = &H80070006
Const E_ABORT = &H80004004
Const E_FAIL = &H80004005
Const E_ACCESSDENIED = &H80070005
'
' Error return codes defined by Upload Library
'
Const E_UPLOADLIBRARY_NOT_AUTHENTICATED = &H80041001
Const E_UPLOADLIBRARY_ACCESS_DENIED = &H80041002
Const E_UPLOADLIBRARY_SERVER_QUOTA_EXCEEDED = &H80041003
Const E_UPLOADLIBRARY_SERVER_BUSY = &H80041004
Const E_UPLOADLIBRARY_NO_DATA = &H80041005
Const E_UPLOADLIBRARY_INVALID_PARAMETERS = &H80041006
Const E_UPLOADLIBRARY_CLIENT_QUOTA_EXCEEDED = &H80041007
Const E_UPLOADLIBRARY_WRONG_SERVER_VERSION = &H80041008
Const E_UPLOADLIBRARY_UNEXPECTED_RESPONSE = &H80041009
'
' Error return codes defined by wininet in wininet.h
'
'
' Internet API error returns
'
Const ERROR_INTERNET_OUT_OF_HANDLES = &H80072EE1
Const ERROR_INTERNET_TIMEOUT = &H80072EE2
Const ERROR_INTERNET_EXTENDED_ERROR = &H80072EE3
Const ERROR_INTERNET_INTERNAL_ERROR = &H80072EE4
Const ERROR_INTERNET_INVALID_URL = &H80072EE5
Const ERROR_INTERNET_UNRECOGNIZED_SCHEME = &H80072EE6
Const ERROR_INTERNET_NAME_NOT_RESOLVED = &H80072EE7
Const ERROR_INTERNET_PROTOCOL_NOT_FOUND = &H80072EE8
Const ERROR_INTERNET_INVALID_OPTION = &H80072EE9
Const ERROR_INTERNET_BAD_OPTION_LENGTH = &H80072EEA
Const ERROR_INTERNET_OPTION_NOT_SETTABLE = &H80072EEB
Const ERROR_INTERNET_SHUTDOWN = &H80072EEC
Const ERROR_INTERNET_INCORRECT_USER_NAME = &H80072EED
Const ERROR_INTERNET_INCORRECT_PASSWORD = &H<PASSWORD>
Const ERROR_INTERNET_LOGIN_FAILURE = &H80072EEF
Const ERROR_INTERNET_INVALID_OPERATION = &H80072EF0
Const ERROR_INTERNET_OPERATION_CANCELLED = &H80072EF1
Const ERROR_INTERNET_INCORRECT_HANDLE_TYPE = &H80072EF2
Const ERROR_INTERNET_INCORRECT_HANDLE_STATE = &H80072EF3
Const ERROR_INTERNET_NOT_PROXY_REQUEST = &H80072EF4
Const ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND = &H80072EF5
Const ERROR_INTERNET_BAD_REGISTRY_PARAMETER = &H80072EF6
Const ERROR_INTERNET_NO_DIRECT_ACCESS = &H80072EF7
Const ERROR_INTERNET_NO_CONTEXT = &H80072EF8
Const ERROR_INTERNET_NO_CALLBACK = &H80072EF9
Const ERROR_INTERNET_REQUEST_PENDING = &H80072EFA
Const ERROR_INTERNET_INCORRECT_FORMAT = &H80072EFB
Const ERROR_INTERNET_ITEM_NOT_FOUND = &H80072EFC
Const ERROR_INTERNET_CANNOT_CONNECT = &H80072EFD
Const ERROR_INTERNET_CONNECTION_ABORTED = &H80072EFE
Const ERROR_INTERNET_CONNECTION_RESET = &H80072EFF
Const ERROR_INTERNET_FORCE_RETRY = &H80072F00
Const ERROR_INTERNET_INVALID_PROXY_REQUEST = &H80072F01
Const ERROR_INTERNET_NEED_UI = &H80072F02
Const ERROR_INTERNET_HANDLE_EXISTS = &H80072F04
Const ERROR_INTERNET_SEC_CERT_DATE_INVALID = &H80072F05
Const ERROR_INTERNET_SEC_CERT_CN_INVALID = &H80072F06
Const ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR = &H80072F07
Const ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR = &H80072F08
Const ERROR_INTERNET_MIXED_SECURITY = &H80072F09
Const ERROR_INTERNET_CHG_POST_IS_NON_SECURE = &H80072F0A
Const ERROR_INTERNET_POST_IS_NON_SECURE = &H80072F0B
Const ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED = &H80072F0C
Const ERROR_INTERNET_INVALID_CA = &H80072F0D
Const ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP = &H80072F0E
Const ERROR_INTERNET_ASYNC_THREAD_FAILED = &H80072F0F
Const ERROR_INTERNET_REDIRECT_SCHEME_CHANGE = &H80072F10
Const ERROR_INTERNET_DIALOG_PENDING = &H80072F11
Const ERROR_INTERNET_RETRY_DIALOG = &H80072F12
Const ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR = &H80072F14
Const ERROR_INTERNET_INSERT_CDROM = &H80072F15
Const ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED = &H80072F16
Const ERROR_INTERNET_SEC_CERT_ERRORS = &H80072F17
Const ERROR_INTERNET_SEC_CERT_NO_REV = &H80072F18
Const ERROR_INTERNET_SEC_CERT_REV_FAILED = &H80072F19
'
' HTTP API errors
'
Const ERROR_HTTP_HEADER_NOT_FOUND = &H80072F76
Const ERROR_HTTP_DOWNLEVEL_SERVER = &H80072F77
Const ERROR_HTTP_INVALID_SERVER_RESPONSE = &H80072F78
Const ERROR_HTTP_INVALID_HEADER = &H80072F79
Const ERROR_HTTP_INVALID_QUERY_REQUEST = &H80072F7A
Const ERROR_HTTP_HEADER_ALREADY_EXISTS = &H80072F7B
Const ERROR_HTTP_REDIRECT_FAILED = &H80072F7C
Const ERROR_HTTP_NOT_REDIRECTED = &H80072F80
Const ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION = &H80072F81
Const ERROR_HTTP_COOKIE_DECLINED = &H80072F82
Const ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION = &H80072F88
'
' additional Internet API error codes
'
Const ERROR_INTERNET_SECURITY_CHANNEL_ERROR = &H80072F7D
Const ERROR_INTERNET_UNABLE_TO_CACHE_FILE = &H80072F7E
Const ERROR_INTERNET_TCPIP_NOT_INSTALLED = &H80072F7F
Const ERROR_INTERNET_DISCONNECTED = &H80072F83
Const ERROR_INTERNET_SERVER_UNREACHABLE = &H80072F84
Const ERROR_INTERNET_PROXY_SERVER_UNREACHABLE = &H80072F85
Const ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT = &H80072F86
Const ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT = &H80072F87
Const ERROR_INTERNET_SEC_INVALID_CERT = &H80072F89
Const ERROR_INTERNET_SEC_CERT_REVOKED = &H80072F8A
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: ERR_GetJobErrorCodeString
'
' Function: Creates a string representation of the IMPCUploadJob::ErrorCode
' property. The errors come from the UploadManager.idl file, from
' winerror.h, and from wininet.h.
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ERR_GetJobErrorCodeString(lErrorCode)
if (fDebug) then WScript.Echo "DEBUG: Function GetJobErrorCodeString"
Dim szErrorCode
Select Case CLng(lErrorCode)
'
' Win32 Errors
'
case ERROR_INVALID_FUNCTION
szErrorCode = "ERROR_INVALID_FUNCTION"
case ERROR_FILE_NOT_FOUND
szErrorCode = "ERROR_FILE_NOT_FOUND"
case ERROR_PATH_NOT_FOUND
szErrorCode = "ERROR_PATH_NOT_FOUND"
case ERROR_TOO_MANY_OPEN_FILES
szErrorCode = "ERROR_TOO_MANY_OPEN_FILES"
case ERROR_ACCESS_DENIED
szErrorCode = "ERROR_ACCESS_DENIED"
case ERROR_INVALID_HANDLE
szErrorCode = "ERROR_INVALID_HANDLE"
case ERROR_SHARING_VIOLATION
szErrorCode = "ERROR_SHARING_VIOLATION"
'
' COM errors
'
case NOERROR
szErrorCode = "NOERROR"
case E_UNEXPECTED
szErrorCode = "E_UNEXPECTED"
case E_NOTIMPL
szErrorCode = "E_NOTIMPL"
case E_OUTOFMEMORY
szErrorCode = "E_OUTOFMEMORY"
case E_INVALIDARG
szErrorCode = "E_INVALIDARG"
case E_NOINTERFACE
szErrorCode = "E_NOINTERFACE"
case E_POINTER
szErrorCode = "E_POINTER"
case E_HANDLE
szErrorCode = "E_HANDLE"
case E_ABORT
szErrorCode = "E_ABORT"
case E_FAIL
szErrorCode = "E_FAIL"
case E_ACCESSDENIED
szErrorCode = "E_ACCESSDENIED"
'
'PCHealth Transport Library errors
'
case E_UPLOADLIBRARY_NOT_AUTHENTICATED
szErrorCode = "E_UPLOADLIBRARY_NOT_AUTHENTICATED"
case E_UPLOADLIBRARY_ACCESS_DENIED
szErrorCode = "E_UPLOADLIBRARY_ACCESS_DENIED"
case E_UPLOADLIBRARY_SERVER_QUOTA_EXCEEDED
szErrorCode = "E_UPLOADLIBRARY_SERVER_QUOTA_EXCEEDED"
case E_UPLOADLIBRARY_SERVER_BUSY
szErrorCode = "E_UPLOADLIBRARY_SERVER_BUSY"
case E_UPLOADLIBRARY_NO_DATA
szErrorCode = "E_UPLOADLIBRARY_NO_DATA"
case E_UPLOADLIBRARY_INVALID_PARAMETERS
szErrorCode = "E_UPLOADLIBRARY_INVALID_PARAMETERS"
case E_UPLOADLIBRARY_CLIENT_QUOTA_EXCEEDED
szErrorCode = "E_UPLOADLIBRARY_CLIENT_QUOTA_EXCEEDED"
case E_UPLOADLIBRARY_WRONG_SERVER_VERSION
szErrorCode = "E_UPLOADLIBRARY_WRONG_SERVER_VERSION"
case E_UPLOADLIBRARY_UNEXPECTED_RESPONSE
szErrorCode = "E_UPLOADLIBRARY_UNEXPECTED_RESPONSE"
'
' Internet API error returns
'
case ERROR_INTERNET_OUT_OF_HANDLES
szErrorCode = "ERROR_INTERNET_OUT_OF_HANDLES"
case ERROR_INTERNET_TIMEOUT
szErrorCode = "ERROR_INTERNET_TIMEOUT"
case ERROR_INTERNET_EXTENDED_ERROR
szErrorCode = "ERROR_INTERNET_EXTENDED_ERROR"
case ERROR_INTERNET_INTERNAL_ERROR
szErrorCode = "ERROR_INTERNET_INTERNAL_ERROR"
case ERROR_INTERNET_INVALID_URL
szErrorCode = "ERROR_INTERNET_INVALID_URL"
case ERROR_INTERNET_UNRECOGNIZED_SCHEME
szErrorCode = "ERROR_INTERNET_UNRECOGNIZED_SCHEME"
case ERROR_INTERNET_NAME_NOT_RESOLVED
szErrorCode = "ERROR_INTERNET_NAME_NOT_RESOLVED"
case ERROR_INTERNET_PROTOCOL_NOT_FOUND
szErrorCode = "ERROR_INTERNET_PROTOCOL_NOT_FOUND"
case ERROR_INTERNET_INVALID_OPTION
szErrorCode = "ERROR_INTERNET_INVALID_OPTION"
case ERROR_INTERNET_BAD_OPTION_LENGTH
szErrorCode = "ERROR_INTERNET_BAD_OPTION_LENGTH"
case ERROR_INTERNET_OPTION_NOT_SETTABLE
szErrorCode = "ERROR_INTERNET_OPTION_NOT_SETTABLE"
case ERROR_INTERNET_SHUTDOWN
szErrorCode = "ERROR_INTERNET_SHUTDOWN"
case ERROR_INTERNET_INCORRECT_USER_NAME
szErrorCode = "ERROR_INTERNET_INCORRECT_USER_NAME"
case ERROR_INTERNET_INCORRECT_PASSWORD
szErrorCode = "ERROR_INTERNET_INCORRECT_PASSWORD"
case ERROR_INTERNET_LOGIN_FAILURE
szErrorCode = "ERROR_INTERNET_LOGIN_FAILURE"
case ERROR_INTERNET_INVALID_OPERATION
szErrorCode = "ERROR_INTERNET_INVALID_OPERATION"
case ERROR_INTERNET_OPERATION_CANCELLED
szErrorCode = "ERROR_INTERNET_OPERATION_CANCELLED"
case ERROR_INTERNET_INCORRECT_HANDLE_TYPE
szErrorCode = "ERROR_INTERNET_INCORRECT_HANDLE_TYPE"
case ERROR_INTERNET_INCORRECT_HANDLE_STATE
szErrorCode = "ERROR_INTERNET_INCORRECT_HANDLE_STATE"
case ERROR_INTERNET_NOT_PROXY_REQUEST
szErrorCode = "ERROR_INTERNET_NOT_PROXY_REQUEST"
case ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND
szErrorCode = "ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND"
case ERROR_INTERNET_BAD_REGISTRY_PARAMETER
szErrorCode = "ERROR_INTERNET_BAD_REGISTRY_PARAMETER"
case ERROR_INTERNET_NO_DIRECT_ACCESS
szErrorCode = "ERROR_INTERNET_NO_DIRECT_ACCESS"
case ERROR_INTERNET_NO_CONTEXT
szErrorCode = "ERROR_INTERNET_NO_CONTEXT"
case ERROR_INTERNET_NO_CALLBACK
szErrorCode = "ERROR_INTERNET_NO_CALLBACK"
case ERROR_INTERNET_REQUEST_PENDING
szErrorCode = "ERROR_INTERNET_REQUEST_PENDING"
case ERROR_INTERNET_INCORRECT_FORMAT
szErrorCode = "ERROR_INTERNET_INCORRECT_FORMAT"
case ERROR_INTERNET_ITEM_NOT_FOUND
szErrorCode = "ERROR_INTERNET_ITEM_NOT_FOUND"
case ERROR_INTERNET_CANNOT_CONNECT
szErrorCode = "ERROR_INTERNET_CANNOT_CONNECT"
case ERROR_INTERNET_CONNECTION_ABORTED
szErrorCode = "ERROR_INTERNET_CONNECTION_ABORTED"
case ERROR_INTERNET_CONNECTION_RESET
szErrorCode = "ERROR_INTERNET_CONNECTION_RESET"
case ERROR_INTERNET_FORCE_RETRY
szErrorCode = "ERROR_INTERNET_FORCE_RETRY"
case ERROR_INTERNET_INVALID_PROXY_REQUEST
szErrorCode = "ERROR_INTERNET_INVALID_PROXY_REQUEST"
case ERROR_INTERNET_NEED_UI
szErrorCode = "ERROR_INTERNET_NEED_UI"
case ERROR_INTERNET_HANDLE_EXISTS
szErrorCode = "ERROR_INTERNET_HANDLE_EXISTS"
case ERROR_INTERNET_SEC_CERT_DATE_INVALID
szErrorCode = "ERROR_INTERNET_SEC_CERT_DATE_INVALID"
case ERROR_INTERNET_SEC_CERT_CN_INVALID
szErrorCode = "ERROR_INTERNET_SEC_CERT_CN_INVALID"
case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
szErrorCode = "ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR"
case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
szErrorCode = "ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR"
case ERROR_INTERNET_MIXED_SECURITY
szErrorCode = "ERROR_INTERNET_MIXED_SECURITY"
case ERROR_INTERNET_CHG_POST_IS_NON_SECURE
szErrorCode = "ERROR_INTERNET_CHG_POST_IS_NON_SECURE"
case ERROR_INTERNET_POST_IS_NON_SECURE
szErrorCode = "ERROR_INTERNET_POST_IS_NON_SECURE"
case ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
szErrorCode = "ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED"
case ERROR_INTERNET_INVALID_CA
szErrorCode = "ERROR_INTERNET_INVALID_CA"
case ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP
szErrorCode = "ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP"
case ERROR_INTERNET_ASYNC_THREAD_FAILED
szErrorCode = "ERROR_INTERNET_ASYNC_THREAD_FAILED"
case ERROR_INTERNET_REDIRECT_SCHEME_CHANGE
szErrorCode = "ERROR_INTERNET_REDIRECT_SCHEME_CHANGE"
case ERROR_INTERNET_DIALOG_PENDING
szErrorCode = "ERROR_INTERNET_DIALOG_PENDING"
case ERROR_INTERNET_RETRY_DIALOG
szErrorCode = "ERROR_INTERNET_RETRY_DIALOG"
case ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
szErrorCode = "ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR"
case ERROR_INTERNET_INSERT_CDROM
szErrorCode = "ERROR_INTERNET_INSERT_CDROM"
case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
szErrorCode = "ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED"
case ERROR_INTERNET_SEC_CERT_ERRORS
szErrorCode = "ERROR_INTERNET_SEC_CERT_ERRORS"
case ERROR_INTERNET_SEC_CERT_NO_REV
szErrorCode = "ERROR_INTERNET_SEC_CERT_NO_REV"
case ERROR_INTERNET_SEC_CERT_REV_FAILED
szErrorCode = "ERROR_INTERNET_SEC_CERT_REV_FAILED"
'
' HTTP API errors
'
case ERROR_HTTP_HEADER_NOT_FOUND
szErrorCode = "ERROR_HTTP_HEADER_NOT_FOUND"
case ERROR_HTTP_DOWNLEVEL_SERVER
szErrorCode = "ERROR_HTTP_DOWNLEVEL_SERVER"
case ERROR_HTTP_INVALID_SERVER_RESPONSE
szErrorCode = "ERROR_HTTP_INVALID_SERVER_RESPONSE"
case ERROR_HTTP_INVALID_HEADER
szErrorCode = "ERROR_HTTP_INVALID_HEADER"
case ERROR_HTTP_INVALID_QUERY_REQUEST
szErrorCode = "ERROR_HTTP_INVALID_QUERY_REQUEST"
case ERROR_HTTP_HEADER_ALREADY_EXISTS
szErrorCode = "ERROR_HTTP_HEADER_ALREADY_EXISTS"
case ERROR_HTTP_REDIRECT_FAILED
szErrorCode = "ERROR_HTTP_REDIRECT_FAILED"
case ERROR_HTTP_NOT_REDIRECTED
szErrorCode = "ERROR_HTTP_NOT_REDIRECTED"
case ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
szErrorCode = "ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION"
case ERROR_HTTP_COOKIE_DECLINED
szErrorCode = "ERROR_HTTP_COOKIE_DECLINED"
case ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
szErrorCode = "ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION"
'
' additional Internet API error codes
'
case ERROR_INTERNET_SECURITY_CHANNEL_ERROR
szErrorCode = "ERROR_INTERNET_SECURITY_CHANNEL_ERROR"
case ERROR_INTERNET_UNABLE_TO_CACHE_FILE
szErrorCode = "ERROR_INTERNET_UNABLE_TO_CACHE_FILE"
case ERROR_INTERNET_TCPIP_NOT_INSTALLED
szErrorCode = "ERROR_INTERNET_TCPIP_NOT_INSTALLED"
case ERROR_INTERNET_DISCONNECTED
szErrorCode = "ERROR_INTERNET_DISCONNECTED"
case ERROR_INTERNET_SERVER_UNREACHABLE
szErrorCode = "ERROR_INTERNET_SERVER_UNREACHABLE"
case ERROR_INTERNET_PROXY_SERVER_UNREACHABLE
szErrorCode = "ERROR_INTERNET_PROXY_SERVER_UNREACHABLE"
case ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
szErrorCode = "ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT"
case ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
szErrorCode = "ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT"
case ERROR_INTERNET_SEC_INVALID_CERT
szErrorCode = "ERROR_INTERNET_SEC_INVALID_CERT"
case ERROR_INTERNET_SEC_CERT_REVOKED
szErrorCode = "ERROR_INTERNET_SEC_CERT_REVOKED"
case else
szErrorCode = "Unknown(0x" & hex(lErrorCode) & ")"
End Select
ERR_GetJobErrorCodeString = szErrorCode
End Function
|
<gh_stars>1-10
Private Sub cmdClear_Click()
txtHello.Text = ""
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdHello_Click()
txtHello.Text = "Hello World!"
With txtHello
.Font = "Arial"
.FontSize = 16
.ForeColor = vbBlue
End With
End Sub
|
<filename>Task/Pick-random-element/VBA/pick-random-element.vba<gh_stars>1-10
Option Explicit
Sub Main_Pick_Random_Element()
Debug.Print Pick_Random_Element(Array(1, 2, 3, 4, 5, #11/24/2017#, "azerty"))
End Sub
Function Pick_Random_Element(myArray)
Randomize Timer
Pick_Random_Element = myArray(Int((Rnd * (UBound(myArray) - LBound(myArray) + 1) + LBound(myArray))))
End Function
|
<reponame>npocmaka/Windows-Server-2003
'+---------------------------------------------------------------------
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' Copyright (c) Microsoft Corporation, 1999-2001. All Rights Reserved.
'
' PROGRAM: qu.vbs
'
' PURPOSE: Illustrates using VBScript, Query Helper API, and Admin
' Helper API with Windows Scripting Host to query Indexing
' Service and to determine the catalog status. The script
' functions similarly to the C++ Simple(QSample) sample.
'
' PLATFORM: Windows 2000
'
'----------------------------------------------------------------------
main
'----------------------------------------------------------------------
sub Main
if WScript.Arguments.Count < 1 then call Usage end if
' set defaults for all arguments
query = ""
catalog = "system"
locale = ""
forceci = TRUE
forcemerge = FALSE
inputfile = ""
shallow = FALSE
dialect = 1
machine = "."
columns = "path"
scope = "\"
quiet = FALSE
sort = ""
groupby = ""
stats = FALSE
uptodate = FALSE
maxhits = 0
firsthits = FALSE
repeat = 1
' parse command line arguments
for i = 0 to WScript.Arguments.Count - 1
arg = WScript.Arguments( i )
first = left( arg, 1 )
c = mid( arg, 2, 1 )
if "/" = first or "-" = first then
if ":" = mid( arg, 3, 1 ) then
v = mid( arg, 4 )
select case c
case "a" groupby = v
case "c" catalog = v
case "e" locale = v
case "f" forceci = ( v = "+" )
case "i" inputfile = v
case "l" dialect = v
case "m" machine = v
case "o" columns = v
case "p" scope = v
case "r" repeat = v
case "s" sort = v
case "x" maxhits = v
case "y" maxhits = v
firsthits = TRUE
case else Usage
end select
else
select case c
case "g" forcemerge = TRUE
case "j" shallow = TRUE
case "q" quiet = TRUE
case "t" stats = TRUE
case "u" uptodate = TRUE
case else Usage
end select
end if
else
if "" = query then query = arg else Usage
end if
next
' Turn a relative scope path into an absolute path
if "\" <> scope and "\\" <> left( scope, 2 ) then
set fso = WScript.CreateObject( "Scripting.FileSystemObject" )
scope = fso.GetAbsolutePathName( scope )
end if
for i = 1 to repeat
if "" = inputfile then
if "" = query and not ( stats or uptodate or forcemerge ) then
Usage
end if
DoQuery query, catalog, locale, forceci, forcemerge, shallow, dialect, machine, columns, scope, quiet, sort, stats, uptodate, maxhits, firsthits, groupby
else
if "" <> query then call Usage
' Open the input file and treat each line as a query.
' Report errors, but don't stop reading queries.
set fs = WScript.CreateObject( "Scripting.FileSystemObject" )
set f = fs.OpenTextFile( inputfile, 1 )
do until f.AtEndOfStream
line = f.ReadLine
on error resume next
DoQuery line, catalog, locale, forceci, forcemerge, shallow, dialect, machine, columns, scope, quiet, sort, stats, uptodate, maxhits, firsthits, groupby
if 0 <> Err.Number then
out Err.Description
out "The query '" & line & "' failed, error 0x" & Hex( Err.Number )
Err.Clear
end if
out ""
loop
end if
next
end sub
'----------------------------------------------------------------------
sub Out( str )
WScript.echo str
end sub
sub Out2( num, str )
out right( space( 9 ) & num, 9 ) & " " & str
end sub
'----------------------------------------------------------------------
sub Usage
out "usage: cscript qu.vbs <query> [arguments]"
out " <query> An Indexing Service query."
out " arguments:"
out " /a:groupby Columns over which results are grouped."
out " /c:catalog Name of the catalog, default is SYSTEM."
out " /e:locale ISO locale identifier, e.g. EN-US; default is system locale."
out " /f:(+|-) + or -, for force use of index. Default is +."
out " /g Force a master merge."
out " /i:inputfile Text input file with queries, one per line."
out " /j Just return files in the scope path, and not subdirectories."
out " /l:dialect 1 or 2, for old or new dialect, default is 1."
out " /m:machine Name of the machine, default is local machine."
out " /o:columns Output column list, default is path."
out " /p:scope The scope path of the query, absolute or relative."
out " /q Quiet. Don't display info other than query results."
out " /r:# Number of times to repeat the command."
out " /s:sort Sort column list, default is none. e.g.: write[d]."
out " Append [a] for ascending (default) or [d] for descending."
out " /t Display catalog statistics."
out " /u Check if the catalog is up to date."
out " /x:maxhits Maximum number of hits to retrieve, default is no limit."
out " /y:firsthits Only look at the first N hits."
out ""
out " examples: cscript qu.vbs mango /o:size,path"
out " cscript qu.vbs ""peach and not apple"" /s:rank[d] /p:."
out " cscript qu.vbs ""@size > 1000000"" /o:size,path /s:size[a] /m:dogfood"
out " cscript qu.vbs ""@docauthor joe"" /o:docauthor,path /s:docauthor,path"
out " cscript qu.vbs apricot /p:c:\\files"
out " cscript qu.vbs /m:index1 /c:sources pear"
out ""
out " columns: path vpath directory filename write create size attrib"
out " rank hitcount workid fileindex"
out " docauthor doclastauthor dockeywords docsubject doctitle"
out ""
out " locales: af ar-ae ar-bh ar-dz ar-eg ar-iq ar-jo ar-kw ar-lb"
out " ar-ly ar-ma ar-om ar-qa ar-sa ar-sy ar-tn ar-ye be"
out " bg ca cs da de de-at de-ch de-li de-lu e en en"
out " en-au en-bz en-ca en-gb en-ie en-jm en-nz en-tt"
out " en-us en-za es es es-ar es-bo es-c es-co es-cr"
out " es-do es-ec es-gt es-hn es-mx es-ni es-pa es-pe"
out " es-pr es-py es-sv es-uy es-ve et eu fa fi fo fr"
out " fr-be fr-ca fr-ch fr-lu gd gd-ie he hi hr hu in"
out " is it it-ch ja ji ko ko lt lv mk ms mt n neutr"
out " nl-be no no p pt pt-br rm ro ro-mo ru ru-mo s sb"
out " sk sq sr sr sv sv-fi sx sz th tn tr ts uk ur ve"
out " vi xh zh-cn zh-hk zh-sg zh-tw zu"
WScript.Quit( 2 )
end sub
'----------------------------------------------------------------------
function FormatValue( v, t )
if 7 = t or 137 = t then
w = 21
elseif 2 = t or 3 = t or 4 = t or 5 = t or 14 = t or 17 = t or 18 = t or 19 = t then
w = 7
elseif 20 = t or 21 = t then
w = 12
else
w = 0
end if
if 0 = w then
r = v
else
r = right( space( w ) & v, w )
end if
FormatValue = r
end function
'----------------------------------------------------------------------
function DisplayGroupedRowset( rs, level )
const cRowsToGet = 20
rs.CacheSize = cRowsToGet
cHits = 0
do until rs.EOF
row = ""
fChild = FALSE
for c = 0 to rs.Fields.Count - 1
if rs( c ).Name <> "Chapter" then
row = row & " " & rs( c ).Value
else
set rsChild = rs.Fields( "Chapter" ).Value
fChild = TRUE
end if
next
out space( level * 2 ) & row
cHits = cHits + 1
if fChild then
x = DisplayGroupedRowset( rsChild, level + 1 )
rsChild.Close
set rsChild = nothing
end if
rs.MoveNext
loop
DisplayGroupedRowset = cHits
end function
'----------------------------------------------------------------------
function DisplayRowset( rs )
' Display the results, 20 rows at a time for performance
const cRowsToGet = 20
rs.CacheSize = cRowsToGet
cHits = 0
do until rs.EOF
rows = rs.GetRows( cRowsToGet )
for r = 0 to UBound( rows, 2 )
row = ""
for col = 0 to UBound( rows, 1 )
if 0 <> col then row = row & " "
row = row & FormatValue( rows( col, r ), rs( col ).type )
next
out row
cHits = cHits + 1
next
loop
DisplayRowset = cHits
end function
'----------------------------------------------------------------------
sub DoQuery( query, catalog, locale, forceci, forcemerge, shallow, dialect, machine, columns, scope, quiet, sort, stats, uptodate, maxhits, firsthits, groupby )
if "" <> query then
' Create the query object and set the query properties
set q = WScript.CreateObject( "ixsso.Query" )
q.Query = query
q.Catalog = "query://" & machine & "/" & catalog
q.AllowEnumeration = not forceci
q.Dialect = dialect
q.Columns = columns
q.CiScope = scope
if shallow then q.CiFlags = "shallow"
if "" <> sort then q.SortBy = sort
if "" <> groupby then q.GroupBy = groupby
' FirstRows is only supported on Windows XP and later versions, though
if 0 <> maxhits then
if firsthits then
q.FirstRows = maxhits
else
q.MaxRecords = maxhits
end if
end if
if "" <> locale then
set u = WScript.CreateObject( "ixsso.Util" )
q.LocaleId = u.ISOToLocaleID( locale )
end if
set rs = q.CreateRecordSet( "sequential" )
if "" <> groupby then
cHits = DisplayGroupedRowset( rs, 0 )
else
cHits = DisplayRowset( rs )
end if
' Display query status information
if not quiet then
out CHR(10) & cHits & " files matched the query '" & query & "'"
if q.OutOfDate then
out "The index is out of date"
end if
if q.QueryTimedOut then
out "The query timed out"
end if
if q.QueryIncomplete then
out "The query results are incomplete; may require enumeration"
end if
end if
end if
' Display catalog status information and/or force a merge
if stats or uptodate or forcemerge then
set a = WScript.CreateObject( "microsoft.ISAdm" )
a.MachineName = machine
set c = a.GetCatalogByName( catalog )
if forcemerge then c.ForceMasterMerge
if stats then
out "Machine: " & machine
out "Catalog: " & catalog
out "Location: " & c.CatalogLocation
out2 c.TotalDocumentCount, "Documents in the catalog"
out2 c.FreshTestCount, "Documents modified since the last master merge"
out2 c.FilteredDocumentCount, "Documents filtered since the service started"
out2 c.DocumentsToFilter, "Documents to filter"
out2 c.DelayedFilterCount, "Documents deferred for filtering"
out2 c.UniqueKeyCount, "Unique keys in the master index"
out2 c.WordListCount, "Wordlists"
out2 c.PersistentIndexCount, "Saved indexes"
out2 c.QueryCount, "Queries executed since the service started"
out2 c.IndexSize, "Megabytes used for index files"
out2 c.PendingScanCount, "Scans scheduled"
s = c.StateInfo
if s and &H1 then out "Shadow merge " & c.PctMergeComplete & "% complete"
if s and &H2 then out "Master merge " & c.PctMergeComplete & "% complete"
if s and &H8 then out "Annealing merge " & c.PctMergeComplete & "% complete"
if s and &H20 then out "Recovery in progress..."
if s and &H80 then out "Indexing paused due to low memory"
if s and &H100 then out "Indexing paused due to high system I/O"
if s and &H400 then out "Catalog is read-only"
if s and &H800 then out "Indexing paused due to running on battery power"
if s and &H1000 then out "Indexing paused due to busy interactive user"
if s and &H2000 then out "Indexing service is starting..."
if s and &H4000 then out "Reading the NTFS USN log(s)"
end if
if uptodate then
if c.IsUpToDate then
out "The catalog is up to date."
else
out "The catalog is not up to date."
end if
end if
end if
end sub
|
<reponame>npocmaka/Windows-Server-2003
' The following sample registers to be informed whenever an instance
' of the class MyClass is created
Set objServices = GetObject("cim:root/default")
Set objEnum = objServices.ExecNotificationQuery ("select * from __instancecreationevent where targetinstance isa 'MyClass'")
for each objEvent in objEnum
WScript.Echo "Got an event"
Next
|
<gh_stars>0
Module FuckYouGithub
Sub Main()
MsgBox("Fuck You Github!")
End Sub
End Module
|
<reponame>npocmaka/Windows-Server-2003
' Windows Installer utility to list component composition of an MSI database
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) Microsoft Corporation. All rights reserved.
' Demonstrates the various tables having foreign keys to the Component table
'
Option Explicit
Public isGUI, installer, database, message, compParam 'global variables access across functions
Const msiOpenDatabaseModeReadOnly = 0
' Check if run from GUI script host, in order to modify display
If UCase(Mid(Wscript.FullName, Len(Wscript.Path) + 2, 1)) = "W" Then isGUI = True
' Show help if no arguments or if argument contains ?
Dim argCount:argCount = Wscript.Arguments.Count
If argCount > 0 Then If InStr(1, Wscript.Arguments(0), "?", vbTextCompare) > 0 Then argCount = 0
If argCount = 0 Then
Wscript.Echo "Windows Installer utility to list component composition in an install database." &_
vbLf & " The 1st argument is the path to an install database, relative or complete path" &_
vbLf & " The 2nd argument is the name of the component (primary key of Component table)" &_
vbLf & " If the 2nd argument is not present, the names of all components will be listed" &_
vbLf & " If the 2nd argument is a ""*"", the composition of all components will be listed" &_
vbLf & " Large databases or components are better displayed using CScript than WScript." &_
vbLf & " Note: The name of the component, if provided, is case-sensitive" &_
vbNewLine &_
vbNewLine & "Copyright (C) Microsoft Corporation. All rights reserved."
Wscript.Quit 1
End If
' Connect to Windows Installer object
On Error Resume Next
Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
' Open database
Dim databasePath:databasePath = Wscript.Arguments(0)
Set database = installer.OpenDatabase(databasePath, msiOpenDatabaseModeReadOnly) : CheckError
If argCount = 1 Then 'If no component specified, then simply list components
ListComponents False
ShowOutput "Components for " & databasePath, message
ElseIf Left(Wscript.Arguments(1), 1) = "*" Then 'List all components
ListComponents True
Else
QueryComponent Wscript.Arguments(1)
End If
Wscript.Quit 0
' List all table rows referencing a given component
Function QueryComponent(component)
' Get component info and format output header
Dim view, record, header, componentId
Set view = database.OpenView("SELECT `ComponentId` FROM `Component` WHERE `Component` = ?") : CheckError
Set compParam = installer.CreateRecord(1)
compParam.StringData(1) = component
view.Execute compParam : CheckError
Set record = view.Fetch : CheckError
Set view = Nothing
If record Is Nothing Then Fail "Component not in database: " & component
componentId = record.StringData(1)
header = "Component: "& component & " ComponentId = " & componentId
' List of tables with foreign keys to Component table - with subsets of columns to display
DoQuery "FeatureComponents","Feature_" '
DoQuery "PublishComponent", "ComponentId,Qualifier" 'AppData,Feature
DoQuery "File", "File,Sequence,FileName,Version" 'FileSize,Language,Attributes
DoQuery "SelfReg,File", "File_" 'Cost
DoQuery "BindImage,File", "File_" 'Path
DoQuery "Font,File", "File_,FontTitle" '
DoQuery "Patch,File", "File_" 'Sequence,PatchSize,Attributes,Header
DoQuery "DuplicateFile", "FileKey,File_,DestName" 'DestFolder
DoQuery "MoveFile", "FileKey,SourceName,DestName" 'SourceFolder,DestFolder,Options
DoQuery "RemoveFile", "FileKey,FileName,DirProperty" 'InstallMode
DoQuery "IniFile", "IniFile,FileName,Section,Key" 'Value,Action
DoQuery "RemoveIniFile", "RemoveIniFile,FileName,Section,Key" 'Value,Action
DoQuery "Registry", "Registry,Root,Key,Name" 'Value
DoQuery "RemoveRegistry", "RemoveRegistry,Root,Key,Name" '
DoQuery "Shortcut", "Shortcut,Directory_,Name,Target" 'Arguments,Description,Hotkey,Icon_,IconIndex,ShowCmd,WkDir
DoQuery "Class", "CLSID,Description" 'Context,ProgId_Default,AppId_,FileType,Mask,Icon_,IconIndex,DefInprocHandler,Argument,Feature_
DoQuery "ProgId,Class", "Class_,ProgId,Description" 'ProgId_Parent,Icon_IconIndex,Insertable
DoQuery "Extension", "Extension,ProgId_" 'MIME_,Feature_
DoQuery "Verb,Extension", "Extension_,Verb" 'Sequence,Command.Argument
DoQuery "MIME,Extension", "Extension_,ContentType" 'CLSID
DoQuery "TypeLib", "LibID,Language,Version,Description" 'Directory_,Feature_,Cost
DoQuery "CreateFolder", "Directory_" '
DoQuery "Environment", "Environment,Name" 'Value
DoQuery "ODBCDriver", "Driver,Description" 'File_,File_Setup
DoQuery "ODBCAttribute,ODBCDriver", "Driver_,Attribute,Value" '
DoQuery "ODBCTranslator", "Translator,Description" 'File_,File_Setup
DoQuery "ODBCDataSource", "DataSource,Description,DriverDescription" 'Registration
DoQuery "ODBCSourceAttribute,ODBCDataSource", "DataSource_,Attribute,Value" '
DoQuery "ServiceControl", "ServiceControl,Name,Event" 'Arguments,Wait
DoQuery "ServiceInstall", "ServiceInstall,Name,DisplayName" 'ServiceType,StartType,ErrorControl,LoadOrderGroup,Dependencies,StartName,Password
DoQuery "ReserveCost", "ReserveKey,ReserveFolder" 'ReserveLocal,ReserveSource
QueryComponent = ShowOutput(header, message)
message = Empty
End Function
' List all components in database
Sub ListComponents(queryAll)
Dim view, record, component
Set view = database.OpenView("SELECT `Component`,`ComponentId` FROM `Component`") : CheckError
view.Execute : CheckError
Do
Set record = view.Fetch : CheckError
If record Is Nothing Then Exit Do
component = record.StringData(1)
If queryAll Then
If QueryComponent(component) = vbCancel Then Exit Sub
Else
If Not IsEmpty(message) Then message = message & vbLf
message = message & component
End If
Loop
End Sub
' Perform a join to query table rows linked to a given component, delimiting and qualifying names to prevent conflicts
Sub DoQuery(table, columns)
Dim view, record, columnCount, column, output, header, delim, columnList, tableList, tableDelim, query, joinTable, primaryKey, foreignKey, columnDelim
On Error Resume Next
tableList = Replace(table, ",", "`,`")
tableDelim = InStr(1, table, ",", vbTextCompare)
If tableDelim Then ' need a 3-table join
joinTable = Right(table, Len(table)-tableDelim)
table = Left(table, tableDelim-1)
foreignKey = columns
Set record = database.PrimaryKeys(joinTable)
primaryKey = record.StringData(1)
columnDelim = InStr(1, columns, ",", vbTextCompare)
If columnDelim Then foreignKey = Left(columns, columnDelim - 1)
query = " AND `" & foreignKey & "` = `" & primaryKey & "`"
End If
columnList = table & "`." & Replace(columns, ",", "`,`" & table & "`.`")
query = "SELECT `" & columnList & "` FROM `" & tableList & "` WHERE `Component_` = ?" & query
If database.TablePersistent(table) <> 1 Then Exit Sub
Set view = database.OpenView(query) : CheckError
view.Execute compParam : CheckError
Do
Set record = view.Fetch : CheckError
If record Is Nothing Then Exit Do
If IsEmpty(output) Then
If Not IsEmpty(message) Then message = message & vbLf
message = message & "----" & table & " Table---- (" & columns & ")" & vbLf
End If
output = Empty
columnCount = record.FieldCount
delim = " "
For column = 1 To columnCount
If column = columnCount Then delim = vbLf
output = output & record.StringData(column) & delim
Next
message = message & output
Loop
End Sub
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub
Function ShowOutput(header, message)
ShowOutput = vbOK
If IsEmpty(message) Then Exit Function
If isGUI Then
ShowOutput = MsgBox(message, vbOKCancel, header)
Else
Wscript.Echo "> " & header
Wscript.Echo message
End If
End Function
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
Dim samplevariable as New Object
Dim anothervariable as Object
Set anothervariable = sameplevariable
|
Public Function Fib(ByVal n As Integer) As Variant
Dim fib0 As Variant, fib1 As Variant, sum As Variant
Dim i As Integer
fib0 = 0
fib1 = 1
For i = 1 To n
sum = fib0 + fib1
fib0 = fib1
fib1 = sum
Next i
Fib = fib0
End Function
|
Function IsLeapYear(yr)
IsLeapYear = False
If yr Mod 4 = 0 And (yr Mod 400 = 0 Or yr Mod 100 <> 0) Then
IsLeapYear = True
End If
End Function
'Testing the function.
arr_yr = Array(1900,1972,1997,2000,2001,2004)
For Each yr In arr_yr
If IsLeapYear(yr) Then
WScript.StdOut.WriteLine yr & " is leap year."
Else
WScript.StdOut.WriteLine yr & " is NOT leap year."
End If
Next
|
<reponame>npocmaka/Windows-Server-2003
'
' test8.vbs
'
' get current driver
'
on error resume next
SET WshShell = WScript.CreateObject("WScript.Shell")
SET DevCon = CreateObject("DevCon.DeviceConsole","\\localhost")
SET Devs = DevCon.DevicesBySetupClasses("NET")
Count = Devs.Count
Wscript.Echo "net: Count="+CStr(Count)
FOR EACH Dev IN Devs
WScript.Echo Dev + ": " + Dev.Description
Set Driver = Dev.CurrentDriverPackage
IF NOT (Driver IS Nothing) THEN
WScript.Echo "Driver: "+Driver.ScriptFile+" [" + Driver.ScriptName+"]"
WScript.Echo "Device Description: "+Driver.Description
WScript.Echo "Driver Description: "+Driver.DriverDescription
WScript.Echo "Provider: "+Driver.Provider
WScript.Echo "Manufacturer: "+Driver.Manufacturer
WScript.Echo "Date: "+FormatDateTime(Driver.Date,vbLongDate)
WScript.Echo "Version: "+Driver.Version
WScript.Echo "Hardware IDs: "+Join(Driver.HardwareIds," ")
WScript.Echo "Compatible IDs: "+Join(Driver.CompatibleIds," ")
WScript.Echo "Driver files: "+Join(Driver.DriverFiles," ")
WScript.Echo "Manifest: "+Join(Driver.Manifest," ")
END IF
NEXT
|
<filename>base/cluster/admin/msclus/vbscript/addresource.vbs
Option Explicit
Sub Main
Dim oGroup
Dim oCluster
Dim oResource
Dim sCluster
Set oCluster = CreateObject("MSCluster.Cluster") 'Create the Cluster object
sCluster = InputBox( "Cluster to open?" )
oCluster.Open( sCluster )
AddGroup oCluster, oGroup 'Create or open the group
AddResource oGroup, oResource 'Create or open the resource
oResource.Online 10 'Bring the resource online and wait for up to 10 seconds for it to come online
Sleep 10
oResource.Offline 10 'Take the resource offline and wait for up to 10 seconds for it to offline
Sleep 5
oResource.Delete 'Delete the resource
Sleep 5
oGroup.Delete 'Delete the group
End Sub
'
' This subroutine will create or open the group
'
Sub AddGroup( oCluster, oGroup )
Set oGroup = oCluster.ResourceGroups.CreateItem("High Availability NotePad")
End Sub
'
' This subroutine will add the resource to the group
'
Sub AddResource(oGroup, oResource)
Dim oGroupResources
Dim oProperties
Dim oCLProperty
Dim oCDProperty
Set oGroupResources = oGroup.Resources
Set oResource = oGroupResources.CreateItem("NotePad", "Generic Application", 0) 'CLUSTER_RESOURCE_DEFAULT_MONITOR
Set oProperties = oResource.PrivateProperties
Set oCLProperty = oProperties.CreateItem("CommandLine", "notepad")
Set oCDProperty = oProperties.CreateItem("CurrentDirectory", "c:\")
oProperties.SaveChanges
End Sub
Sub Sleep(PauseTime)
Dim Start
Start = Timer
Do While Timer < Start + PauseTime
Loop
End Sub
Main
|
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.1#0"; "RICHTX32.OCX"
Begin VB.Form frmScriptMode
BorderStyle = 0 'None
Caption = "Script Mode"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 9480
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 5730
ScaleWidth = 9480
ShowInTaskbar = 0 'False
Visible = 0 'False
Begin RichTextLib.RichTextBox txtTerminal
Height = 5295
Left = 6120
TabIndex = 29
Top = 120
Width = 3255
_ExtentX = 5741
_ExtentY = 9340
_Version = 327681
Enabled = -1 'True
ScrollBars = 2
TextRTF = $"frmScriptMode.frx":0000
End
Begin VB.Frame framePort
Height = 5415
Left = 0
TabIndex = 25
Top = 0
Width = 6055
Begin VB.Timer Timer1
Left = 5040
Top = 2040
End
Begin VB.PictureBox Picture3
Height = 255
Left = 5160
Picture = "frmScriptMode.frx":00D5
ScaleHeight = 195
ScaleWidth = 435
TabIndex = 28
Top = 2760
Visible = 0 'False
Width = 495
End
Begin VB.PictureBox Picture2
Height = 255
Left = 4320
Picture = "frmScriptMode.frx":067B
ScaleHeight = 195
ScaleWidth = 435
TabIndex = 27
Top = 2760
Visible = 0 'False
Width = 495
End
Begin VB.PictureBox Picture1
Height = 255
Left = 3600
Picture = "frmScriptMode.frx":0C21
ScaleHeight = 195
ScaleWidth = 435
TabIndex = 26
Top = 2760
Visible = 0 'False
Width = 495
End
Begin VB.ComboBox Combo42
Height = 315
ItemData = "frmScriptMode.frx":11C7
Left = 1080
List = "frmScriptMode.frx":11DA
Style = 2 'Dropdown List
TabIndex = 5
Top = 1170
Width = 1695
End
Begin VB.TextBox Text22
Height = 315
Left = 4080
TabIndex = 13
Text = "AT&FE0"
Top = 1170
Width = 1815
End
Begin VB.ComboBox Combo12
Height = 315
ItemData = "frmScriptMode.frx":11FC
Left = 1080
List = "frmScriptMode.frx":1230
Style = 2 'Dropdown List
TabIndex = 1
Top = 240
Width = 1695
End
Begin VB.ComboBox Combo22
Height = 315
ItemData = "frmScriptMode.frx":12AB
Left = 4080
List = "frmScriptMode.frx":12D6
Style = 2 'Dropdown List
TabIndex = 9
Top = 240
Width = 1815
End
Begin VB.TextBox Text12
Height = 315
Left = 4080
TabIndex = 11
Text = "2.0"
Top = 690
Width = 1815
End
Begin VB.ComboBox Combo32
Height = 315
ItemData = "frmScriptMode.frx":132E
Left = 1080
List = "frmScriptMode.frx":1341
Style = 2 'Dropdown List
TabIndex = 3
Top = 690
Width = 1695
End
Begin VB.ComboBox Combo52
Height = 315
ItemData = "frmScriptMode.frx":1354
Left = 1080
List = "frmScriptMode.frx":1361
Style = 2 'Dropdown List
TabIndex = 7
Top = 1620
Width = 1695
End
Begin VB.CommandButton cmdGo
Caption = "&Connect"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2880
TabIndex = 14
Top = 1560
Width = 1455
End
Begin VB.CommandButton cmdStop
Caption = "D&isconnect"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4440
TabIndex = 15
Top = 1560
Width = 1455
End
Begin VB.TextBox txtNewValue
Height = 285
Left = 120
TabIndex = 21
Top = 5010
Width = 2535
End
Begin VB.CommandButton cmdDeleteKey
Caption = "D&elete Value"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4440
TabIndex = 23
Top = 4920
Width = 1455
End
Begin VB.CommandButton cmdAdd
Caption = "&Update Value"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2880
TabIndex = 22
Top = 4920
Width = 1455
End
Begin VB.ListBox lstSections
Height = 2400
Left = 120
TabIndex = 17
Top = 2370
Width = 1815
End
Begin ComctlLib.ListView ListView2
Height = 2370
Left = 2040
TabIndex = 19
Top = 2400
Width = 3855
_ExtentX = 6800
_ExtentY = 4180
View = 3
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 2
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "clmKey"
Object.Tag = ""
Text = "Command"
Object.Width = 1764
EndProperty
BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
SubItemIndex = 1
Key = "clmValue"
Object.Tag = ""
Text = "Value"
Object.Width = 3528
EndProperty
End
Begin MSCommLib.MSComm MSComm1
Left = 4080
Top = 2040
_ExtentX = 1005
_ExtentY = 1005
_Version = 327681
DTREnable = -1 'True
End
Begin VB.Label Label2
Caption = "&Reset:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2880
TabIndex = 12
Top = 1200
Width = 1095
End
Begin VB.Label Label6
Caption = "P&arity:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 4
Top = 1200
Width = 855
End
Begin VB.Label Label3
Caption = "&Port:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 0
Top = 270
Width = 855
End
Begin VB.Label Label4
Caption = "Port &speed:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2880
TabIndex = 8
Top = 270
Width = 1095
End
Begin VB.Label Label5
Caption = "&Data bits:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 2
Top = 720
Width = 855
End
Begin VB.Label Label7
Caption = "S&top bits:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 6
Top = 1680
Width = 855
End
Begin VB.Label Label1
Caption = "I&nterval:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2880
TabIndex = 10
Top = 720
Width = 1095
End
Begin VB.Label lblValue
Caption = "Co&mmand"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 20
Top = 4800
Width = 1815
End
Begin VB.Label lblKeys
Caption = "C&ommands in script"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2040
TabIndex = 18
Top = 2160
Width = 3255
End
Begin VB.Label lblSections
Caption = "&Scripts"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 16
Top = 2160
Width = 1095
End
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 24
Top = 5430
Width = 9480
_ExtentX = 16722
_ExtentY = 529
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 4
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 12171
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
Object.Width = 882
MinWidth = 882
Picture = "frmScriptMode.frx":1370
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "4/30/98"
Object.Tag = ""
EndProperty
BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "4:36 PM"
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "frmScriptMode"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Command() As String
Dim Instring As String ' Buffer to hold input string
Dim SectionName$
Dim Halt As Boolean
Dim Section() As String
Dim FileOut As String
Dim Go As Boolean
Dim CP As Integer
Dim X As Integer
Dim z As Integer
Public Filename$
Const INIFILE = "Uquery11.ini"
Const Q = """"
Private mintCurFrame As Integer ' Current Frame visible
Dim TerminalOutput As String
Private Sub cmdGo_Click()
Dim RetVal
Dim TimeInterval As String
Dim ComSettings As String
Dim ParitySetting As String
On Error GoTo ErrorHandler
cmdGo.Enabled = False
cmdStop.Enabled = True
lstSections.Enabled = False
ListView2.Enabled = False
txtNewValue.Enabled = False
cmdAdd.Enabled = False
cmdDeleteKey.Enabled = False
Halt = False
TimeInterval = Text12.Text
If TimeInterval > 0 Then
Timer1.Interval = TimeInterval * 250
Else
Timer1.Interval = 2000
End If
MSComm1.CommPort = Right(Combo12.Text, 2) ' Use selected port.
ParitySetting = Left(Combo42.Text, 1)
ComSettings = Combo22.Text & ", " & ParitySetting & ", " & Combo32.Text & ", " & Combo52.Text
MSComm1.Settings = ComSettings
MSComm1.InputLen = 0 ' Tell the control to read entire buffer when Input is used.
'StatusBar1.Panels(1).Text = "Working"
StatusBar1.Panels(1).Text = MSComm1.Settings & " Port number: " & MSComm1.CommPort
txtTerminal.Refresh
txtTerminal.Text = ""
TerminalOutput = ""
MSComm1.PortOpen = True ' Open the port.
GetCommand (lstSections.Text)
SendLines
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False ' Close the serial port.
End If
cmdGo.Enabled = True
cmdStop.Enabled = False
lstSections.Enabled = True
ListView2.Enabled = True
txtNewValue.Enabled = True
cmdAdd.Enabled = True
cmdDeleteKey.Enabled = True
StatusBar1.Panels(2).Picture = Picture1.Picture
StatusBar1.Panels(1).Text = "Select which script and port to continue."
Exit Sub
ErrorHandler:
If Err.Number = "8002" Then
RetVal = MsgBox("Invalid Port Number", vbExclamation)
Else
RetVal = MsgBox(Err.Description & " " & Err.Number, vbCritical)
End If
cmdStop.Enabled = False
cmdGo.Enabled = True
lstSections.Enabled = True
ListView2.Enabled = True
txtNewValue.Enabled = True
cmdAdd.Enabled = True
cmdDeleteKey.Enabled = True
StatusBar1.Panels(1).Text = "Finished"
End Sub
Private Sub cmdShowIniReader_Click()
frmVB5INI.Show vbModal, Me
End Sub
Private Sub cmdStop_Click()
Halt = True
End Sub
Private Sub Form_Load()
TerminalOutput = ""
framePort.Top = 0
framePort.Left = 0
Combo12.Text = GetSetting(App.Title, "Settings", "Combo12", "Com 1")
Combo22.Text = GetSetting(App.Title, "Settings", "Combo22", "9600")
Combo32.Text = GetSetting(App.Title, "Settings", "Combo32", "8")
Combo42.Text = GetSetting(App.Title, "Settings", "Combo42", "None")
Combo52.Text = GetSetting(App.Title, "Settings", "Combo52", "1")
Text12.Text = GetSetting(App.Title, "Settings", "Text12", "1.5")
Text22.Text = GetSetting(App.Title, "Settings", "Text22", "AT&FE0")
Format ("Simple")
ShowSections
StatusBar1.Panels(1).Text = "Select which script and port to continue."
End Sub
Private Function Format(File As String)
'Dim Instring As String ' Buffer to hold input string
FileOut = File & "1.ini"
File = File & ".ini"
Filename$ = App.Path ' This sample expects to see the INI file in the application
If Right$(Filename$, 1) <> "\" Then Filename$ = Filename$ & "\" ' directory. At design time, the current directory is VB, so
FileOut = Filename$ & FileOut ' we add the app.path to make sure we choose the right place.
Filename$ = App.Path ' This sample expects to see the INI file in the application
If Right$(Filename$, 1) <> "\" Then Filename$ = Filename$ & "\" ' directory. At design time, the current directory is VB, so
File = Filename$ & File
Filename$ = App.Path ' This sample expects to see the INI file in the application
If Right$(Filename$, 1) <> "\" Then Filename$ = Filename$ & "\" ' directory. At design time, the current directory is VB, so
Filename$ = FileOut
Dim TextLine As String
Dim First As String
Dim X As Integer
X = 0
Open File For Input As #1 ' Open input file.
Open FileOut For Output As #2 ' Open output file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
First = Mid(TextLine, 1, 1)
Select Case First
Case "'"
Case "["
Case ""
Case Else
X = X + 1
TextLine = "Command" & X & " = " & TextLine
End Select
Print #2, TextLine ' Write line to file.
'Debug.Print TextLine ' Print to Debug window.
Loop
Close #1 ' Close file.
Close #2 ' Close file.
End Function
Private Sub Form_Resize()
txtTerminal.Width = frmScriptMode.Width - 6225
txtTerminal.Height = frmScriptMode.Height - 435
framePort.Height = frmScriptMode.Height - 350
txtNewValue.Top = frmScriptMode.Height - 700
lblValue.Top = frmScriptMode.Height - 910
cmdAdd.Top = frmScriptMode.Height - 790
cmdDeleteKey.Top = frmScriptMode.Height - 790
lstSections.Height = frmScriptMode.Height - 3330
ListView2.Height = frmScriptMode.Height - 3330
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Settings", "Combo12", Combo12.Text
SaveSetting App.Title, "Settings", "Combo22", Combo22.Text
SaveSetting App.Title, "Settings", "Combo32", Combo32.Text
SaveSetting App.Title, "Settings", "Combo42", Combo42.Text
SaveSetting App.Title, "Settings", "Combo52", Combo52.Text
SaveSetting App.Title, "Settings", "Text12", Text12.Text
SaveSetting App.Title, "Settings", "Text22", Text22.Text
End Sub
Private Sub ListView2_Click()
Dim KeyValue$
KeyValue$ = VBGetPrivateProfileString(SectionName$, ListView2.SelectedItem, Filename$)
txtNewValue.Text = KeyValue$
End Sub
Private Sub lstSections_Click()
SectionName$ = lstSections.Text
ListKeys
cmdGo.Enabled = True
StatusBar1.Panels(1).Text = "Ready"
End Sub
Private Sub mnuEditCommand_Click()
cmdShowIniReader_Click
End Sub
Public Function GetCommand(Section As String)
Dim characters
Dim KeyList$
Dim KeyValue$
Dim KeyNum$
KeyList$ = String$(2048, 0)
characters = GetPrivateProfileStringKeys(Section, 0, "", KeyList$, 2047, Filename$) ' Retrieve the list of keys in the section
'ReDim Command(characters)
z = -1
Dim NullOffset%
'KeyValue$ = VBGetPrivateProfileString(Section, Mid$(KeyList$, 1, 5), FileName$)
'KeyValue$ = Mid(KeyValue$, 5)
KeyNum$ = KeyList$
Do
z = z + 1
NullOffset% = InStr(KeyNum$, Chr$(0))
If NullOffset% > 1 Then
KeyNum$ = Mid$(KeyNum$, NullOffset% + 1)
End If
Loop While NullOffset% > 1
ReDim Command(z)
X = -1
Do
X = X + 1
NullOffset% = InStr(KeyList$, Chr$(0))
If NullOffset% > 1 Then
KeyValue$ = VBGetPrivateProfileString(Section, Mid$(KeyList$, 1, NullOffset% - 1), Filename$)
Command(X) = KeyValue$
KeyList$ = Mid$(KeyList$, NullOffset% + 1)
End If
Loop While NullOffset% > 1
End Function
Public Function SendLines()
Dim Garbage As String
Dim Y As Integer
Dim TextLine As String
For Y = 0 To (X - 1)
If Halt = True Then
cmdStop.Enabled = False
Exit Function
End If
Go = False
TextLine = Command(Y)
If Mid(TextLine, 1, 2) <> "AT" Then
TextLine = "AT" & TextLine
End If
StatusBar1.Panels(2).Picture = Picture2.Picture
Do
DoEvents
Loop Until Go = True
Go = False
MSComm1.Output = Text22.Text + Chr$(13)
Do
DoEvents
Loop Until Go = True
Go = False
StatusBar1.Panels(2).Picture = Picture3.Picture
Garbage = MSComm1.Input
Do
DoEvents
Loop Until Go = True
Go = False
StatusBar1.Panels(2).Picture = Picture2.Picture
MSComm1.Output = TextLine + Chr$(13) ' Send the command to the modem.
Do
DoEvents
Loop Until Go = True ' Wait for data to come back to the serial port.
Go = False
StatusBar1.Panels(2).Picture = Picture3.Picture
Instring = MSComm1.Input ' Read the response data in the serial port.
TerminalOutput = TerminalOutput & TextLine & Instring
TerminalOutput = TerminalOutput + Chr(10)
txtTerminal.Text = TerminalOutput
txtTerminal.SelStart = Len(txtTerminal.Text)
Next Y
End Function
Private Sub Timer1_Timer()
Go = True
End Sub
'
' List all of the keys in a particular section
'
Private Sub ListKeys()
Dim characters As Long
Dim itmX As ListItem
Dim KeyList$
Dim KeyValue$
Dim X As Integer
KeyList$ = String$(2048, 0)
ListView2.ListItems.Clear
' Retrieve the list of keys in the section
characters = GetPrivateProfileStringKeys(SectionName$, 0, "", KeyList$, 2047, Filename$)
' Load sections into the list box
Dim NullOffset%
Do
NullOffset% = InStr(KeyList$, Chr$(0))
If NullOffset% > 1 Then
Set itmX = ListView2.ListItems.Add(, , Mid$(KeyList$, 1, NullOffset% - 1))
KeyValue$ = VBGetPrivateProfileString(SectionName$, Mid$(KeyList$, 1, NullOffset% - 1), Filename$)
itmX.SubItems(1) = KeyValue$ ' Add the response to the list
KeyList$ = Mid$(KeyList$, NullOffset% + 1)
End If
Loop While NullOffset% > 1
End Sub
Private Sub ShowSections()
Dim characters As Long
Dim SectionList$
SectionList$ = String$(2048, 0)
' Retrieve the list of keys in the section
characters = GetPrivateProfileStringSections(0, 0, "", SectionList$, 2047, Filename$)
' Load sections into the list box
Dim NullOffset%
Do
NullOffset% = InStr(SectionList$, Chr$(0))
If NullOffset% > 1 Then
lstSections.AddItem Mid$(SectionList$, 1, NullOffset% - 1)
SectionList$ = Mid$(SectionList$, NullOffset% + 1)
End If
Loop While NullOffset% > 1
End Sub
Private Sub cmdAdd_Click()
Dim success%
If Len(txtNewValue.Text) = 0 Then
MsgBox "No value specified."
Exit Sub
End If
' Write the new key
success% = WritePrivateProfileStringByKeyName(SectionName$, ListView2.SelectedItem, txtNewValue.Text, Filename$)
If success% = 0 Then
MsgBox "Edit failed - this is typically caused by a write protected INI file"
Exit Sub
End If
ListKeys ' Refresh the list box
End Sub
Private Sub cmdDeleteKey_Click()
Dim success%
If ListView2.ListItems.Count < 1 Then
MsgBox "No selected entries in the list box"
Exit Sub
End If
' Delete the selected key
success% = WritePrivateProfileStringToDeleteKey(SectionName$, ListView2.SelectedItem, 0, Filename$)
If success% = 0 Then
MsgBox "Delete failed - this is typically caused by a write protected INI file"
Exit Sub
End If
txtNewValue.Text = ""
ListKeys ' Refresh the list box
End Sub
Public Sub ClearControl()
txtTerminal.Text = ""
End Sub
Public Sub EditCopy()
Clipboard.Clear
Clipboard.SetText txtTerminal.SelText
End Sub
Public Sub EditPaste()
txtTerminal.Text = (Clipboard.GetText)
End Sub
|
For n = 1 To 10
sequence = Generate_Sequence(n)
WScript.Echo sequence & " is " & Check_Balance(sequence) & "."
Next
Function Generate_Sequence(n)
For i = 1 To n
j = Round(Rnd())
If j = 0 Then
Generate_Sequence = Generate_Sequence & "["
Else
Generate_Sequence = Generate_Sequence & "]"
End If
Next
End Function
Function Check_Balance(s)
Set Stack = CreateObject("System.Collections.Stack")
For i = 1 To Len(s)
char = Mid(s,i,1)
If i = 1 Or char = "[" Then
Stack.Push(char)
ElseIf Stack.Count <> 0 Then
If char = "]" And Stack.Peek = "[" Then
Stack.Pop
End If
Else
Stack.Push(char)
End If
Next
If Stack.Count > 0 Then
Check_Balance = "Not Balanced"
Else
Check_Balance = "Balanced"
End If
End Function
|
<reponame>j-lawrence-b1/string-path-search
'BasicPawn
'Copyright(C) 2017 TheTimocop
'This program Is free software: you can redistribute it And/Or modify
'it under the terms Of the GNU General Public License As published by
'the Free Software Foundation, either version 3 Of the License, Or
'(at your option) any later version.
'This program Is distributed In the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty Of
'MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License For more details.
'You should have received a copy Of the GNU General Public License
'along with this program. If Not, see < http: //www.gnu.org/licenses/>.
Imports System.Windows.Forms
Imports BasicPawn
Public Class FormFTP
Private g_mPluginFTP As PluginFTP
Private g_mSecureStorage As ClassSecureStorage
Private g_lFtpEntries As New List(Of STRUC_FTP_ENTRY_ITEM)
Private g_mUploadThread As Threading.Thread
Private g_mFormProgress As FormProgress
Enum ENUM_FTP_PROTOCOL_TYPE
FTP
SFTP
End Enum
Structure STRUC_FTP_ENTRY_ITEM
Dim sGUID As String
Dim sHost As String
Dim sDatabaseEntry As String
Dim sDestinationPath As String
Dim iProtocolType As ENUM_FTP_PROTOCOL_TYPE
Sub New(_Host As String, _DatabaseEntry As String, _DestinationPath As String, _ProtocolType As ENUM_FTP_PROTOCOL_TYPE)
sGUID = Guid.NewGuid.ToString
sHost = _Host
sDatabaseEntry = _DatabaseEntry
sDestinationPath = _DestinationPath
iProtocolType = _ProtocolType
End Sub
End Structure
Public Sub New(mPluginFTP As PluginFTP, sFile As String)
Me.New(mPluginFTP, New String() {sFile})
End Sub
Public Sub New(mPluginFTP As PluginFTP, sFiles As String())
g_mPluginFTP = mPluginFTP
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
TextBox_UploadFile.Multiline = True
TextBox_UploadFile.Text = String.Join(";"c, sFiles)
GroupBox_NewEntry.Visible = False
ComboBox_Protocol.SelectedIndex = 0
Me.AutoSize = True
g_mSecureStorage = New ClassSecureStorage("PluginFtpEntries")
LoadData()
FillListView()
End Sub
Private Sub FormFTP_Load(sender As Object, e As EventArgs) Handles Me.Load
ClassControlStyle.UpdateControls(Me)
End Sub
Private Sub Button_SearchUploadFile_Click(sender As Object, e As EventArgs) Handles Button_SearchUploadFile.Click
Using i As New OpenFileDialog
i.Multiselect = True
If (i.ShowDialog = DialogResult.OK) Then
TextBox_UploadFile.Text = String.Join(";"c, i.FileNames)
End If
End Using
End Sub
Private Sub ListView_FtpEntries_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_FtpEntries.SelectedIndexChanged
Button_Upload.Enabled = (ListView_FtpEntries.SelectedItems.Count > 0)
Button_Browse.Enabled = (ListView_FtpEntries.SelectedItems.Count > 0)
End Sub
Private Sub ListView_FtpEntries_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles ListView_FtpEntries.MouseDoubleClick
Button_Upload.PerformClick()
End Sub
Private Sub LinkLabel_RemoveItem_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel_RemoveItem.LinkClicked
Try
If (ListView_FtpEntries.SelectedItems.Count < 1) Then
Throw New ArgumentException("Nothing selected to remove")
End If
For i = 0 To ListView_FtpEntries.SelectedItems.Count - 1
Dim mListViewItemData = TryCast(ListView_FtpEntries.SelectedItems(i), ClassListViewItemData)
If (mListViewItemData Is Nothing) Then
Throw New ArgumentException("Invalid type")
End If
Dim sGUID As String = CStr(mListViewItemData.g_mData("GUID"))
g_lFtpEntries.RemoveAll(Function(x As STRUC_FTP_ENTRY_ITEM)
Return x.sGUID = sGUID
End Function)
Next
FillListView()
SaveData()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub CheckBox_MoreDetails_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox_MoreDetails.CheckedChanged
GroupBox_NewEntry.Visible = CheckBox_MoreDetails.Checked
End Sub
Private Sub ComboBox_DatabaseEntry_DropDown(sender As Object, e As EventArgs) Handles ComboBox_DatabaseEntry.DropDown
Try
Dim sLastSelected As String = ComboBox_DatabaseEntry.Text
ComboBox_DatabaseEntry.BeginUpdate()
ComboBox_DatabaseEntry.Items.Clear()
For Each mItem In ClassDatabase.GetDatabaseItems
ComboBox_DatabaseEntry.Items.Add(mItem.m_Name)
Next
ComboBox_DatabaseEntry.EndUpdate()
Dim iIndex As Integer = ComboBox_DatabaseEntry.Items.IndexOf(sLastSelected)
If (iIndex > -1) Then
ComboBox_DatabaseEntry.SelectedIndex = iIndex
End If
Catch ex As Exception
ClassExceptionLog.WriteToLogMessageBox(ex)
End Try
End Sub
Private Sub Button_SearchPath_Click(sender As Object, e As EventArgs) Handles Button_SearchPath.Click
Try
Dim sDatabaseEntry As String = ComboBox_DatabaseEntry.Text
If (String.IsNullOrEmpty(sDatabaseEntry)) Then
Throw New ArgumentException("Invalid database entry")
End If
Dim sHost As String = TextBox_Host.Text
If (String.IsNullOrEmpty(sHost)) Then
Throw New ArgumentException("Invalid host")
End If
Dim iProtocol As ENUM_FTP_PROTOCOL_TYPE
Select Case (ComboBox_Protocol.SelectedIndex)
Case 0
iProtocol = ENUM_FTP_PROTOCOL_TYPE.FTP
Case Else
iProtocol = ENUM_FTP_PROTOCOL_TYPE.SFTP
End Select
Dim mDatabaseItem = ClassDatabase.FindDatabaseItemByName(sDatabaseEntry)
If (mDatabaseItem Is Nothing) Then
Throw New ArgumentException("Unable to find database entry")
End If
Dim sUsername As String = mDatabaseItem.m_Username
Dim sPassword As String = mDatabaseItem.m_Password
Using i As New FormFileDialogFTP(FormFileDialogFTP.ENUM_DIALOG_TYPE.OPEN_DIRECTORY, CType(iProtocol, FormFileDialogFTP.ENUM_FTP_PROTOCOL_TYPE), sHost, sUsername, sPassword, "")
If (i.ShowDialog = DialogResult.OK) Then
TextBox_DestinationPath.Text = i.m_CurrentPath
Else
Return
End If
End Using
Catch ex As Exception
ClassExceptionLog.WriteToLogMessageBox(ex)
End Try
End Sub
Private Sub Button_Browse_Click(sender As Object, e As EventArgs) Handles Button_Browse.Click
Try
If (ListView_FtpEntries.SelectedItems.Count < 1) Then
Return
End If
Dim mListViewItemData = TryCast(ListView_FtpEntries.SelectedItems(0), ClassListViewItemData)
If (mListViewItemData Is Nothing) Then
Return
End If
Dim sGUID As String = CStr(mListViewItemData.g_mData("GUID"))
For Each mFtpItem In g_lFtpEntries.ToArray
If (mFtpItem.sGUID = sGUID) Then
Dim mDatabaseItem = ClassDatabase.FindDatabaseItemByName(mFtpItem.sDatabaseEntry)
If (mDatabaseItem Is Nothing) Then
Throw New ArgumentException("Unable to find database entry")
End If
Using i As New FormFileDialogFTP(FormFileDialogFTP.ENUM_DIALOG_TYPE.OPEN_DIRECTORY, CType(mFtpItem.iProtocolType, FormFileDialogFTP.ENUM_FTP_PROTOCOL_TYPE), mFtpItem.sHost, mDatabaseItem.m_Username, mDatabaseItem.m_Password, "")
i.ShowDialog()
End Using
Exit For
End If
Next
Catch ex As Exception
ClassExceptionLog.WriteToLogMessageBox(ex)
End Try
End Sub
Private Sub Button_Upload_Click(sender As Object, e As EventArgs) Handles Button_Upload.Click
If (ClassThread.IsValid(g_mUploadThread)) Then
Return
End If
Try
If (ListView_FtpEntries.SelectedItems.Count < 1) Then
Return
End If
Dim mListViewItemData = TryCast(ListView_FtpEntries.SelectedItems(0), ClassListViewItemData)
If (mListViewItemData Is Nothing) Then
Return
End If
Dim sGUID As String = CStr(mListViewItemData.g_mData("GUID"))
For Each mFtpItem In g_lFtpEntries.ToArray
If (mFtpItem.sGUID = sGUID) Then
Dim mDatabaseItem = ClassDatabase.FindDatabaseItemByName(mFtpItem.sDatabaseEntry)
If (mDatabaseItem Is Nothing) Then
Throw New ArgumentException("Unable to find database entry")
End If
Dim sFiles As String() = TextBox_UploadFile.Text.Split(";"c)
Dim iProtocolType As ENUM_FTP_PROTOCOL_TYPE = mFtpItem.iProtocolType
Dim sHost As String = mFtpItem.sHost
Dim sDestinationPath As String = mFtpItem.sDestinationPath
Dim sUsername As String = mDatabaseItem.m_Username
Dim sPassword As String = mDatabaseItem.m_Password
g_mUploadThread = New Threading.Thread(Sub()
Dim bCanceled As Boolean = False
Try
ClassThread.ExecEx(Of Object)(Me, Sub() TableLayoutPanel_Controls.Enabled = False)
Try
Dim i As Integer
For i = 0 To sFiles.Length - 1
If (Not IO.File.Exists(sFiles(i))) Then
g_mPluginFTP.g_mFormMain.PrintInformation("[ERRO]", String.Format("Could not upload '{0}' because the file does not exist!", sFiles(i)))
Continue For
End If
g_mPluginFTP.g_mFormMain.PrintInformation("[INFO]", String.Format("Uploading file '{0}' ({1}/{2}) to '{3}/{4}' using {5}...", sFiles(i), i + 1, sFiles.Length, sHost.TrimEnd("/"c), sDestinationPath.TrimStart("/"c),
If(iProtocolType = ENUM_FTP_PROTOCOL_TYPE.FTP, "FTP", "SFTP")))
Dim sFilename As String = IO.Path.GetFileName(sFiles(i))
Dim sDestinationFile As String = (sDestinationPath.TrimEnd("/"c) & "/" & sFilename)
Dim iFileLenght As ULong = CULng(New IO.FileInfo(sFiles(i)).Length)
ClassThread.ExecEx(Of Object)(Me, Sub()
If (g_mFormProgress IsNot Nothing AndAlso Not g_mFormProgress.IsDisposed) Then
g_mFormProgress.Dispose()
g_mFormProgress = Nothing
End If
g_mFormProgress = New FormProgress With {
.Text = String.Format("Uploading file ({0}/{1})...", i + 1, sFiles.Length),
.m_Progress = 0
}
g_mFormProgress.m_CloseAction = (Function()
'Ewww quite dirty
g_mFormProgress.Text = "Canceling..."
bCanceled = True
ClassThread.Abort(g_mUploadThread, False)
Return True
End Function)
g_mFormProgress.Show(Me)
End Sub)
Dim mUploadAction As Action(Of ULong) = (Sub(iBytesUplaoded As ULong)
Dim iProgress As Integer = ClassTools.ClassMath.ClampInt(CInt((iBytesUplaoded / iFileLenght) * 100), 0, 100)
ClassThread.ExecAsync(Me, Sub()
If (g_mFormProgress IsNot Nothing AndAlso Not g_mFormProgress.IsDisposed) Then
If (g_mFormProgress.m_Progress <> iProgress) Then
g_mFormProgress.m_Progress = iProgress
End If
End If
End Sub)
End Sub)
Select Case (iProtocolType)
Case ENUM_FTP_PROTOCOL_TYPE.FTP
Dim mClassFTP As New ClassFTP(sHost, sUsername, sPassword)
mClassFTP.UploadFile(sFiles(i), sDestinationFile, mUploadAction)
Case Else
Using mClassSFTP As New Renci.SshNet.SftpClient(sHost, sUsername, sPassword)
mClassSFTP.Connect()
Using mStream As New IO.FileStream(sFiles(i), IO.FileMode.Open, IO.FileAccess.Read)
mClassSFTP.UploadFile(mStream, sDestinationFile, mUploadAction)
End Using
End Using
End Select
g_mPluginFTP.g_mFormMain.PrintInformation("[INFO]", "Upload Success!")
Next
Finally
ClassThread.ExecAsync(Me, Sub()
If (g_mFormProgress IsNot Nothing AndAlso Not g_mFormProgress.IsDisposed) Then
g_mFormProgress.Dispose()
g_mFormProgress = Nothing
End If
End Sub)
End Try
ClassThread.ExecAsync(Me, Sub() Me.Close())
Catch ex As Threading.ThreadAbortException
If (bCanceled) Then
g_mPluginFTP.g_mFormMain.PrintInformation("[ERRO]", "Upload canceled!")
ClassThread.ExecAsync(Me, Sub() Me.Close())
End If
Throw
Catch ex As Exception
g_mPluginFTP.g_mFormMain.PrintInformation("[ERRO]", "Upload failed!")
ClassExceptionLog.WriteToLogMessageBox(ex)
ClassThread.ExecAsync(Me, Sub() TableLayoutPanel_Controls.Enabled = True)
End Try
End Sub) With {
.IsBackground = True,
.Priority = Threading.ThreadPriority.Lowest
}
g_mUploadThread.Start()
Exit For
End If
Next
Catch ex As Exception
ClassExceptionLog.WriteToLogMessageBox(ex)
End Try
End Sub
Private Sub Button_AddEntry_Click(sender As Object, e As EventArgs) Handles Button_AddEntry.Click
Try
Dim sDatabaseEntry As String = ComboBox_DatabaseEntry.Text
If (String.IsNullOrEmpty(sDatabaseEntry)) Then
Throw New ArgumentException("Invalid database entry")
End If
Dim sHost As String = TextBox_Host.Text
If (String.IsNullOrEmpty(sHost)) Then
Throw New ArgumentException("Invalid host")
End If
Dim sDestinationPath As String = TextBox_DestinationPath.Text
Dim iProtocol As ENUM_FTP_PROTOCOL_TYPE
Select Case (ComboBox_Protocol.SelectedIndex)
Case 0
iProtocol = ENUM_FTP_PROTOCOL_TYPE.FTP
Case Else
iProtocol = ENUM_FTP_PROTOCOL_TYPE.SFTP
End Select
g_lFtpEntries.Add(New STRUC_FTP_ENTRY_ITEM(sHost, sDatabaseEntry, sDestinationPath, iProtocol))
FillListView()
SaveData()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Button_Cancel_Click(sender As Object, e As EventArgs) Handles Button_Cancel.Click
Me.Close()
End Sub
Private Sub FormFTP_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
CleanUp()
End Sub
Private Sub LoadData()
Try
g_lFtpEntries.Clear()
g_mSecureStorage.Open()
Using mIni As New ClassIni(g_mSecureStorage.m_String(System.Text.Encoding.Default))
For Each sSection As String In mIni.GetSectionNames
Dim sHost As String = mIni.ReadKeyValue(sSection, "Host", Nothing)
Dim sDatabaseEntry As String = mIni.ReadKeyValue(sSection, "DatabaseEntry", Nothing)
Dim sDestinationPath As String = mIni.ReadKeyValue(sSection, "DestinationPath", Nothing)
Dim sProtocol As String = mIni.ReadKeyValue(sSection, "Protocol", "FTP")
If (String.IsNullOrEmpty(sHost) OrElse String.IsNullOrEmpty(sDatabaseEntry)) Then
Continue For
End If
Dim iProtocolType As ENUM_FTP_PROTOCOL_TYPE
Select Case (sProtocol)
Case "SFTP"
iProtocolType = ENUM_FTP_PROTOCOL_TYPE.SFTP
Case Else
iProtocolType = ENUM_FTP_PROTOCOL_TYPE.FTP
End Select
g_lFtpEntries.Add(New STRUC_FTP_ENTRY_ITEM(sHost, sDatabaseEntry, sDestinationPath, iProtocolType))
Next
End Using
Catch ex As Exception
ClassExceptionLog.WriteToLogMessageBox(ex)
End Try
End Sub
Private Sub SaveData()
Try
Using mIni As New ClassIni
For Each mFtpItem In g_lFtpEntries.ToArray
Dim sSection As String = Guid.NewGuid.ToString
mIni.WriteKeyValue(sSection, "Host", mFtpItem.sHost)
mIni.WriteKeyValue(sSection, "DatabaseEntry", mFtpItem.sDatabaseEntry)
mIni.WriteKeyValue(sSection, "DestinationPath", mFtpItem.sDestinationPath)
mIni.WriteKeyValue(sSection, "Protocol", If(mFtpItem.iProtocolType = ENUM_FTP_PROTOCOL_TYPE.FTP, "FTP", "SFTP"))
Next
g_mSecureStorage.m_String(System.Text.Encoding.Default) = mIni.ExportToString
End Using
g_mSecureStorage.Close()
Catch ex As Exception
ClassExceptionLog.WriteToLogMessageBox(ex)
End Try
End Sub
Private Sub FillListView()
Dim lListViewItems As New List(Of ListViewItem)
For Each mFtpItem In g_lFtpEntries.ToArray
Dim mListViewItemData = New ClassListViewItemData(New String() {mFtpItem.sDatabaseEntry, mFtpItem.sHost, mFtpItem.sDestinationPath, If(mFtpItem.iProtocolType = ENUM_FTP_PROTOCOL_TYPE.FTP, "FTP", "SFTP")})
mListViewItemData.g_mData("GUID") = mFtpItem.sGUID
lListViewItems.Add(mListViewItemData)
Next
ListView_FtpEntries.BeginUpdate()
ListView_FtpEntries.Items.Clear()
ListView_FtpEntries.Items.AddRange(lListViewItems.ToArray)
ClassTools.ClassControls.ClassListView.AutoResizeColumns(ListView_FtpEntries)
ListView_FtpEntries.EndUpdate()
End Sub
Private Sub CleanUp()
ClassThread.Abort(g_mUploadThread)
If (g_mFormProgress IsNot Nothing AndAlso Not g_mFormProgress.IsDisposed) Then
g_mFormProgress.Dispose()
g_mFormProgress = Nothing
End If
End Sub
End Class
|
<filename>admin/wmi/wbem/scripting/test/vbscript/putclass.vbs
'***************************************************************************
'This script tests the ability to set up instances with keyholes and read
'back the path
'***************************************************************************
On Error Resume Next
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer ("lamard3", "root\sms\site_la3", "smsadmin", "Elvis1")
Service.Security_.ImpersonationLevel = 3
Set o = Service.Get ("sms_package")
WScript.Echo o.Path_.DisplayName
Set NewPackage = o.SpawnInstance_
NewPackage.Description = "Scripting API Test Package"
Set ObjectPath = NewPackage.Put_
WScript.Echo "Path of new Package is", ObjectPath.RelPath
if Err <> 0 Then
WScript.Echo Err.Description
End if
|
Function build_spiral(n)
'declare a two dimentional array
Dim matrix()
ReDim matrix(n-1,n-1)
'determine starting point
x = (n-1)/2 : y = (n-1)/2
'set the initial iterations
x_max = 1 : y_max = 1 : count = 1
'set initial direction
dir = "R"
'populate the array
For i = 1 To n*n
l = Len(n*n)
If IsPrime(i) Then
matrix(x,y) = Right("000" & i,l)
Else
matrix(x,y) = String(l,"-")
End If
Select Case dir
Case "R"
If x_max > 0 Then
x = x + 1 : x_max = x_max - 1
Else
dir = "U" : y_max = count
y = y - 1 : y_max = y_max - 1
End If
Case "U"
If y_max > 0 Then
y = y - 1 : y_max = y_max - 1
Else
dir = "L" : count = count + 1 : x_max = count
x = x - 1 : x_max = x_max - 1
End If
Case "L"
If x_max > 0 Then
x = x - 1 : x_max = x_max - 1
Else
dir = "D" : y_max = count
y = y + 1 : y_max = y_max - 1
End If
Case "D"
If y_max > 0 Then
y = y + 1 : y_max = y_max - 1
Else
dir = "R" : count = count + 1 : x_max = count
x = x + 1 : x_max = x_max - 1
End If
End Select
Next
'print the matrix
For y = 0 To n - 1
For x = 0 To n - 1
If x = n - 1 Then
WScript.StdOut.Write matrix(x,y)
Else
WScript.StdOut.Write matrix(x,y) & vbTab
End If
Next
WScript.StdOut.WriteLine
Next
End Function
Function IsPrime(n)
If n = 2 Then
IsPrime = True
ElseIf n <= 1 Or n Mod 2 = 0 Then
IsPrime = False
Else
IsPrime = True
For i = 3 To Int(Sqr(n)) Step 2
If n Mod i = 0 Then
IsPrime = False
Exit For
End If
Next
End If
End Function
'test with 9
build_spiral(9)
|
<filename>Task/Truncatable-primes/VBScript/truncatable-primes.vb
start_time = Now
lt = 0
rt = 0
For h = 1 To 1000000
If IsLeftTruncatable(h) And h > lt Then
lt = h
End If
If IsRightTruncatable(h) And h > rt Then
rt = h
End If
Next
end_time = now
WScript.StdOut.WriteLine "Largest LTP from 1..1000000: " & lt
WScript.StdOut.WriteLine "Largest RTP from 1..1000000: " & rt
WScript.StdOut.WriteLine "Elapse Time(seconds) : " & DateDiff("s",start_time,end_time)
'------------
Function IsLeftTruncatable(n)
IsLeftTruncatable = False
c = 0
For i = Len(n) To 1 Step -1
If InStr(1,n,"0") > 0 Then
Exit For
End If
If IsPrime(Right(n,i)) Then
c = c + 1
End If
Next
If c = Len(n) Then
IsLeftTruncatable = True
End If
End Function
Function IsRightTruncatable(n)
IsRightTruncatable = False
c = 0
For i = Len(n) To 1 Step -1
If InStr(1,n,"0") > 0 Then
Exit For
End If
If IsPrime(Left(n,i)) Then
c = c + 1
End If
Next
If c = Len(n) Then
IsRightTruncatable = True
End If
End Function
Function IsPrime(n)
If n = 2 Then
IsPrime = True
ElseIf n <= 1 Or n Mod 2 = 0 Then
IsPrime = False
Else
IsPrime = True
For i = 3 To Int(Sqr(n)) Step 2
If n Mod i = 0 Then
IsPrime = False
Exit For
End If
Next
End If
End Function
|
<filename>admin/pchealth/authtools/prodtools/applets/rkconversion/frmmain.frm<gh_stars>10-100
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "RKConversion"
ClientHeight = 2055
ClientLeft = 45
ClientTop = 330
ClientWidth = 4710
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2055
ScaleWidth = 4710
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txtCABOutDesk
Height = 285
Left = 1560
TabIndex = 5
Top = 840
Width = 3015
End
Begin VB.TextBox txtCABOutSrv
Height = 285
Left = 1560
TabIndex = 3
Top = 480
Width = 3015
End
Begin VB.TextBox txtCABIn
Height = 285
Left = 1560
TabIndex = 1
Top = 120
Width = 3015
End
Begin VB.TextBox txtXML
Height = 285
Left = 1560
TabIndex = 7
Top = 1200
Width = 3015
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Height = 375
Left = 3720
TabIndex = 8
Top = 1560
Width = 855
End
Begin VB.Label lblCAB
Caption = "CAB Out (&Desktop):"
Height = 255
Index = 2
Left = 120
TabIndex = 4
Top = 840
Width = 1455
End
Begin VB.Label lblCAB
Caption = "CAB Out (&Server):"
Height = 255
Index = 1
Left = 120
TabIndex = 2
Top = 480
Width = 1335
End
Begin VB.Label lblCAB
Caption = "CAB &In:"
Height = 255
Index = 0
Left = 120
TabIndex = 0
Top = 120
Width = 1335
End
Begin VB.Label lblXML
Caption = "&XML:"
Height = 255
Left = 120
TabIndex = 6
Top = 1200
Width = 495
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Example:
'<RKCONVERSION>
'
' <TAXONOMY_ENTRIES_DESKTOP>
' <TAXONOMY_ENTRY
' TITLE = ""
' TYPE="0"
' ENTRY = "Windows_Resource_Kit"
' ACTION = "ADD"
' CATEGORY = ""
' />
' <TAXONOMY_ENTRY
' TITLE = "Professional"
' TYPE="0"
' ENTRY = "Professional"
' ACTION = "ADD"
' CATEGORY = "Windows_Resource_Kit"
' />
' <TAXONOMY_ENTRY
' TITLE = "Server"
' TYPE="0"
' ENTRY = "Server"
' ACTION = "ADD"
' CATEGORY = "Windows_Resource_Kit"
' />
' <TAXONOMY_ENTRY
' TITLE = "Tools"
' TYPE="0"
' ENTRY = "Tools"
' ACTION = "ADD"
' CATEGORY = "Windows_Resource_Kit"
' />
' </TAXONOMY_ENTRIES_DESKTOP>
'
' <TAXONOMY_ENTRIES_SERVER>
' <TAXONOMY_ENTRY
' TITLE = ""
' CATEGORY = ""
' URI = "MS-ITS:%HELP_LOCATION%\reskit.chm::/HSS_rktopic.htm"
' ACTION = "DEL"
' />
' </TAXONOMY_ENTRIES_SERVER>
'
' <PREFIX_STRINGS>
' <PREFIX_STRING
' FIND = "Windows_Whistler_Resource_Kit/Professional"
' REPLACE = "Windows_Resource_Kit/Professional"
' />
' <PREFIX_STRING
' FIND = "Windows_Whistler_Resource_Kit/Server"
' REPLACE = "Windows_Resource_Kit/Server"
' />
' <PREFIX_STRING
' FIND = "Tools"
' REPLACE = "Windows_Resource_Kit/Tools"
' />
' </PREFIX_STRINGS>
'
' <PRODUCT ID="Windows_XP_PRO" DISPLAYNAME="Windows XP Professional"/>
'
'</RKCONVERSION>
'In the server CAB, SKU VALUE is set to SERVER.
'In the desktop CAB, SKU VALUE is set to DESKTOP.
'
'Any Category starting with
' Tools...
'is replaced by
' Windows_Resource_Kit/Tools...
'All other entries are deleted from the Desktop HHT.
'
'The TAXONOMY_ENTRY's are prepended as is to the TAXONOMY_ENTRY's of the input.
Private Const OPT_CAB_IN_C As String = "i"
Private Const OPT_CAB_OUT_SRV_C As String = "s"
Private Const OPT_CAB_OUT_DESK_C As String = "d"
Private Const OPT_XML_C As String = "x"
Private Const PKG_DESC_FILE_C As String = "package_description.xml"
' (E)lements, (A)ttributes, and (V)alues in the (C)ab
Private Const EC_SKU_C As String = "HELPCENTERPACKAGE/SKU"
Private Const EC_PRODUCT_C As String = "HELPCENTERPACKAGE/PRODUCT"
Private Const EC_HHT_C As String = "HELPCENTERPACKAGE/METADATA/HHT"
Private Const EC_TAXONOMY_ENTRIES_C As String = "METADATA/TAXONOMY_ENTRIES"
Private Const AC_VALUE_C As String = "VALUE"
Private Const AC_FILE_C As String = "FILE"
Private Const AC_CATEGORY_C As String = "CATEGORY"
Private Const AC_keep_C As String = "RKConversionKeep"
Private Const AC_ID_C As String = "ID"
Private Const AC_DISPLAYNAME_C As String = "DISPLAYNAME"
Private Const VC_SERVER_C As String = "SERVER"
Private Const VC_DESKTOP_C As String = "DESKTOP"
Private Const VC_keep_value_C As String = "1"
' (E)lements, and (A)ttributes in the (X)ml file
Private Const EX_TAXONOMY_ENTRIES_DESKTOP_C As String = "RKCONVERSION/TAXONOMY_ENTRIES_DESKTOP"
Private Const EX_TAXONOMY_ENTRIES_SERVER_C As String = "RKCONVERSION/TAXONOMY_ENTRIES_SERVER"
Private Const EX_PREFIX_STRINGS_C As String = "RKCONVERSION/PREFIX_STRINGS"
Private Const EX_PRODUCT_C As String = "RKCONVERSION/PRODUCT"
Private Const AX_FIND_C As String = "FIND"
Private Const AX_REPLACE_C As String = "REPLACE"
Private Const AX_ID_C As String = "ID"
Private Const AX_DISPLAYNAME_C As String = "DISPLAYNAME"
Private FSO As Scripting.FileSystemObject
Private WS As IWshShell
Private Type FindReplace
strFind As String
strReplace As String
End Type
Private Sub Form_Load()
Dim strCommand As String
Set FSO = New Scripting.FileSystemObject
Set WS = CreateObject("Wscript.Shell")
strCommand = Trim$(Command$)
txtCABIn = GetOption(strCommand, OPT_CAB_IN_C, True)
txtCABOutSrv = GetOption(strCommand, OPT_CAB_OUT_SRV_C, True)
txtCABOutDesk = GetOption(strCommand, OPT_CAB_OUT_DESK_C, True)
txtXML = GetOption(strCommand, OPT_XML_C, True)
If (Len(strCommand) <> 0) Then
Me.Show Modal:=False
cmdOK_Click
End If
End Sub
Private Sub cmdOK_Click()
Dim strFolderSrv As String
Dim strFolderDesk As String
If (txtCABIn = "" Or txtCABOutSrv = "" Or txtCABOutDesk = "" Or txtXML = "") Then
MsgBox "Please specify all 4 arguments"
Exit Sub
End If
Me.Enabled = False
strFolderSrv = p_Cab2Folder(txtCABIn)
strFolderDesk = p_Cab2Folder(txtCABIn)
FixPerSe txtXML, strFolderSrv, strFolderDesk
p_Folder2Cab strFolderSrv, txtCABOutSrv
p_Folder2Cab strFolderDesk, txtCABOutDesk
FSO.DeleteFolder strFolderSrv, Force:=True
FSO.DeleteFolder strFolderDesk, Force:=True
Unload Me
End Sub
Private Sub FixPerSe( _
ByVal i_strXML As String, _
ByVal i_strFolderSrv As String, _
ByVal i_strFolderDesk As String _
)
Dim strHHT As String
Dim strHHTDesktop As String
Dim strHHTServer As String
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim arrFR() As FindReplace
p_SetSKUAndGetHHT i_strFolderSrv, VC_SERVER_C, strHHT
p_SetSKUAndGetHHT i_strFolderDesk, VC_DESKTOP_C, strHHT
Set DOMDoc = New MSXML2.DOMDocument
DOMDoc.Load i_strXML
strHHTServer = i_strFolderSrv & "\" & strHHT
strHHTDesktop = i_strFolderDesk & "\" & strHHT
Set DOMNode = DOMDoc.selectSingleNode(EX_PREFIX_STRINGS_C)
p_GetFindReplace DOMNode, arrFR
p_Replace arrFR, strHHTDesktop
Set DOMNode = DOMDoc.selectSingleNode(EX_TAXONOMY_ENTRIES_SERVER_C)
p_PrependTaxonomyEntries DOMNode, strHHTServer
Set DOMNode = DOMDoc.selectSingleNode(EX_TAXONOMY_ENTRIES_DESKTOP_C)
p_PrependTaxonomyEntries DOMNode, strHHTDesktop
p_SetProductIdAndDisplayName DOMDoc, i_strFolderDesk
End Sub
Private Sub p_PrependTaxonomyEntries( _
ByVal i_DOMNode As MSXML2.IXMLDOMNode, _
ByVal u_strHHT As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNodeTaxoEntries As MSXML2.IXMLDOMNode
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMAttr As MSXML2.IXMLDOMAttribute
Dim DOMElement As MSXML2.IXMLDOMElement
Dim intIndex As Long
Dim strQuery As String
If (i_DOMNode Is Nothing) Then
Exit Sub
End If
Set DOMDoc = New MSXML2.DOMDocument
DOMDoc.Load u_strHHT
Set DOMNodeTaxoEntries = DOMDoc.selectSingleNode(EC_TAXONOMY_ENTRIES_C)
intIndex = i_DOMNode.childNodes.length - 1
Do While intIndex >= 0
Set DOMNode = i_DOMNode.childNodes.Item(intIndex)
DOMNodeTaxoEntries.insertBefore DOMNode, DOMNodeTaxoEntries.childNodes.Item(0)
intIndex = intIndex - 1
Loop
DOMDoc.save u_strHHT
End Sub
Private Sub p_Replace( _
ByRef i_arrFR() As FindReplace, _
ByVal u_strHHT As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNodeTaxoEntries As MSXML2.IXMLDOMNode
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMAttr As MSXML2.IXMLDOMAttribute
Dim DOMElement As MSXML2.IXMLDOMElement
Dim intIndex As Long
Dim strFind As String
Dim strReplace As String
Dim strQuery As String
Set DOMDoc = New MSXML2.DOMDocument
DOMDoc.Load u_strHHT
DOMDoc.setProperty "SelectionLanguage", "XPath"
For intIndex = LBound(i_arrFR) To UBound(i_arrFR)
strFind = i_arrFR(intIndex).strFind
strReplace = i_arrFR(intIndex).strReplace
strQuery = "descendant::TAXONOMY_ENTRY[attribute::" & AC_CATEGORY_C & "[starts-with(" & _
"translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')," & _
"""" & strFind & """ )]]"
Set DOMNodeList = DOMDoc.selectNodes(strQuery)
For Each DOMNode In DOMNodeList
Set DOMAttr = DOMNode.Attributes.getNamedItem(AC_CATEGORY_C)
DOMAttr.Value = Replace$(DOMAttr.Value, strFind, strReplace, , 1, vbTextCompare)
Set DOMElement = DOMNode
DOMElement.setAttribute AC_keep_C, VC_keep_value_C
Next
Next
Set DOMNodeTaxoEntries = DOMDoc.selectSingleNode(EC_TAXONOMY_ENTRIES_C)
For Each DOMNode In DOMNodeTaxoEntries.childNodes
If (DOMNode.Attributes.getNamedItem(AC_keep_C) Is Nothing) Then
DOMNodeTaxoEntries.removeChild DOMNode
Else
Set DOMElement = DOMNode
DOMElement.removeAttribute AC_keep_C
End If
Next
DOMDoc.save u_strHHT
End Sub
Private Sub p_GetFindReplace( _
ByVal i_DOMNode As MSXML2.IXMLDOMNode, _
ByRef o_arrFR() As FindReplace _
)
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMAttr As MSXML2.IXMLDOMAttribute
Dim intIndex As Long
For Each DOMNode In i_DOMNode.childNodes
ReDim Preserve o_arrFR(intIndex)
Set DOMAttr = DOMNode.Attributes.getNamedItem(AX_FIND_C)
o_arrFR(intIndex).strFind = LCase$(DOMAttr.Value)
Set DOMAttr = DOMNode.Attributes.getNamedItem(AX_REPLACE_C)
o_arrFR(intIndex).strReplace = DOMAttr.Value
intIndex = intIndex + 1
Next
End Sub
Private Sub p_SetSKUAndGetHHT( _
ByVal i_strFolder As String, _
ByVal i_strValue As String, _
ByRef o_strHHT As String _
)
Dim strFile As String
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMAttr As MSXML2.IXMLDOMAttribute
strFile = i_strFolder & "\" & PKG_DESC_FILE_C
Set DOMDoc = New MSXML2.DOMDocument
DOMDoc.Load strFile
Set DOMNode = DOMDoc.selectSingleNode(EC_SKU_C)
Set DOMAttr = DOMNode.Attributes.getNamedItem(AC_VALUE_C)
DOMAttr.Value = i_strValue
Set DOMNode = DOMDoc.selectSingleNode(EC_HHT_C)
Set DOMAttr = DOMNode.Attributes.getNamedItem(AC_FILE_C)
o_strHHT = DOMAttr.Value
DOMDoc.save strFile
End Sub
Private Sub p_SetProductIdAndDisplayName( _
ByVal i_DOMDoc As MSXML2.DOMDocument, _
ByVal i_strFolder As String _
)
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMAttr As MSXML2.IXMLDOMAttribute
Dim DOMDoc As MSXML2.DOMDocument
Dim Element As MSXML2.IXMLDOMElement
Dim strProductId As String
Dim strDisplayName As String
Dim strFile As String
Set DOMNode = i_DOMDoc.selectSingleNode(EX_PRODUCT_C)
If (DOMNode Is Nothing) Then
Exit Sub
End If
Set DOMAttr = DOMNode.Attributes.getNamedItem(AX_ID_C)
If (Not DOMAttr Is Nothing) Then
strProductId = DOMAttr.Value
End If
Set DOMAttr = DOMNode.Attributes.getNamedItem(AX_DISPLAYNAME_C)
If (Not DOMAttr Is Nothing) Then
strDisplayName = DOMAttr.Value
End If
strFile = i_strFolder & "\" & PKG_DESC_FILE_C
Set DOMDoc = New MSXML2.DOMDocument
DOMDoc.Load strFile
Set Element = DOMDoc.selectSingleNode(EC_PRODUCT_C)
Element.setAttribute AC_ID_C, strProductId
Set Element = DOMDoc.selectSingleNode(EC_SKU_C)
Element.setAttribute AC_DISPLAYNAME_C, strDisplayName
DOMDoc.save strFile
End Sub
Private Function p_Cab2Folder( _
ByVal i_strCabFile As String _
) As String
Dim strFolder As String
Dim strCmd As String
p_Cab2Folder = ""
' We grab a Temporary Filename and create a folder out of it
strFolder = FSO.GetSpecialFolder(TemporaryFolder) + "\" + FSO.GetTempName
FSO.CreateFolder strFolder
' We uncab CAB contents into the Source CAB Contents dir.
strCmd = "cabarc X " + i_strCabFile + " " + strFolder + "\"
WS.Run strCmd, True, True
p_Cab2Folder = strFolder
End Function
Private Sub p_Folder2Cab( _
ByVal i_strFolder As String, _
ByVal i_strCabFile As String _
)
Dim strCmd As String
If (FSO.FileExists(i_strCabFile)) Then
FSO.DeleteFile i_strCabFile, True
End If
strCmd = "cabarc -r -s 6144 n """ & i_strCabFile & """ " & i_strFolder & "\*"
WS.Run strCmd, True, True
End Sub
|
<reponame>npocmaka/Windows-Server-2003<filename>net/homenet/config/dll/algplugin_add.vbs
Set objAlgInstall = CreateObject("Alg.AlgSetup")
Error = objAlgInstall.Add("{6E590D41-F6BC-4dad-AC21-7DC40D304059}","ezNET", "TheUnitTest","1.0",0, "1313, 12, 45")
Error = objAlgInstall.Add("{6E590D51-F6BC-4dad-AC21-7DC40D304059}","AOL", "ICQ messaging","1.0",1, "23, 11")
Error = objAlgInstall.Add("{6E590D61-F6BC-4dad-AC21-7DC40D304059}","Microsoft", "FTP Client/Server Protocol","1.0",1,"21")
|
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmHHT
BorderStyle = 1 'Fixed Single
Caption = "Create HHT and CAB"
ClientHeight = 4230
ClientLeft = 45
ClientTop = 330
ClientWidth = 6015
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4230
ScaleWidth = 6015
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txtLanguage
Height = 285
Left = 960
TabIndex = 14
Text = "ALL"
Top = 3000
Width = 4935
End
Begin VB.CommandButton cmdCreate
Caption = "Create"
Height = 375
Left = 3360
TabIndex = 16
Top = 3720
Width = 1215
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 4680
TabIndex = 17
Top = 3720
Width = 1215
End
Begin VB.Frame fraSKU
Caption = "SKU"
Height = 2295
Left = 120
TabIndex = 3
Top = 600
Width = 5775
Begin VB.OptionButton optSKU
Caption = "All"
Height = 255
Index = 11
Left = 120
TabIndex = 20
Top = 1920
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "Server"
Height = 255
Index = 10
Left = 3000
TabIndex = 19
Top = 1560
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "Desktop"
Height = 255
Index = 9
Left = 120
TabIndex = 18
Top = 1560
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "Windows Me"
Height = 255
Index = 0
Left = 120
TabIndex = 4
Top = 240
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "64-bit Datacenter Server"
Height = 255
Index = 8
Left = 3000
TabIndex = 12
Top = 1200
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "64-bit Advanced Server"
Height = 255
Index = 6
Left = 3000
TabIndex = 10
Top = 720
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "64-bit Professional"
Height = 255
Index = 3
Left = 120
TabIndex = 7
Top = 960
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "32-bit Datacenter Server"
Height = 255
Index = 7
Left = 3000
TabIndex = 11
Top = 960
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "32-bit Advanced Server"
Height = 255
Index = 5
Left = 3000
TabIndex = 9
Top = 480
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "32-bit Server"
Height = 255
Index = 4
Left = 3000
TabIndex = 8
Top = 240
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "32-bit Professional"
Height = 255
Index = 2
Left = 120
TabIndex = 6
Top = 720
Width = 2295
End
Begin VB.OptionButton optSKU
Caption = "32-bit Personal"
Height = 255
Index = 1
Left = 120
TabIndex = 5
Top = 480
Width = 2295
End
End
Begin VB.CommandButton cmdBrowse
Caption = "..."
Height = 315
Left = 5520
TabIndex = 2
Top = 120
Width = 375
End
Begin VB.TextBox txtName
Height = 315
Left = 1080
TabIndex = 1
Tag = "1"
Top = 120
Width = 4335
End
Begin MSComDlg.CommonDialog dlgFileOpen
Left = 120
Top = 3720
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Label lblLanguage
Caption = "Language:"
Height = 255
Left = 120
TabIndex = 13
Top = 3000
Width = 855
End
Begin VB.Label lblStatus
BorderStyle = 1 'Fixed Single
Caption = "Entry #1 created"
Height = 255
Left = 120
TabIndex = 15
Tag = "1"
Top = 3360
Width = 5775
End
Begin VB.Label lblName
Caption = "File Name:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 855
End
End
Attribute VB_Name = "frmHHT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const DATE_FORMAT_C As String = "Short Date"
Private WithEvents p_clsHHT As AuthDatabase.HHT
Attribute p_clsHHT.VB_VarHelpID = -1
Private Enum SKU_INDEX_E
SI_WINDOWS_MILLENNIUM_E = 0
SI_STANDARD_E = 1
SI_PROFESSIONAL_E = 2
SI_PROFESSIONAL_64_E = 3
SI_SERVER_E = 4
SI_ADVANCED_SERVER_E = 5
SI_ADVANCED_SERVER_64_E = 6
SI_DATA_CENTER_SERVER_E = 7
SI_DATA_CENTER_SERVER_64_E = 8
SI_DESKTOP_ALL_E = 9
SI_SERVER_ALL_E = 10
SI_ALL_E = 11
End Enum
Private Const FILE_FILTER_CAB_C As String = "CAB File (*.cab)|*.cab"
Private p_blnCreating As Boolean
Private p_blnCancelHHTCreation As Boolean
Private Sub Form_Load()
Set p_clsHHT = g_AuthDatabase.HHT
p_blnCreating = False
p_blnCancelHHTCreation = False
p_SetToolTips
SetFontInternal Me
End Sub
Private Sub Form_Activate()
optSKU(SI_STANDARD_E).Value = True
lblStatus = ""
p_DisableCreate
cmdCreate.Default = True
cmdCancel.Cancel = True
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If (p_blnCreating) Then
cmdCancel_Click
Cancel = True
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set p_clsHHT = Nothing
End Sub
Private Sub txtName_Change()
If (txtName = "") Then
p_DisableCreate
Else
p_EnableCreate
End If
End Sub
Private Sub cmdBrowse_Click()
On Error GoTo LErrorHandler
dlgFileOpen.CancelError = True
dlgFileOpen.Flags = cdlOFNHideReadOnly
dlgFileOpen.Filter = FILE_FILTER_CAB_C
dlgFileOpen.ShowSave
txtName = dlgFileOpen.FileName
LEnd:
Exit Sub
LErrorHandler:
GoTo LEnd
End Sub
Sub cmdCreate_Click()
Dim strName As String
On Error GoTo LErrorHandler
p_blnCreating = True
p_DisableEverythingExceptCancel
p_clsHHT.GenerateCAB txtName, p_GetSelectedSKU, txtLanguage
LEnd:
p_blnCreating = False
p_Exit
Exit Sub
LErrorHandler:
Select Case Err.Number
Case cdlCancel, errCancel
' Nothing. The user cancelled.
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case errProductIdOrVersionMissing
MsgBox "The Product ID or Product Version is missing. " & _
"Please configure these values by selecting Tools/Parameters.", vbExclamation + vbOKOnly
Case Else
g_ErrorInfo.SetInfoAndDump "cmdCreate_Click"
End Select
GoTo LEnd
End Sub
Private Sub cmdCancel_Click()
If (p_blnCreating) Then
p_blnCreating = False
p_blnCancelHHTCreation = True
p_DisableCancel
Else
p_Exit
End If
End Sub
Private Sub p_clsHHT_ReportStatus(ByVal strStatus As String, ByRef blnCancel As Boolean)
lblStatus = strStatus
DoEvents
If (p_blnCancelHHTCreation) Then
blnCancel = True
p_Exit
End If
End Sub
Private Function p_GetSelectedSKU() As SKU_E
If (optSKU(SI_STANDARD_E).Value) Then
p_GetSelectedSKU = SKU_STANDARD_E
ElseIf (optSKU(SI_PROFESSIONAL_E).Value) Then
p_GetSelectedSKU = SKU_PROFESSIONAL_E
ElseIf (optSKU(SI_SERVER_E).Value) Then
p_GetSelectedSKU = SKU_SERVER_E
ElseIf (optSKU(SI_ADVANCED_SERVER_E).Value) Then
p_GetSelectedSKU = SKU_ADVANCED_SERVER_E
ElseIf (optSKU(SI_DATA_CENTER_SERVER_E).Value) Then
p_GetSelectedSKU = SKU_DATA_CENTER_SERVER_E
ElseIf (optSKU(SI_PROFESSIONAL_64_E).Value) Then
p_GetSelectedSKU = SKU_PROFESSIONAL_64_E
ElseIf (optSKU(SI_ADVANCED_SERVER_64_E).Value) Then
p_GetSelectedSKU = SKU_ADVANCED_SERVER_64_E
ElseIf (optSKU(SI_DATA_CENTER_SERVER_64_E).Value) Then
p_GetSelectedSKU = SKU_DATA_CENTER_SERVER_64_E
ElseIf (optSKU(SI_WINDOWS_MILLENNIUM_E).Value) Then
p_GetSelectedSKU = SKU_WINDOWS_MILLENNIUM_E
ElseIf (optSKU(SI_SERVER_ALL_E).Value) Then
p_GetSelectedSKU = SKU_SERVER_ALL_E
ElseIf (optSKU(SI_DESKTOP_ALL_E).Value) Then
p_GetSelectedSKU = SKU_DESKTOP_ALL_E
ElseIf (optSKU(SI_ALL_E).Value) Then
p_GetSelectedSKU = SKU_ALL_E
End If
End Function
Private Sub p_Exit()
Set frmHHT = Nothing
Unload Me
End Sub
Private Sub p_EnableCreate()
cmdCreate.Enabled = True
End Sub
Private Sub p_DisableCreate()
cmdCreate.Enabled = False
End Sub
Private Sub p_DisableCancel()
cmdCancel.Enabled = False
End Sub
Private Sub p_DisableEverythingExceptCancel()
Dim optIndex As Long
lblName.Enabled = False
txtName.Enabled = False
cmdBrowse.Enabled = False
fraSKU.Enabled = False
For optIndex = optSKU.LBound To optSKU.UBound
optSKU(optIndex).Enabled = False
Next
p_DisableCreate
End Sub
Private Sub p_SetToolTips()
lblName.ToolTipText = "Type the path and name of the CAB file to create."
txtName.ToolTipText = lblName.ToolTipText
fraSKU.ToolTipText = "Select the desired SKU for which to create the file."
End Sub
|
<reponame>lihaokang/riscv_pulpino<gh_stars>0
/*
----------------------------------------------------------------------------------
- -
- Copyright Mentor Graphics Corporation -
- All Rights Reserved -
- -
- THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY -
- INFORMATION WHICH IS THE PROPERTY OF MENTOR GRAPHICS -
- CORPORATION OR ITS LICENSORS AND IS SUBJECT -
- TO LICENSE TERMS. -
- -
----------------------------------------------------------------------------------
- File created by: membistipGenerate -
- Version: 2017.1 -
- Created on: Sat Feb 23 20:09:41 CST 2019 -
----------------------------------------------------------------------------------
*/
module READONLY_LVISION_MBISTPG_ASSEMBLY (
BIST_CLK,
CS,
OE,
DVS3,
DVS2,
DVS1,
DVS0,
DVSE,
A8,
A7,
A6,
A5,
A4,
A3,
A2,
A1,
A0,
DO31,
DO30,
DO29,
DO28,
DO27,
DO26,
DO25,
DO24,
DO23,
DO22,
DO21,
DO20,
DO19,
DO18,
DO17,
DO16,
DO15,
DO14,
DO13,
DO12,
DO11,
DO10,
DO9,
DO8,
DO7,
DO6,
DO5,
DO4,
DO3,
DO2,
DO1,
DO0
, BIST_SHIFT , BIST_HOLD , BIST_SETUP2 , BIST_SETUP , MBISTPG_TESTDATA_SELECT
, TCK_MODE
, TCK , LV_TM , MBISTPG_MEM_RST , MBISTPG_REDUCED_ADDR_CNT_EN
, MBISTPG_ASYNC_RESETN
, BIST_SI , MBISTPG_SO , MBISTPG_EN , MBISTPG_DONE , MBISTPG_GO );
output MBISTPG_GO;
output MBISTPG_DONE;
input MBISTPG_EN;
output MBISTPG_SO;
input BIST_SI;
input MBISTPG_ASYNC_RESETN;
input MBISTPG_REDUCED_ADDR_CNT_EN;
input MBISTPG_MEM_RST;
input LV_TM;
input TCK;
input TCK_MODE;
input MBISTPG_TESTDATA_SELECT;
input[1:0] BIST_SETUP;
wire[1:0] BIST_SETUP;
input BIST_SETUP2;
input BIST_HOLD;
input BIST_SHIFT;
input BIST_CLK;
input CS;
input OE;
input DVS3;
input DVS2;
input DVS1;
input DVS0;
input DVSE;
input A8;
input A7;
input A6;
input A5;
input A4;
input A3;
input A2;
input A1;
input A0;
output DO31;
output DO30;
output DO29;
output DO28;
output DO27;
output DO26;
output DO25;
output DO24;
output DO23;
output DO22;
output DO21;
output DO20;
output DO19;
output DO18;
output DO17;
output DO16;
output DO15;
output DO14;
output DO13;
output DO12;
output DO11;
output DO10;
output DO9;
output DO8;
output DO7;
output DO6;
output DO5;
output DO4;
output DO3;
output DO2;
output DO1;
output DO0;
// [start] : AUT Instance
READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST_INST (
.CK ( BIST_CLK ),
.CS ( CS ),
.OE ( OE ),
.DVS3 ( DVS3 ),
.DVS2 ( DVS2 ),
.DVS1 ( DVS1 ),
.DVS0 ( DVS0 ),
.DVSE ( DVSE ),
.A8 ( A8 ),
.A7 ( A7 ),
.A6 ( A6 ),
.A5 ( A5 ),
.A4 ( A4 ),
.A3 ( A3 ),
.A2 ( A2 ),
.A1 ( A1 ),
.A0 ( A0 ),
.DO31 ( DO31 ),
.DO30 ( DO30 ),
.DO29 ( DO29 ),
.DO28 ( DO28 ),
.DO27 ( DO27 ),
.DO26 ( DO26 ),
.DO25 ( DO25 ),
.DO24 ( DO24 ),
.DO23 ( DO23 ),
.DO22 ( DO22 ),
.DO21 ( DO21 ),
.DO20 ( DO20 ),
.DO19 ( DO19 ),
.DO18 ( DO18 ),
.DO17 ( DO17 ),
.DO16 ( DO16 ),
.DO15 ( DO15 ),
.DO14 ( DO14 ),
.DO13 ( DO13 ),
.DO12 ( DO12 ),
.DO11 ( DO11 ),
.DO10 ( DO10 ),
.DO9 ( DO9 ),
.DO8 ( DO8 ),
.DO7 ( DO7 ),
.DO6 ( DO6 ),
.DO5 ( DO5 ),
.DO4 ( DO4 ),
.DO3 ( DO3 ),
.DO2 ( DO2 ),
.DO1 ( DO1 ),
.DO0 ( DO0 )
,
.BIST_CLK(BIST_CLK),
.BIST_SHIFT(BIST_SHIFT),
.BIST_HOLD(BIST_HOLD),
.BIST_SETUP2(BIST_SETUP2),
.BIST_SETUP({
BIST_SETUP[1],
BIST_SETUP[0]
}),
.MBISTPG_TESTDATA_SELECT(MBISTPG_TESTDATA_SELECT),
.TCK_MODE(TCK_MODE),
.TCK(TCK),
.LV_TM(LV_TM),
.MBISTPG_MEM_RST(MBISTPG_MEM_RST),
.MBISTPG_REDUCED_ADDR_CNT_EN(MBISTPG_REDUCED_ADDR_CNT_EN),
.MBISTPG_ASYNC_RESETN(MBISTPG_ASYNC_RESETN),
.BIST_SI(BIST_SI),
.MBISTPG_SO(MBISTPG_SO),
.MBISTPG_EN(MBISTPG_EN),
.MBISTPG_DONE(MBISTPG_DONE),
.MBISTPG_GO(MBISTPG_GO));
// [end] : AUT Instance
// [start] : monitor module
`ifdef LVISION_MBIST_DUMP_MEM_SIGNAL
//synopsys translate_off
// Instances
`define controllerInstPath READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST_INST.READONLY_MBIST_CTRL
`define mem0InstPathStp0 READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST_INST.MEM0_MEM_INST
`define mem0InstPath READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST_INST.MEM0_MEM_INST
// Instances
// Controller signals
`define BIST_CLK `controllerInstPath.BIST_CLK
`define BIST_DONE `controllerInstPath.BIST_DONE
`define BIST_EN `controllerInstPath.MBISTPG_EN
`define BIST_COL_ADD `controllerInstPath.BIST_COL_ADD
`define BIST_ROW_ADD `controllerInstPath.BIST_ROW_ADD
`define LAST_STATE_DONE `controllerInstPath.LAST_STATE_DONE
`define SETUP_PULSE1 `controllerInstPath.MBISTPG_FSM.SETUP_PULSE1
`define SETUP_PULSE2 `controllerInstPath.MBISTPG_FSM.SETUP_PULSE2
`define NEXT_ALGO `controllerInstPath.MBISTPG_FSM.NEXT_ALGO
`define ALGO_DONE `controllerInstPath.LAST_STATE_DONE
`define LAST_STEP 1'b1
`define LAST_PORT 1'b1
`define INST_POINTER `controllerInstPath.MBISTPG_POINTER_CNTRL.INST_POINTER
`define LOOP_A_CNTR `controllerInstPath.MBISTPG_REPEAT_LOOP_CNTRL.LOOP_A_CNTR
`define LOOP_B_CNTR `controllerInstPath.MBISTPG_REPEAT_LOOP_CNTRL.LOOP_B_CNTR
`define CNTR_A_MAX `controllerInstPath.MBISTPG_REPEAT_LOOP_CNTRL.CNTR_A_MAX
`define CNTR_B_MAX `controllerInstPath.MBISTPG_REPEAT_LOOP_CNTRL.CNTR_B_MAX
`define BIST_COLLAR_EN0 `controllerInstPath.BIST_COLLAR_EN0
`define CMP_EN0 `controllerInstPath.BIST_CMP
// Controller signals
// Internal signals
integer addMapFile; // Address mapping output file
integer stepEnable0; // Step 0 started flag
integer algoCycleCount0; // Step 0 algorithm cycle count
integer compareCount0; // Step 0 compare count
integer algoCycleCount0_subtotal; // Step 0 algorithm cycle count after adjustment
integer compareCount0_subtotal; // Step 0 compare count after adjustment
integer algoCycleCount_total; // Overall algorithm cycle count
integer compareCount_total; // Overall compare count after
reg [4:0] PHASE_READONLY;
reg [2:0] SUB_PHASE_READONLY;
// Internal signals
// Initialize variables
initial
begin
stepEnable0 = 0;
algoCycleCount0 = 0;
compareCount0 = 0;
algoCycleCount0_subtotal = 0;
compareCount0_subtotal = 0;
algoCycleCount_total = 0;
compareCount_total = 0;
PHASE_READONLY = 1;
SUB_PHASE_READONLY = 0;
addMapFile = $fopen("READONLY_physical_logical_address.txt","w");
end
// Initialize variables
//--------------------
//-- Step 0 --
//--------------------
// Step 0
always @ (posedge `BIST_CLK) begin
if (`BIST_EN) begin
if (stepEnable0 == 0) begin
if (`BIST_COLLAR_EN0 && `SETUP_PULSE2) begin // Next cycle is RUN state
stepEnable0 = 1;
$display("[[");
$display("[[ Starting memory signal dump for Step 0 Test Port 0 of Controller READONLY");
$display("[[");
$fwrite(addMapFile,"//\n");
$fwrite(addMapFile,"// Starting address signal dump for Step 0 Test Port 0 of Controller READONLY\n");
$fwrite(addMapFile,"//\n");
$fwrite(addMapFile,"// MemoryID : %s\n", "MEM0 (SKAA110_512X32BM1A)");
$fwrite(addMapFile,"// MemoryType : %s\n", "ROM");
$fwrite(addMapFile,"// Address : %s\n", "A8 A7 A6 A5 A4 A3 A2 A1 A0");
$fwrite(addMapFile,"// Data : %s\n", "DO31 DO30 DO29 DO28 DO27 DO26 DO25 DO24 DO23 DO22 DO21 DO20 DO19 DO18 DO17 DO16 DO15 DO14 DO13 DO12 DO11 DO10 DO9 DO8 DO7 DO6 DO5 DO4 DO3 DO2 DO1 DO0");
$fwrite(addMapFile,"// Algorithm : %s\n", "READONLY");
$fwrite(addMapFile,"// Phase : %s\n", "2.0");
$fwrite(addMapFile,"//\n");
$fwrite(addMapFile,"// Bank Row Column | Address | Data \n");
$fwrite(addMapFile,"//\n");
end
end else begin
if (`ALGO_DONE && `LAST_PORT) begin // Step 0 algorithm done
stepEnable0 = 0;
// Adjust step total
algoCycleCount0_subtotal = algoCycleCount0;
compareCount0_subtotal = compareCount0;
// Update overall total
algoCycleCount_total = algoCycleCount_total + algoCycleCount0_subtotal;
compareCount_total = compareCount_total + compareCount0_subtotal;
$display("[[");
$display("[[ Summary for Controller READONLY");
$display("[[");
$display("[[ Step 0 Number of Algorithm Cycles = %d", algoCycleCount0_subtotal);
$display("[[ Step 0 Number of Compares = %d", compareCount0_subtotal);
$display("[[");
$display("[[ Total Number of Algorithm Cycles = %d", algoCycleCount_total);
$display("[[ Total Number of Compares = %d", compareCount_total);
$display("[[");
end
end // stepEnable0
end // BIST_EN
end
always @ (negedge `BIST_CLK) begin
if (stepEnable0 == 1) begin
if (`CMP_EN0) begin
compareCount0 = compareCount0 + 1;
end
end
end
always @ (negedge `BIST_CLK) begin
if (stepEnable0 == 1) begin
algoCycleCount0 = algoCycleCount0 + 1;
end
end
// Display signals
always @ (posedge `BIST_CLK) begin
if (stepEnable0 == 1) begin
$display(
"[[",
//"%d", $time,
//" %d", algoCycleCount0,
" %s", "READONLY",
" PHASE=%d.%d ;", PHASE_READONLY, SUB_PHASE_READONLY,
" INST=%d ;", `INST_POINTER,
" LOOPA=%d ;", `LOOP_A_CNTR,
" LOOPB=%d ;", `LOOP_B_CNTR,
" %s", "MEM0",
" A8=%h", `mem0InstPath.A8,
" A7=%h", `mem0InstPath.A7,
" A6=%h", `mem0InstPath.A6,
" A5=%h", `mem0InstPath.A5,
" A4=%h", `mem0InstPath.A4,
" A3=%h", `mem0InstPath.A3,
" A2=%h", `mem0InstPath.A2,
" A1=%h", `mem0InstPath.A1,
" A0=%h", `mem0InstPath.A0,
" DO31=%h", `mem0InstPath.DO31,
" DO30=%h", `mem0InstPath.DO30,
" DO29=%h", `mem0InstPath.DO29,
" DO28=%h", `mem0InstPath.DO28,
" DO27=%h", `mem0InstPath.DO27,
" DO26=%h", `mem0InstPath.DO26,
" DO25=%h", `mem0InstPath.DO25,
" DO24=%h", `mem0InstPath.DO24,
" DO23=%h", `mem0InstPath.DO23,
" DO22=%h", `mem0InstPath.DO22,
" DO21=%h", `mem0InstPath.DO21,
" DO20=%h", `mem0InstPath.DO20,
" DO19=%h", `mem0InstPath.DO19,
" DO18=%h", `mem0InstPath.DO18,
" DO17=%h", `mem0InstPath.DO17,
" DO16=%h", `mem0InstPath.DO16,
" DO15=%h", `mem0InstPath.DO15,
" DO14=%h", `mem0InstPath.DO14,
" DO13=%h", `mem0InstPath.DO13,
" DO12=%h", `mem0InstPath.DO12,
" DO11=%h", `mem0InstPath.DO11,
" DO10=%h", `mem0InstPath.DO10,
" DO9=%h", `mem0InstPath.DO9,
" DO8=%h", `mem0InstPath.DO8,
" DO7=%h", `mem0InstPath.DO7,
" DO6=%h", `mem0InstPath.DO6,
" DO5=%h", `mem0InstPath.DO5,
" DO4=%h", `mem0InstPath.DO4,
" DO3=%h", `mem0InstPath.DO3,
" DO2=%h", `mem0InstPath.DO2,
" DO1=%h", `mem0InstPath.DO1,
" DO0=%h", `mem0InstPath.DO0,
" CS=%h", `mem0InstPath.CS,
" OE=%h", `mem0InstPath.OE,
" DVS3=%h", `mem0InstPath.DVS3,
" DVS2=%h", `mem0InstPath.DVS2,
" DVS1=%h", `mem0InstPath.DVS1,
" DVS0=%h", `mem0InstPath.DVS0,
" DVSE=%h", `mem0InstPath.DVSE,
" %s", ";",
" "
); // $display
end
end
// Display signals
// Address map file
always @ (posedge `BIST_CLK) begin
// Note:
// The map file only contains the address and data
// values for the first memory in each controller step.
if (stepEnable0 == 1 &&
`CMP_EN0 == 1'b1 &&
`INST_POINTER == 2'b01 && `CNTR_A_MAX == 1'b0) begin
$fwrite(addMapFile,
" %s", "-",
" %b", `BIST_ROW_ADD,
" %b", `BIST_COL_ADD,
" ",
"%b", `mem0InstPath.A8,
"%b", `mem0InstPath.A7,
"%b", `mem0InstPath.A6,
"%b", `mem0InstPath.A5,
"%b", `mem0InstPath.A4,
"%b", `mem0InstPath.A3,
"%b", `mem0InstPath.A2,
"%b", `mem0InstPath.A1,
"%b", `mem0InstPath.A0,
" ",
"%b", `mem0InstPath.DO31,
"%b", `mem0InstPath.DO30,
"%b", `mem0InstPath.DO29,
"%b", `mem0InstPath.DO28,
"%b", `mem0InstPath.DO27,
"%b", `mem0InstPath.DO26,
"%b", `mem0InstPath.DO25,
"%b", `mem0InstPath.DO24,
"%b", `mem0InstPath.DO23,
"%b", `mem0InstPath.DO22,
"%b", `mem0InstPath.DO21,
"%b", `mem0InstPath.DO20,
"%b", `mem0InstPath.DO19,
"%b", `mem0InstPath.DO18,
"%b", `mem0InstPath.DO17,
"%b", `mem0InstPath.DO16,
"%b", `mem0InstPath.DO15,
"%b", `mem0InstPath.DO14,
"%b", `mem0InstPath.DO13,
"%b", `mem0InstPath.DO12,
"%b", `mem0InstPath.DO11,
"%b", `mem0InstPath.DO10,
"%b", `mem0InstPath.DO9,
"%b", `mem0InstPath.DO8,
"%b", `mem0InstPath.DO7,
"%b", `mem0InstPath.DO6,
"%b", `mem0InstPath.DO5,
"%b", `mem0InstPath.DO4,
"%b", `mem0InstPath.DO3,
"%b", `mem0InstPath.DO2,
"%b", `mem0InstPath.DO1,
"%b", `mem0InstPath.DO0,
" \n"
); // $fwrite
end
end
// Address map file
// Step 0
//synopsys translate_on
`endif
// [end] : monitor module
endmodule // READONLY_LVISION_MBISTPG_ASSEMBLY_ASSEMBLY
// [start] : AUT module
module READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST (
CK,
CS,
OE,
DVS3,
DVS2,
DVS1,
DVS0,
DVSE,
A8,
A7,
A6,
A5,
A4,
A3,
A2,
A1,
A0,
DO31,
DO30,
DO29,
DO28,
DO27,
DO26,
DO25,
DO24,
DO23,
DO22,
DO21,
DO20,
DO19,
DO18,
DO17,
DO16,
DO15,
DO14,
DO13,
DO12,
DO11,
DO10,
DO9,
DO8,
DO7,
DO6,
DO5,
DO4,
DO3,
DO2,
DO1,
DO0
, BIST_CLK , BIST_SHIFT , BIST_HOLD , BIST_SETUP2 , BIST_SETUP
, MBISTPG_TESTDATA_SELECT
, TCK_MODE , TCK , LV_TM , MBISTPG_MEM_RST , MBISTPG_REDUCED_ADDR_CNT_EN
, MBISTPG_ASYNC_RESETN
, BIST_SI , MBISTPG_SO , MBISTPG_EN , MBISTPG_DONE , MBISTPG_GO );
wire MEM0_INTERF_INST_A0;
wire MEM0_INTERF_INST_A1;
wire MEM0_INTERF_INST_A2;
wire MEM0_INTERF_INST_A3;
wire MEM0_INTERF_INST_A4;
wire MEM0_INTERF_INST_A5;
wire MEM0_INTERF_INST_A6;
wire MEM0_INTERF_INST_A7;
wire MEM0_INTERF_INST_A8;
wire MEM0_INTERF_INST_OE;
wire MEM0_INTERF_INST_CS;
wire BIST_GO;
wire BIST_COLLAR_HOLD;
wire BIST_CLEAR;
wire BIST_CLEAR_DEFAULT;
wire BIST_COLLAR_SETUP;
wire BIST_SO;
wire BIST_SI_LV_1;
wire BIST_SHIFT_COLLAR;
wire BIST_COLLAR_EN;
wire[4:0] BIST_ROW_ADD;
wire[3:0] BIST_COL_ADD;
wire BIST_CMP;
wire BIST_OUTPUTENABLE;
wire BIST_SELECT;
wire MBISTPG_COMPARE_MISR;
output MBISTPG_GO;
wire MBISTPG_GO;
output MBISTPG_DONE;
wire MBISTPG_DONE;
input MBISTPG_EN;
wire MBISTPG_EN;
output MBISTPG_SO;
wire MBISTPG_SO;
input BIST_SI;
wire BIST_SI;
input MBISTPG_ASYNC_RESETN;
wire MBISTPG_ASYNC_RESETN;
input MBISTPG_REDUCED_ADDR_CNT_EN;
wire MBISTPG_REDUCED_ADDR_CNT_EN;
input MBISTPG_MEM_RST;
wire MBISTPG_MEM_RST;
input LV_TM;
wire LV_TM;
input TCK;
wire TCK;
input TCK_MODE;
wire TCK_MODE;
input MBISTPG_TESTDATA_SELECT;
wire MBISTPG_TESTDATA_SELECT;
input[1:0] BIST_SETUP;
wire[1:0] BIST_SETUP;
input BIST_SETUP2;
wire BIST_SETUP2;
input BIST_HOLD;
wire BIST_HOLD;
input BIST_SHIFT;
wire BIST_SHIFT;
input BIST_CLK;
wire BIST_CLK;
input CK;
input CS;
input OE;
input DVS3;
input DVS2;
input DVS1;
input DVS0;
input DVSE;
input A8;
input A7;
input A6;
input A5;
input A4;
input A3;
input A2;
input A1;
input A0;
output DO31;
output DO30;
output DO29;
output DO28;
output DO27;
output DO26;
output DO25;
output DO24;
output DO23;
output DO22;
output DO21;
output DO20;
output DO19;
output DO18;
output DO17;
output DO16;
output DO15;
output DO14;
output DO13;
output DO12;
output DO11;
output DO10;
output DO9;
output DO8;
output DO7;
output DO6;
output DO5;
output DO4;
output DO3;
output DO2;
output DO1;
output DO0;
SKAA110_512X32BM1A MEM0_MEM_INST ( //
// Clock ports
.CK ( CK ),
.CS(MEM0_INTERF_INST_CS),
.OE(MEM0_INTERF_INST_OE), // i
// Functional ports
.DVS3 ( DVS3 ), // i
.DVS2 ( DVS2 ), // i
.DVS1 ( DVS1 ), // i
.DVS0 ( DVS0 ), // i
.DVSE ( DVSE ),
.A8(MEM0_INTERF_INST_A8),
.A7(MEM0_INTERF_INST_A7),
.A6(MEM0_INTERF_INST_A6),
.A5(MEM0_INTERF_INST_A5),
.A4(MEM0_INTERF_INST_A4),
.A3(MEM0_INTERF_INST_A3),
.A2(MEM0_INTERF_INST_A2),
.A1(MEM0_INTERF_INST_A1),
.A0(MEM0_INTERF_INST_A0), // i
// Data ports
.DO31 ( DO31 ), // o
.DO30 ( DO30 ), // o
.DO29 ( DO29 ), // o
.DO28 ( DO28 ), // o
.DO27 ( DO27 ), // o
.DO26 ( DO26 ), // o
.DO25 ( DO25 ), // o
.DO24 ( DO24 ), // o
.DO23 ( DO23 ), // o
.DO22 ( DO22 ), // o
.DO21 ( DO21 ), // o
.DO20 ( DO20 ), // o
.DO19 ( DO19 ), // o
.DO18 ( DO18 ), // o
.DO17 ( DO17 ), // o
.DO16 ( DO16 ), // o
.DO15 ( DO15 ), // o
.DO14 ( DO14 ), // o
.DO13 ( DO13 ), // o
.DO12 ( DO12 ), // o
.DO11 ( DO11 ), // o
.DO10 ( DO10 ), // o
.DO9 ( DO9 ), // o
.DO8 ( DO8 ), // o
.DO7 ( DO7 ), // o
.DO6 ( DO6 ), // o
.DO5 ( DO5 ), // o
.DO4 ( DO4 ), // o
.DO3 ( DO3 ), // o
.DO2 ( DO2 ), // o
.DO1 ( DO1 ), // o
.DO0 ( DO0 ) // o
); //
READONLY_LVISION_MBISTPG_CTRL READONLY_MBIST_CTRL
(
.BIST_CLK(BIST_CLK),
.BIST_SHIFT(BIST_SHIFT),
.BIST_HOLD(BIST_HOLD),
.BIST_SETUP2(BIST_SETUP2),
.BIST_SETUP({
BIST_SETUP[1],
BIST_SETUP[0]
}),
.MBISTPG_TESTDATA_SELECT(MBISTPG_TESTDATA_SELECT),
.TCK_MODE(TCK_MODE),
.TCK(TCK),
.LV_TM(LV_TM),
.MBISTPG_MEM_RST(MBISTPG_MEM_RST),
.MBISTPG_REDUCED_ADDR_CNT_EN(MBISTPG_REDUCED_ADDR_CNT_EN),
.MBISTPG_ASYNC_RESETN(MBISTPG_ASYNC_RESETN),
.BIST_SI(BIST_SI),
.MBISTPG_SO(MBISTPG_SO),
.MBISTPG_EN(MBISTPG_EN),
.MBISTPG_DONE(MBISTPG_DONE),
.MBISTPG_GO(MBISTPG_GO),
.MBISTPG_COMPARE_MISR(MBISTPG_COMPARE_MISR),
.BIST_SELECT(BIST_SELECT),
.BIST_OUTPUTENABLE(BIST_OUTPUTENABLE),
.BIST_CMP(BIST_CMP),
.BIST_COL_ADD(BIST_COL_ADD),
.BIST_ROW_ADD(BIST_ROW_ADD),
.BIST_COLLAR_EN0(BIST_COLLAR_EN),
.BIST_SHIFT_COLLAR(BIST_SHIFT_COLLAR),
.MEM0_BIST_COLLAR_SI(BIST_SI_LV_1),
.MEM0_BIST_COLLAR_SO(BIST_SO),
.BIST_COLLAR_SETUP(BIST_COLLAR_SETUP),
.BIST_CLEAR_DEFAULT(BIST_CLEAR_DEFAULT),
.BIST_CLEAR(BIST_CLEAR),
.BIST_COLLAR_HOLD(BIST_COLLAR_HOLD),
.BIST_COLLAR_GO(BIST_GO));
READONLY_LVISION_MEM0_INTERFACE MEM0_INTERF_INST
( .SCAN_OBS_FLOPS(),
.CS_IN(CS),
.OE_IN(OE),
.A8_IN(A8),
.A7_IN(A7),
.A6_IN(A6),
.A5_IN(A5),
.A4_IN(A4),
.A3_IN(A3),
.A2_IN(A2),
.A1_IN(A1),
.A0_IN(A0),
.BIST_CLK(BIST_CLK),
.TCK_MODE(TCK_MODE),
.LV_TM(LV_TM),
.MBISTPG_COMPARE_MISR(MBISTPG_COMPARE_MISR),
.BIST_SELECT(BIST_SELECT),
.BIST_OUTPUTENABLE(BIST_OUTPUTENABLE),
.BIST_CMP(BIST_CMP),
.BIST_COL_ADD(BIST_COL_ADD),
.BIST_ROW_ADD(BIST_ROW_ADD),
.BIST_EN(MBISTPG_EN),
.BIST_COLLAR_EN(BIST_COLLAR_EN),
.BIST_ASYNC_RESETN(MBISTPG_ASYNC_RESETN),
.BIST_TESTDATA_SELECT_TO_COLLAR(MBISTPG_TESTDATA_SELECT),
.BIST_SHIFT_COLLAR(BIST_SHIFT_COLLAR),
.BIST_SI(BIST_SI_LV_1),
.BIST_SO(BIST_SO),
.BIST_COLLAR_SETUP(BIST_COLLAR_SETUP),
.BIST_CLEAR_DEFAULT(BIST_CLEAR_DEFAULT),
.BIST_CLEAR(BIST_CLEAR),
.BIST_SETUP0(BIST_SETUP[0]),
.BIST_COLLAR_HOLD(BIST_COLLAR_HOLD),
.BIST_GO(BIST_GO),
.CS(MEM0_INTERF_INST_CS),
.OE(MEM0_INTERF_INST_OE),
.A8(MEM0_INTERF_INST_A8),
.A7(MEM0_INTERF_INST_A7),
.A6(MEM0_INTERF_INST_A6),
.A5(MEM0_INTERF_INST_A5),
.A4(MEM0_INTERF_INST_A4),
.A3(MEM0_INTERF_INST_A3),
.A2(MEM0_INTERF_INST_A2),
.A1(MEM0_INTERF_INST_A1),
.A0(MEM0_INTERF_INST_A0),
.DO31(DO31),
.DO30(DO30),
.DO29(DO29),
.DO28(DO28),
.DO27(DO27),
.DO26(DO26),
.DO25(DO25),
.DO24(DO24),
.DO23(DO23),
.DO22(DO22),
.DO21(DO21),
.DO20(DO20),
.DO19(DO19),
.DO18(DO18),
.DO17(DO17),
.DO16(DO16),
.DO15(DO15),
.DO14(DO14),
.DO13(DO13),
.DO12(DO12),
.DO11(DO11),
.DO10(DO10),
.DO9(DO9),
.DO8(DO8),
.DO7(DO7),
.DO6(DO6),
.DO5(DO5),
.DO4(DO4),
.DO3(DO3),
.DO2(DO2),
.DO1(DO1),
.DO0(DO0));
endmodule // READONLY_LVISION_MBISTPG_ASSEMBLY_UNDER_TEST
// [end] : AUT module
|
<reponame>LaudateCorpus1/RosettaCodeData
Option Base 1
Private Function sq_add(arr As Variant, x As Double) As Variant
Dim res() As Variant
ReDim res(UBound(arr))
For i = 1 To UBound(arr)
res(i) = arr(i) + x
Next i
sq_add = res
End Function
Private Function beadsort(ByVal a As Variant) As Variant
Dim poles() As Variant
ReDim poles(WorksheetFunction.Max(a))
For i = 1 To UBound(a)
For j = 1 To a(i)
poles(j) = poles(j) + 1
Next j
Next i
For j = 1 To UBound(a)
a(j) = 0
Next j
For i = 1 To UBound(poles)
For j = 1 To poles(i)
a(j) = a(j) + 1
Next j
Next i
beadsort = a
End Function
Public Sub main()
Debug.Print Join(beadsort([{5, 3, 1, 7, 4, 1, 1, 20}]), ", ")
End Sub
|
Sub Main()
Debug.Assert ROT13("abc") = "nop"
Debug.Assert ROT13("nop") = "abc"
End Sub
|
<script id="Connections" language="VBScript" src="D:\include\ConnectionStrings.vbs"/>
|
VERSION 5.00
Begin VB.Form VendorInfo
Caption = "Vendor Information"
ClientHeight = 5730
ClientLeft = 60
ClientTop = 345
ClientWidth = 6195
LinkTopic = "Form1"
ScaleHeight = 5730
ScaleWidth = 6195
StartUpPosition = 3 'Windows Default
Visible = 0 'False
Begin VB.CommandButton Exit
Caption = "Exit"
Height = 375
Left = 120
TabIndex = 11
Top = 5280
Width = 1095
End
Begin VB.TextBox txtName
Height = 375
Left = 1320
TabIndex = 0
Top = 240
Width = 3975
End
Begin VB.TextBox Address
Height = 375
Left = 1320
TabIndex = 1
Top = 840
Width = 3975
End
Begin VB.TextBox City
Height = 375
Left = 1320
TabIndex = 2
Top = 1440
Width = 3975
End
Begin VB.TextBox State
Height = 375
Left = 1320
TabIndex = 3
Top = 2040
Width = 3975
End
Begin VB.TextBox Country
Height = 375
Left = 1320
TabIndex = 5
Top = 3240
Width = 3975
End
Begin VB.TextBox PostalCode
Height = 375
Left = 1320
TabIndex = 4
Top = 2640
Width = 3975
End
Begin VB.TextBox Telephone
Height = 375
Left = 1320
TabIndex = 6
Top = 3840
Width = 3975
End
Begin VB.TextBox Email
Height = 375
Left = 1320
TabIndex = 7
Top = 4440
Width = 2295
End
Begin VB.CommandButton Next
Caption = "&Next >"
Default = -1 'True
Height = 375
Left = 5040
TabIndex = 8
Top = 5280
Width = 1095
End
Begin VB.CommandButton Prev
Caption = "< &Prev"
Height = 375
Left = 3720
TabIndex = 10
Top = 5280
Width = 1095
End
Begin VB.Label Label1
Caption = "Name:"
Height = 255
Left = 120
TabIndex = 18
Top = 240
Width = 495
End
Begin VB.Label Label3
Caption = "Address:"
Height = 255
Left = 120
TabIndex = 17
Top = 960
Width = 615
End
Begin VB.Label Label4
Caption = "City:"
Height = 255
Left = 120
TabIndex = 16
Top = 1560
Width = 375
End
Begin VB.Label Label5
Caption = "State/Province:"
Height = 255
Left = 120
TabIndex = 15
Top = 2160
Width = 1110
End
Begin VB.Label Label6
Caption = "Country:"
Height = 255
Left = 120
TabIndex = 14
Top = 3360
Width = 615
End
Begin VB.Label Label7
Caption = "Postal code:"
Height = 255
Left = 120
TabIndex = 13
Top = 2760
Width = 975
End
Begin VB.Label Label8
Caption = "Telephone:"
Height = 255
Left = 120
TabIndex = 12
Top = 3960
Width = 855
End
Begin VB.Label Label9
Caption = "Support email:"
Height = 255
Left = 120
TabIndex = 9
Top = 4560
Width = 1095
End
End
Attribute VB_Name = "VendorInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Sub SaveData()
strVendName = txtName.Text
strVendAddress = Address.Text
strVendCity = City.Text
strVendState = State.Text
strVendCountry = Country.Text
strVendPostalCode = PostalCode.Text
strVendTelephone = Telephone.Text
strVendEmail = Email.Text
End Sub
Private Sub Next_Click()
ProdInfo.Left = VendorInfo.Left
ProdInfo.Top = VendorInfo.Top
VendorInfo.Visible = False
ProdInfo.Visible = True
End Sub
Private Sub Prev_Click()
frmXML.Left = VendorInfo.Left
frmXML.Top = VendorInfo.Top
VendorInfo.Visible = False
frmXML.Visible = True
End Sub
Private Sub Form_Load()
txtName = strVendName
Address = strVendAddress
City = strVendCity
State = strVendState
Country = strVendCountry
PostalCode = strVendPostalCode
Telephone = strVendTelephone
Email = strVendEmail
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveData
frmXML.EndProgram
End Sub
Private Sub Exit_Click()
frmXML.EndProgram
End Sub
|
Public Sub reduce()
s = [{1,2,3,4,5}]
Debug.Print WorksheetFunction.Sum(s)
Debug.Print WorksheetFunction.Product(s)
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
' Sum of a series
for i=1 to 1000
s=s+1/i^2
next
wscript.echo s
|
<filename>Task/HTTP/VBScript/http.vb
Option Explicit
Const sURL="http://rosettacode.org/"
Dim oHTTP
Set oHTTP = CreateObject("Microsoft.XmlHTTP")
On Error Resume Next
oHTTP.Open "GET", sURL, False
oHTTP.Send ""
If Err.Number = 0 Then
WScript.Echo oHTTP.responseText
Else
Wscript.Echo "error " & Err.Number & ": " & Err.Description
End If
Set oHTTP = Nothing
|
<gh_stars>1-10
Imports System
Imports System.Threading
Imports System.IO.Ports
Imports System.ComponentModel
Public Class Form1
Dim myPort As Array
Delegate Sub SetTextCallBack(ByVal [text] As String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Getting working COM port number
myPort = IO.Ports.SerialPort.GetPortNames()
cbxCOM.Items.AddRange(myPort)
btnWrite.Enabled = False
btnClose.Enabled = False
End Sub
Private Sub btnInit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInit.Click
SerialPort1.PortName = cbxCOM.Text
SerialPort1.BaudRate = cbxSpeed.Text
SerialPort1.Open()
btnInit.Enabled = False
btnWrite.Enabled = True
btnClose.Enabled = True
End Sub
Private Sub btnWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrite.Click
' Converting 7 bit numbers to appropriate byte
Dim numberStr As String
numberStr = txtNumIn.Text
Dim p As Integer = numberStr.Length()
Dim number As Byte = 0
Dim j As Integer = 0
For j = 0 To (p - 1)
If numberStr(j) = "0" Then
number = number * 2
Else
number = (number * 2) + 1
End If
Next j
j = 0
' Checking which operation is selected, and sending appropriate byte
If op0.Checked = True Then
SerialPort1.Write("@")
ElseIf op1.Checked = True Then
SerialPort1.Write("L")
ElseIf op2.Checked = True Then
SerialPort1.Write("M")
ElseIf op3.Checked = True Then
SerialPort1.Write("N")
ElseIf op4.Checked = True Then
SerialPort1.Write("F")
ElseIf op5.Checked = True Then
SerialPort1.Write("A")
ElseIf op6.Checked = True Then
SerialPort1.Write("G")
ElseIf op7.Checked = True Then
SerialPort1.Write("B")
ElseIf op8.Checked = True Then
SerialPort1.Write("H")
ElseIf op9.Checked = True Then
SerialPort1.Write("I")
ElseIf op10.Checked = True Then
SerialPort1.Write("]")
ElseIf op11.Checked = True Then
SerialPort1.Write("^")
ElseIf op12.Checked = True Then
SerialPort1.Write("K")
ElseIf op13.Checked = True Then
SerialPort1.Write("J")
ElseIf op14.Checked = True Then
SerialPort1.Write("R")
ElseIf op15.Checked = True Then
SerialPort1.Write("S")
ElseIf op16.Checked = True Then
SerialPort1.Write("T")
ElseIf op17.Checked = True Then
SerialPort1.Write("U")
ElseIf op18.Checked = True Then
SerialPort1.Write("V")
ElseIf op19.Checked = True Then
SerialPort1.Write("W")
ElseIf op20.Checked = True Then
SerialPort1.Write("X")
ElseIf op21.Checked = True Then
SerialPort1.Write("Y")
ElseIf op22.Checked = True Then
SerialPort1.Write("Z")
ElseIf op23.Checked = True Then
SerialPort1.Write("\")
ElseIf op24.Checked = True Then
SerialPort1.Write("[")
ElseIf op25.Checked = True Then
SerialPort1.Write("_")
ElseIf op26.Checked = True Then
SerialPort1.Write("P")
Else
SerialPort1.Write("@")
End If
' Checking which register is selected, and sending appropriate byte
If (rx0.Checked = True) And (ry0.Checked = True) Then
SerialPort1.Write("@")
ElseIf (rx0.Checked = True) And (ry1.Checked = True) Then
SerialPort1.Write("A")
ElseIf (rx0.Checked = True) And (ry2.Checked = True) Then
SerialPort1.Write("B")
ElseIf (rx0.Checked = True) And (ry3.Checked = True) Then
SerialPort1.Write("C")
ElseIf (rx1.Checked = True) And (ry0.Checked = True) Then
SerialPort1.Write("D")
ElseIf (rx1.Checked = True) And (ry1.Checked = True) Then
SerialPort1.Write("E")
ElseIf (rx1.Checked = True) And (ry2.Checked = True) Then
SerialPort1.Write("F")
ElseIf (rx1.Checked = True) And (ry3.Checked = True) Then
SerialPort1.Write("G")
ElseIf (rx2.Checked = True) And (ry0.Checked = True) Then
SerialPort1.Write("H")
ElseIf (rx2.Checked = True) And (ry1.Checked = True) Then
SerialPort1.Write("I")
ElseIf (rx2.Checked = True) And (ry2.Checked = True) Then
SerialPort1.Write("J")
ElseIf (rx2.Checked = True) And (ry3.Checked = True) Then
SerialPort1.Write("K")
ElseIf (rx3.Checked = True) And (ry0.Checked = True) Then
SerialPort1.Write("L")
ElseIf (rx3.Checked = True) And (ry1.Checked = True) Then
SerialPort1.Write("M")
ElseIf (rx3.Checked = True) And (ry2.Checked = True) Then
SerialPort1.Write("N")
ElseIf (rx3.Checked = True) And (ry3.Checked = True) Then
SerialPort1.Write("O")
Else
SerialPort1.Write("@")
End If
'Sending the number
If number = 0 Then
SerialPort1.Write(Chr(0))
Else
SerialPort1.Write(Chr(number))
End If
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
SerialPort1.Close()
btnInit.Enabled = True
btnWrite.Enabled = False
btnClose.Enabled = False
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.txtOutput.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Dim g As String 'keep one bit of incoming bits
Dim k As Integer 'lenght of incoming bits
Dim m As Integer 'for FOR statement
k = (text.Length - 1)
For m = 0 To k
g = text.Substring(m, 1)
'Examine first bit for error detection
If Not ((g = Chr(48)) Or (g = Chr(49)) Or (g = Chr(13))) Then
Me.txtOutput.Text &= ("ERROR! Ignore the line below..." & Chr(13))
Else
txtBE.Text &= g
End If
g = Nothing
Next m
Me.txtOutput.Text &= txtBE.Text
txtBE.Clear()
'Placing the cursor to end of the textbox
txtOutput.Select(txtOutput.TextLength, 0)
txtOutput.ScrollToCaret()
End If
End Sub
Private Sub txtNumIn_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNumIn.KeyPress
Dim k As Byte = Asc(e.KeyChar)
If Not (e.KeyChar = "0" Or e.KeyChar = "1" Or k = 8 Or k = 13) Then e.Handled = True
End Sub
End Class
|
Private Function to_base(ByVal number As Long, base As Integer) As String
Dim digits As String, result As String
Dim i As Integer, digit As Integer
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
Do While number > 0
digit = number Mod base
result = Mid(digits, digit + 1, 1) & result
number = number \ base
Loop
to_base = result
End Function
Private Function from_base(number As String, base As Integer) As Long
Dim digits As String, result As Long
Dim i As Integer
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
result = Val(InStr(1, digits, Mid(number, 1, 1), vbTextCompare) - 1)
For i = 2 To Len(number)
result = result * base + Val(InStr(1, digits, Mid(number, i, 1), vbTextCompare) - 1)
Next i
from_base = result
End Function
Public Sub Non_decimal_radices_Convert()
Debug.Print "26 decimal in base 16 is: "; to_base(26, 16); ". Conversely, hexadecimal 1a in decimal is: "; from_base("1a", 16)
End Sub
|
'********************************************************************
'*
'* File: DEVICE.VBS
'* Created: July 1998
'* Version: 1.0
'*
'* Main Function: Controls devices on a machine.
'* Usage: DEVICE.VBS [/LIST | /START | /STOP] [/D:devicename] [/S:server]
'* [/O:outputfile] [/U:username] [/W:password] [/Q]
'*
'* Copyright (C) 1998 Microsoft Corporation
'*
'********************************************************************
OPTION EXPLICIT
ON ERROR RESUME NEXT
'Define constants
CONST CONST_ERROR = 0
CONST CONST_WSCRIPT = 1
CONST CONST_CSCRIPT = 2
CONST CONST_SHOW_USAGE = 3
CONST CONST_PROCEED = 4
'Declare variables
Dim strOutputFile, intOpMode, blnQuiet, i
Dim strServer, strDeviceCommand, strDeviceName, strUserName, strPassword
ReDim strArgumentArray(0)
'Initialize variables
strArgumentArray(0) = ""
blnQuiet = False
strServer = ""
strDeviceCommand = ""
strDeviceName = ""
strUserName = ""
strPassword = ""
strOutputFile = ""
intProcessId = 0
intTerminationCode = 0
'Get the command line arguments
For i = 0 to Wscript.arguments.count - 1
ReDim Preserve strArgumentArray(i)
strArgumentArray(i) = Wscript.arguments.Item(i)
Next
'Check whether the script is run using CScript
Select Case intChkProgram()
Case CONST_CSCRIPT
'Do Nothing
Case CONST_WSCRIPT
WScript.Echo "Please run this script using CScript." & vbCRLF & _
"This can be achieved by" & vbCRLF & _
"1. Using ""CScript DEVICE.VBS arguments"" for Windows 95/98 or" & vbCRLF & _
"2. Changing the default Windows Scripting Host setting to CScript" & vbCRLF & _
" using ""CScript //H:CScript //S"" and running the script using" & vbCRLF & _
" ""DEVICE.VBS arguments"" for Windows NT."
WScript.Quit
Case Else
WScript.Quit
End Select
'Parse the command line
intOpMode = intParseCmdLine(strArgumentArray, strDeviceName, strDeviceCommand, _
strServer, strOutputFile, strUserName, strPassword, blnQuiet)
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in parsing the command line."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
WScript.Quit
End If
Select Case intOpMode
Case CONST_SHOW_USAGE
Call ShowUsage()
Case CONST_PROCEED
Call Device(strDeviceName, strDeviceCommand, strServer, _
strOutputFile, strUserName, strPassword)
Case CONST_ERROR
'Do nothing.
Case Else 'Default -- should never happen
Print "Error occurred in passing parameters."
End Select
'********************************************************************
'*
'* Function intChkProgram()
'* Purpose: Determines which program is used to run this script.
'* Input: None
'* Output: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT,
'* and CONST_CSCRIPT.
'*
'********************************************************************
Private Function intChkProgram()
ON ERROR RESUME NEXT
Dim strFullName, strCommand, i, j
'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE
strFullName = WScript.FullName
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred."
If Err.Description <> "" Then
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
End If
intChkProgram = CONST_ERROR
Exit Function
End If
i = InStr(1, strFullName, ".exe", 1)
If i = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
j = InStrRev(strFullName, "\", i, 1)
If j = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
strCommand = Mid(strFullName, j+1, i-j-1)
Select Case LCase(strCommand)
Case "cscript"
intChkProgram = CONST_CSCRIPT
Case "wscript"
intChkProgram = CONST_WSCRIPT
Case Else 'should never happen
Print "An unexpected program is used to run this script."
Print "Only CScript.Exe or WScript.Exe can be used to run this script."
intChkProgram = CONST_ERROR
End Select
End If
End If
End Function
'********************************************************************
'*
'* Function intParseCmdLine()
'* Purpose: Parses the command line.
'* Input: strArgumentArray an array containing input from the command line
'* Output: strDeviceName a device name
'* strDeviceCommand one of List, Start, Stop
'* strServer a machine name
'* strOutputFile an output file name
'* strUserName the current user's name
'* strPassword the current <PASSWORD>'s password
'* blnQuiet specifies whether to suppress messages
'* intParseCmdLine is set to one of CONST_ERROR, CONST_SHOW_USAGE, CONST_PROCEED.
'*
'********************************************************************
Private Function intParseCmdLine(strArgumentArray, strDeviceName, strDeviceCommand, _
strServer, strOutputFile, strUserName, strPassword, blnQuiet)
ON ERROR RESUME NEXT
Dim strFlag, i
strFlag = strArgumentArray(0)
If strFlag = "" then 'No arguments have been received
Print "Arguments are required."
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End If
If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _
OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") OR (strFlag="h") Then
intParseCmdLine = CONST_SHOW_USAGE
Exit Function
End If
For i = 0 to UBound(strArgumentArray)
strFlag = LCase(Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1))
If Err.Number Then 'An error occurs if there is no : in the string
Err.Clear
Select Case LCase(strArgumentArray(i))
Case "/q"
blnQuiet = True
Case "/list"
strDeviceCommand = "list"
Case "/start"
strDeviceCommand = "start"
Case "/stop"
strDeviceCommand = "stop"
Case Else
Print strArgumentArray(i) & " is not a valid input."
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End Select
Else
Select Case strFlag
Case "/d"
strDeviceName = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case "/s"
strServer = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case "/o"
strOutputFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case "/u"
strUserName = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case "/w"
strPassword = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case else
Print "Invalid flag " & """" & strFlag & ":""" & "."
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End Select
End If
Next
intParseCmdLine = CONST_PROCEED
If strDeviceCommand <> "list" And strDeviceName = "" Then
Print "You must enter a device name to start or stop a device!"
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End If
End Function
'********************************************************************
'*
'* Sub ShowUsage()
'* Purpose: Shows the correct usage to the user.
'* Input: None
'* Output: Help messages are displayed on screen.
'*
'********************************************************************
Private Sub ShowUsage()
Wscript.Echo ""
Wscript.Echo "Controls devices on a machine." & vbCRLF
Wscript.Echo "DEVICE.VBS [/LIST | /START | /STOP] [/D:devicename] [/S:server]"
Wscript.Echo "[/O:outputfile] [/U:username] [/W:password] [/Q]"
Wscript.Echo " /D, /S, /O, /U, /W"
Wscript.Echo " Parameter specifiers."
Wscript.Echo " /LIST Lists all devices available."
Wscript.Echo " /START Starts a device."
Wscript.Echo " /STOP Stops a device from running."
Wscript.Echo " devicename The name of a device to be started or stopped."
Wscript.Echo " server A machine name."
Wscript.Echo " outputfile The output file name."
Wscript.Echo " username The current user's name."
Wscript.Echo " password <PASSWORD>."
Wscript.Echo " /Q Suppresses all output messages." & vbCRLF
Wscript.Echo "EXAMPLE:"
Wscript.Echo "DEVICE.VBS /stop /D:beep /S:MyMachine2"
Wscript.Echo " stops the beep device on MyMachine2."
End Sub
'********************************************************************
'*
'* Sub Device()
'* Purpose: Controls devices on a machine.
'* Input: strDeviceName a device name
'* strDeviceCommand one of List, Start, Stop
'* strServer a machine name
'* strOutputFile an output file name
'* strUserName the current user's name
'* strPassword <PASSWORD>
'* Output: Results are printed on screen or saved to file strOutputFile.
'*
'********************************************************************
Private Sub Device(strDeviceName, strDeviceCommand, strServer, _
strOutputFile, strUserName, strPassword)
ON ERROR RESUME NEXT
Dim objFileSystem, objOutputFile, objDevice, strWBEMPath
If strOutputFile = "" Then
objOutputFile = ""
Else
'Create a file object
set objFileSystem = CreateObject("Scripting.FileSystemObject")
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " opening a filesystem object."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Exit Sub
End If
'Open the file for output
set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, 8, True)
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " opening file " & strOutputFile
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Exit Sub
End If
End If
'Establish a connection with the server.
If blnConnect(objDevice, strServer, "root\cimv2", strUserName, strPassword) Then
Exit Sub
End If
'Now execute the method.
If strServer = "" Then
strWBEMPath = "Win32_SystemDriver.Name=""" _
& strDeviceName & """"
Else
strWBEMPath = "\\" & strServer & "\root\cimv2:Win32_SystemDriver.Name=""" _
& strDeviceName & """"
End If
Call ExecuteMethod(objDevice, objOutputFile, strDeviceCommand, strWBEMPath)
If strOutputFile <> "" Then
objOutputFile.Close
If intResult > 0 Then
Wscript.echo "Results are saved in file " & strOutputFile & "."
End If
End If
End Sub
'********************************************************************
'*
'* Function blnConnect()
'* Purpose: Connects to machine strServer.
'* Input: strServer a machine name
'* strNameSpace a namespace
'* strUserName name of the current user
'* strPassword password of the current user
'* Output: objService is returned as a service object.
'*
'********************************************************************
Private Function blnConnect(objService, strServer, strNameSpace, strUserName, strPassword)
ON ERROR RESUME NEXT
Dim objLocator
blnConnect = False 'There is no error.
' Create Locator object to connect to remote CIM object manager
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in creating a locator object."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
blnConnect = True 'An error occurred
Exit Function
End If
' Connect to the namespace which is either local or remote
Set objService = objLocator.ConnectServer (strServer, strNameSpace, _
strUserName, strPassword)
ObjService.Security_.impersonationlevel = 3
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in connecting to server " _
& strServer & "."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
blnConnect = True 'An error occurred
End If
End Function
'********************************************************************
'*
'* Sub ExecMethod()
'* Purpose: Executes a method.
'* Input: objDevice a device object
'* objOutputFile an output file object
'* strDeviceCommand one of List, Start, Stop
'* strWBEMPath path to a WBEM Win32_SystemDriver object
'* Output: Results are printed on screen or saved to file objOutputFile.
'*
'********************************************************************
Private Sub ExecuteMethod(objDevice, objOutputFile, strDeviceCommand, strWBEMPath)
ON ERROR RESUME NEXT
Dim intStatus, strMessage
Dim objEnumerator, objInstance
ReDim strName(0), strDisplayName(0),strState(0), intOrder(0)
strMessage = ""
strName(0) = ""
strDisplayName(0) = ""
strState(0) = ""
intOrder(0) = 0
Select Case LCase(strDeviceCommand)
Case "start"
Set objInstance = objDevice.Get(strWBEMPath)
If Err.Number Then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in getting device " _
& strWBEMPath & "."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
Exit Sub
End If
If objInstance is nothing Then
Exit Sub
End If
intStatus = objInstance.StartService()
If intStatus = 0 Then
strMessage = "Succeeded in starting device " & strWBEMPath & "."
Else
strMessage = "Failed to start device " & strWBEMPath & "."
End If
WriteLine strMessage, objOutputFile
Case "stop"
Set objInstance = objDevice.Get(strWBEMPath)
If Err.Number Then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in getting device " _
& strWBEMPath & "."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
Exit Sub
End If
If objInstance is nothing Then
Exit Sub
End If
intStatus = objInstance.StopService()
If intStatus = 0 and Err.Number = 0 Then
strMessage = "Succeeded in stopping device " & strWBEMPath & "."
Else
strMessage = "Failed to stop device " & strWBEMPath & "."
End If
WriteLine strMessage, objOutputFile
Case "list"
Set objEnumerator = objDevice.ExecQuery(_
"Select Name,DisplayName,State From Win32_SystemDriver")
If Err.Number Then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
Exit Sub
End If
i = 0
For Each objInstance in objEnumerator
If objInstance is nothing Then
Exit Sub
Else
ReDim Preserve strName(i), strDisplayName(i), strState(i), intOrder(i)
strName(i) = objInstance.Name
strDisplayName(i) = objInstance.DisplayName
strState(i) = objInstance.State
intOrder(i) = i
If IsNull(strState(i)) Then
strState(i) = ""
End If
i = i + 1
End If
If Err.Number Then
Err.Clear
End If
Next
If i > 0 Then
'Sort strName() and arrange intOrder()
Call SortArray(strName, True, intOrder, 0)
'Arrange strState() and strDisplayName() accordingly
Call ReArrangeArray(strState, intOrder)
Call ReArrangeArray(strDisplayName, intOrder)
'Display the header
strMessage = Space(2) & strPackString("NAME", 15, 1, 0)
strMessage = strMessage & strPackString("STATE", 15, 1, 0)
strMessage = strMessage & strPackString("DISPLAYNAME", 15, 1, 0)
WriteLine strMessage & vbCRLF, objOutputFile
'Display all the devices
For i = 0 To UBound(strName)
strMessage = Space(2) & strPackString(strName(i), 15, 1, 0)
strMessage = strMessage & strPackString(strState(i), 15, 1, 0)
strMessage = strMessage & strPackString(strDisplayName(i), 15, 1, 0)
WriteLine strMessage, objOutputFile
Next
End If
Case Else
Print "Error occurred in passing parameters!"
End Select
End Sub
'********************************************************************
'*
'* Sub SortArray()
'* Purpose: Sorts an array and arrange another array accordingly.
'* Input: strArray the array to be sorted
'* blnOrder True for ascending and False for descending
'* strArray2 an array that has exactly the same number of elements as strArray
'* and will be reordered together with strArray
'* blnCase indicates whether the order is case sensitive
'* Output: The sorted arrays are returned in the original arrays.
'* Note: Repeating elements are not deleted.
'*
'********************************************************************
Private Sub SortArray(strArray, blnOrder, strArray2, blnCase)
ON ERROR RESUME NEXT
Dim i, j, intUbound
If IsArray(strArray) Then
intUbound = UBound(strArray)
Else
Print "Argument is not an array!"
Exit Sub
End If
blnOrder = CBool(blnOrder)
blnCase = CBool(blnCase)
If Err.Number Then
Print "Argument is not a boolean!"
Exit Sub
End If
i = 0
Do Until i > intUbound-1
j = i + 1
Do Until j > intUbound
If blnCase Then 'Case sensitive
If (strArray(i) > strArray(j)) and blnOrder Then
Swap strArray(i), strArray(j) 'swaps element i and j
Swap strArray2(i), strArray2(j)
ElseIf (strArray(i) < strArray(j)) and Not blnOrder Then
Swap strArray(i), strArray(j) 'swaps element i and j
Swap strArray2(i), strArray2(j)
ElseIf strArray(i) = strArray(j) Then
'Move element j to next to i
If j > i + 1 Then
Swap strArray(i+1), strArray(j)
Swap strArray2(i+1), strArray2(j)
End If
End If
Else
If (LCase(strArray(i)) > LCase(strArray(j))) and blnOrder Then
Swap strArray(i), strArray(j) 'swaps element i and j
Swap strArray2(i), strArray2(j)
ElseIf (LCase(strArray(i)) < LCase(strArray(j))) and Not blnOrder Then
Swap strArray(i), strArray(j) 'swaps element i and j
Swap strArray2(i), strArray2(j)
ElseIf LCase(strArray(i)) = LCase(strArray(j)) Then
'Move element j to next to i
If j > i + 1 Then
Swap strArray(i+1), strArray(j)
Swap strArray2(i+1), strArray2(j)
End If
End If
End If
j = j + 1
Loop
i = i + 1
Loop
End Sub
'********************************************************************
'*
'* Sub Swap()
'* Purpose: Exchanges values of two strings.
'* Input: strA a string
'* strB another string
'* Output: Values of strA and strB are exchanged.
'*
'********************************************************************
Private Sub Swap(ByRef strA, ByRef strB)
Dim strTemp
strTemp = strA
strA = strB
strB = strTemp
End Sub
'********************************************************************
'*
'* Sub ReArrangeArray()
'* Purpose: Rearranges one array according to order specified in another array.
'* Input: strArray the array to be rearranged
'* intOrder an integer array that specifies the order
'* Output: strArray is returned as rearranged
'*
'********************************************************************
Private Sub ReArrangeArray(strArray, intOrder)
ON ERROR RESUME NEXT
Dim intUBound, i, strTempArray()
If Not (IsArray(strArray) and IsArray(intOrder)) Then
Print "At least one of the arguments is not an array"
Exit Sub
End If
intUBound = UBound(strArray)
If intUBound <> UBound(intOrder) Then
Print "The upper bound of these two arrays do not match!"
Exit Sub
End If
ReDim strTempArray(intUBound)
For i = 0 To intUBound
strTempArray(i) = strArray(intOrder(i))
If Err.Number Then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in rearranging an array."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
Exit Sub
End If
Next
For i = 0 To intUBound
strArray(i) = strTempArray(i)
Next
End Sub
'********************************************************************
'*
'* Function strPackString()
'* Purpose: Attaches spaces to a string to increase the length to intLength.
'* Input: strString a string
'* intLength the intended length of the string
'* blnAfter specifies whether to add spaces after or before the string
'* blnTruncate specifies whether to truncate the string or not if
'* the string length is longer than intLength
'* Output: strPackString is returned as the packed string.
'*
'********************************************************************
Private Function strPackString(strString, ByVal intLength, blnAfter, blnTruncate)
ON ERROR RESUME NEXT
intLength = CInt(intLength)
blnAfter = CBool(blnAfter)
blnTruncate = CBool(blnTruncate)
If Err.Number Then
Print "Argument type is incorrect!"
Err.Clear
Wscript.Quit
End If
If IsNull(strString) Then
strPackString = Space(intLength)
Exit Function
End If
strString = CStr(strString)
If Err.Number Then
Print "Argument type is incorrect!"
Err.Clear
Wscript.Quit
End If
If intLength > Len(strString) Then
If blnAfter Then
strPackString = strString & Space(intLength-Len(strString))
Else
strPackString = Space(intLength-Len(strString)) & strString & " "
End If
Else
If blnTruncate Then
strPackString = Left(strString, intLength-1) & " "
Else
strPackString = strString & " "
End If
End If
End Function
'********************************************************************
'*
'* Sub WriteLine()
'* Purpose: Writes a text line either to a file or on screen.
'* Input: strMessage the string to print
'* objFile an output file object
'* Output: strMessage is either displayed on screen or written to a file.
'*
'********************************************************************
Sub WriteLine(ByRef strMessage, ByRef objFile)
If IsObject(objFile) then 'objFile should be a file object
objFile.WriteLine strMessage
Else
Wscript.Echo strMessage
End If
End Sub
'********************************************************************
'*
'* Sub Print()
'* Purpose: Prints a message on screen if blnQuiet = False.
'* Input: strMessage the string to print
'* Output: strMessage is printed on screen if blnQuiet = False.
'*
'********************************************************************
Sub Print(ByRef strMessage)
If Not blnQuiet then
Wscript.Echo strMessage
End If
End Sub
'********************************************************************
'* *
'* End of File *
'* *
'********************************************************************
'********************************************************************
'*
'* Procedures calling sequence: DEVICE.VBS
'*
'* intParseCmdLine
'* ShowUsage
'* Device
'* blnConnect
'* ExecuteMethod
'* SortArray
'* Swap
'* ReArrangeArray
'* strPackString
'* WriteLine
'*
'********************************************************************
'********************************************************************
'*
'* Sub Debug()
'* Purpose: Prints a debug message and the error condition.
'* Input: i an integer
'* strMessage a message string
'* Output: A message is printed on screen.
'*
'********************************************************************
Sub Debug(i, strMessage)
If Err.Number then
Wscript.echo "Error 0X" & Hex(Err.Number) & " occurred."
Wscript.echo "Error description " & i & " " & Err.Description
Wscript.echo strMessage
' Err.Clear
Else
Wscript.echo "No problem " & i
Wscript.echo strMessage
End If
End Sub
'********************************************************************
'*
'* Sub PrintArray()
'* Purpose: Prints all elements of an array on screen.
'* Input: strArray an array name
'* Output: All elements of the array are printed on screen.
'*
'********************************************************************
Sub PrintArray(strArray)
Dim i
For i = 0 To UBound(strArray)
Wscript.echo strArray(i)
Next
End Sub
|
<filename>admin/wmi/wbem/scripting/samples/general/classmeth.vbs
'***************************************************************************
'This script tests various "remote" methods on classes
'***************************************************************************
On Error Resume Next
Set DiskClass = GetObject("winmgmts:CIM_LogicalDisk")
'Subclasses enumeration
for each DiskSubclass in DiskClass.Subclasses_ ()
WScript.Echo "Subclass name:", DiskSubclass.Path_.Relpath
next
'Instance enumeration
DiskClass.Security_.ImpersonationLevel = 3
for each DiskSubclass in DiskClass.Instances_ (0)
WScript.Echo "Instance Path:", DiskSubclass.Path_.Relpath
next
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
|
<gh_stars>10-100
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "Inverse CAB Creation Utility"
ClientHeight = 3855
ClientLeft = 2685
ClientTop = 2190
ClientWidth = 6000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3855
ScaleWidth = 6000
Begin MSComctlLib.ProgressBar prgBar
Height = 240
Left = -675
TabIndex = 10
Top = 3375
Width = 6870
_ExtentX = 12118
_ExtentY = 423
_Version = 393216
Appearance = 1
End
Begin VB.TextBox txtLog
Height = 2100
Left = 0
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 9
Top = 1275
Width = 5985
End
Begin MSComctlLib.StatusBar stbProgress
Align = 2 'Align Bottom
Height = 240
Left = 0
TabIndex = 8
Top = 3615
Width = 6000
_ExtentX = 10583
_ExtentY = 423
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton cmdSave
Caption = "..."
Height = 255
Left = 5520
TabIndex = 5
Top = 480
Width = 420
End
Begin VB.TextBox txtSaveCab
Height = 285
Left = 1200
TabIndex = 4
Top = 480
Width = 4260
End
Begin MSComDlg.CommonDialog dlg
Left = 3540
Top = 690
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdBrowse
Caption = "..."
Height = 255
Left = 5520
TabIndex = 2
Top = 120
Width = 420
End
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 375
Left = 5100
TabIndex = 7
Top = 810
Width = 855
End
Begin VB.CommandButton cmdGo
Caption = "&OK"
Height = 375
Left = 4140
TabIndex = 6
Top = 810
Width = 855
End
Begin VB.TextBox txtCabFile
Height = 285
Left = 1200
TabIndex = 1
Top = 120
Width = 4260
End
Begin VB.Label Label2
Caption = "Output CAB:"
Height = 255
Left = 120
TabIndex = 3
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "Input CAB:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 975
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' Utility Stuff, all this could go to a COM Object and be distributed
' like this.
Private m_WsShell As IWshShell ' Used to Shell and Wait for Sub-Processes
Private m_fso As Scripting.FileSystemObject ' For filesystem operations
Private Sub Form_Initialize()
Set m_WsShell = CreateObject("Wscript.Shell")
Set m_fso = New Scripting.FileSystemObject
End Sub
Private Sub Form_Load()
WriteLog App.EXEName & " Inverse CAB Creation Utility", False
WriteLog String$(40, "="), False
cmdGo.Default = True
cmdClose.Cancel = True
If (Len(Trim$(Command$)) > 0) Then
Me.txtCabFile = Command$
Me.txtCabFile.Enabled = False
Me.cmdBrowse.Enabled = False
Me.cmdGo.Enabled = False
Me.Show Modal:=False
cmdGo_Click
cmdClose_Click
End If
End Sub
Function Cab2Folder(ByVal strCabFile As String)
Cab2Folder = ""
' We grab a Temporary Filename and create a folder out of it
Dim strFolder As String
strFolder = m_fso.GetSpecialFolder(TemporaryFolder) + "\" + m_fso.GetTempName
m_fso.CreateFolder strFolder
' We uncab CAB contents into the Source CAB Contents dir.
Dim strCmd As String
strCmd = "cabarc X " + strCabFile + " " + strFolder + "\"
m_WsShell.Run strCmd, True, True
Cab2Folder = strFolder
End Function
Sub Folder2Cab( _
ByVal strFolder As String, _
ByVal strCabFile As String _
)
' We recab using the Destination directory contents
' cabarc -s 6144 N ..\algo.cab *.*
If (m_fso.FileExists(strCabFile)) Then
m_fso.DeleteFile strCabFile, force:=True
End If
Dim strCmd As String
strCmd = "cabarc -s 6144 N " + strCabFile + " " + strFolder + "\*.*"
m_WsShell.Run strCmd, True, True
End Sub
Sub WriteLog(strMsg As String, Optional ByVal bWriteToStatusBar As Boolean = True)
With Me
.txtLog = .txtLog & vbCrLf & strMsg
If (bWriteToStatusBar) Then
.stbProgress.SimpleText = strMsg
End If
End With
DoEvents
End Sub
' ============ END UTILITY STUFF ========================
' ============ BoilerPlate Form Code
Private Sub cmdBrowse_Click()
dlg.Filter = "All Files (*.*)|*.*|Cab Files (*.cab)|*.cab"
dlg.FilterIndex = 2
dlg.ShowOpen
If (Len(dlg.FileName) > 0) Then
Me.txtCabFile = dlg.FileName
End If
End Sub
Private Sub cmdSave_Click()
dlg.Filter = "All Files (*.*)|*.*|Cab Files (*.cab)|*.cab"
dlg.FilterIndex = 2
dlg.ShowSave
If (Len(dlg.FileName) > 0) Then
Me.txtSaveCab = dlg.FileName
End If
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdGo_Click()
Me.txtCabFile.Text = Trim$(Me.txtCabFile.Text)
Me.txtSaveCab.Text = Trim$(Me.txtSaveCab.Text)
If (Len(Me.txtCabFile.Text) > 0) Then
FixCab Me.txtCabFile.Text, Me.txtSaveCab.Text
End If
End Sub
Sub FixCab(ByVal strCabFile As String, ByVal strSaveCab As String)
Dim strErrMsg As String: strErrMsg = ""
If (Not m_fso.FileExists(strCabFile)) Then
MsgBox "Cannot find " & strCabFile
GoTo Common_Exit
End If
Dim strCabFolder As String
prgBar.Visible = True
WriteLog "Uncabbing " & strCabFile
strCabFolder = Cab2Folder(strCabFile)
WriteLog "Applying Fixes "
If (FixPerSe(strCabFolder)) Then
WriteLog "Recabbing " & strCabFile
Folder2Cab strCabFolder, strSaveCab
Else
MsgBox "Error: Fix Failed", Title:=App.EXEName
End If
' Now we delete the Temporary Folders
WriteLog "Deleting Temporary Files"
m_fso.DeleteFolder strCabFolder, force:=True
Common_Exit:
WriteLog "Done" + IIf(Len(strErrMsg) > 0, " - " + strErrMsg, "")
prgBar.Visible = False
End Sub
' ========================================================
' ============= End BoilerPlate Form Code ================
' ========================================================
Function FixPerSe(ByVal strCabFolder As String) As Boolean
FixPerSe = False
' Now we parse Package_Description.xml to find the HHT Files
Dim oElem As IXMLDOMElement ' Used for all element Creation
Dim oDomPkg As DOMDocument: Set oDomPkg = New DOMDocument
Dim strPkgFile As String: strPkgFile = strCabFolder + "\package_description.xml"
oDomPkg.async = False
oDomPkg.Load strPkgFile
If (oDomPkg.parseError <> 0) Then
p_DisplayParseError oDomPkg.parseError
GoTo Common_Exit
End If
' Let's check whether this fix was applied
Dim oFixNode As IXMLDOMNode
Set oFixNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/package_fixes/fix[@id='2']")
If (Not oFixNode Is Nothing) Then GoTo Common_Exit
' now, if it is the first time we run we have to create the Package_fixes
' NODE.
If (oDomPkg.selectSingleNode("HELPCENTERPACKAGE/package_fixes") Is Nothing) Then
Set oElem = oDomPkg.createElement("package_fixes")
oDomPkg.selectSingleNode("HELPCENTERPACKAGE").appendChild oElem
End If
' We record the fact that this fix was already applied
Set oElem = oDomPkg.createElement("fix")
oDomPkg.selectSingleNode("HELPCENTERPACKAGE/package_fixes").appendChild oElem
oElem.setAttribute "id", "2"
oElem.setAttribute "description", "Inverse CAB"
Dim lTaxoInEntries As Long: lTaxoInEntries = 0
Dim oMetadataNode As IXMLDOMNode
Set oMetadataNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/METADATA")
Dim oDOMNode As IXMLDOMNode
Dim oDomHhtNode As IXMLDOMNode
For Each oDomHhtNode In oMetadataNode.selectNodes("HHT")
Dim strHhtFile As String
strHhtFile = oDomHhtNode.Attributes.getNamedItem("FILE").Text
' Let's load the HHT
Dim oDomHht As DOMDocument: Set oDomHht = New DOMDocument
oDomHht.async = False
oDomHht.Load strCabFolder + "\" + strHhtFile
If (oDomHht.parseError <> 0) Then
p_DisplayParseError oDomHht.parseError
GoTo Common_Exit
End If
lTaxoInEntries = lTaxoInEntries + oDomHht.selectNodes("//*[ @ACTION ]").length
WriteLog m_fso.GetBaseName(strHhtFile) & _
" has " & lTaxoInEntries & " entries with ACTION Attribute", False
prgBar.Max = lTaxoInEntries
prgBar.Value = 1
Set oDOMNode = oDomHht.selectSingleNode("METADATA/TAXONOMY_ENTRIES")
p_ReverseTaxonomy oDOMNode
Set oDOMNode = oDomHht.selectSingleNode("METADATA/STOPSIGN_ENTRIES")
p_ReverseOther oDOMNode
Set oDOMNode = oDomHht.selectSingleNode("METADATA/STOPWORD_ENTRIES")
p_ReverseOther oDOMNode
Set oDOMNode = oDomHht.selectSingleNode("METADATA/OPERATOR_ENTRIES")
p_ReverseOther oDOMNode
Set oDOMNode = oDomHht.selectSingleNode("METADATA/HELPIMAGE")
p_ReverseOther oDOMNode
Set oDOMNode = oDomHht.selectSingleNode("METADATA/INDEX")
p_ReverseOther oDOMNode
oDomHht.Save strCabFolder + "\" + strHhtFile
Next
Dim lPkgInEntries As Long: lPkgInEntries = 0
lPkgInEntries = lPkgInEntries + oDomPkg.selectNodes("//*[ @ACTION ]").length
WriteLog m_fso.GetBaseName(strPkgFile) & _
" has " & lPkgInEntries & " entries with ACTION Attribute", False
If (lPkgInEntries > 0) Then
prgBar.Max = lPkgInEntries
prgBar.Value = 1
Set oDOMNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/SEARCHENGINES")
p_ReverseOther oDOMNode
Set oDOMNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/CONFIG")
p_ReverseOther oDOMNode
Set oDOMNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/INSTALL_CONTENT")
p_ReverseOther oDOMNode
Set oDOMNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/TRUSTED_CONTENT")
p_ReverseOther oDOMNode
End If
oDomPkg.Save strCabFolder + "\" + "\package_description.xml"
FixPerSe = True
Common_Exit:
Exit Function
End Function
Private Sub p_ReverseTaxonomy( _
ByRef u_DOMNode As IXMLDOMNode _
)
If (u_DOMNode Is Nothing) Then GoTo Common_Exit
Dim u_DOMNodeCopy As IXMLDOMNode
Set u_DOMNodeCopy = u_DOMNode.cloneNode(deep:=True)
WriteLog "Reversing " & u_DOMNode.nodeName & _
" with " & u_DOMNode.childNodes.length & " entries"
Dim oTaxoEntry As IXMLDOMNode
For Each oTaxoEntry In u_DOMNode.childNodes
u_DOMNode.removeChild oTaxoEntry
Next
Dim lEnd As Long: lEnd = u_DOMNodeCopy.childNodes.length - 1
Do While lEnd >= 0
Set oTaxoEntry = u_DOMNodeCopy.childNodes.Item(lEnd)
p_FlipAddDel oTaxoEntry
u_DOMNodeCopy.removeChild oTaxoEntry
u_DOMNode.appendChild oTaxoEntry
Set oTaxoEntry = Nothing
lEnd = lEnd - 1
Loop
Set u_DOMNodeCopy = Nothing
Common_Exit:
End Sub
Private Sub p_ReverseOther( _
ByRef u_DOMNode As IXMLDOMNode _
)
If (u_DOMNode Is Nothing) Then GoTo Common_Exit
Dim oTaxoEntry As IXMLDOMNode
WriteLog "Reversing " & u_DOMNode.nodeName & _
" with " & u_DOMNode.childNodes.length & " entries"
For Each oTaxoEntry In u_DOMNode.childNodes
p_FlipAddDel oTaxoEntry
Next
Common_Exit:
End Sub
Private Sub p_FlipAddDel( _
ByRef oNodeEntry As IXMLDOMNode _
)
Dim oAttribAction As IXMLDOMAttribute
Set oAttribAction = oNodeEntry.Attributes.getNamedItem("ACTION")
If (oAttribAction Is Nothing) Then
Dim oElemEntryWithNoAction As IXMLDOMElement
Set oElemEntryWithNoAction = oNodeEntry
' If there is no ACTION, then HelpSvc.exe assumes that
' ACTION=ADD, so we need to generate an ACTION = DEL
oElemEntryWithNoAction.setAttribute "ACTION", "DEL"
Else
With oAttribAction
Select Case .Value
Case "ADD", ""
.Value = "DEL"
Case Else
.Value = "ADD"
End Select
End With
prgBar.Value = prgBar.Value + 1
End If
End Sub
Public Sub p_DisplayParseError( _
ByRef i_ParseError As IXMLDOMParseError _
)
Dim strError As String
strError = "Error: " & i_ParseError.reason & _
"Line: " & i_ParseError.Line & vbCrLf & _
"Linepos: " & i_ParseError.linepos & vbCrLf & _
"srcText: " & i_ParseError.srcText
MsgBox strError, vbOKOnly, "Error while parsing"
End Sub
|
Public Function StrRepeat(s As String, n As Integer) As String
Dim r As String, i As Integer
r = ""
For i = 1 To n
r = r & s
Next i
StrRepeat = r
End Function
Debug.Print StrRepeat("ha", 5)
|
<gh_stars>10-100
'***************************************************************************
'This script tests the manipulation of qualifier values, in the case that the
'qualifier is a not an array type
'***************************************************************************
Set Service = GetObject("winmgmts:root/default")
On Error Resume Next
Set aClass = Service.Get()
aClass.Path_.Class = "SIMPLEQUALTEST00"
aClass.Qualifiers_.Add "q1", 327, true, false, false
WScript.Echo "The initial value of q1 is [327]:", aClass.Qualifiers_("q1")
'Verify we can report the qualifier value
v = aClass.Qualifiers_("q1")
WScript.Echo "By indirection q1 has value [327]:",v
'Verify we can report the value directly
WScript.Echo "By direct access q1 has value [327]:", aClass.Qualifiers_("q1")
'Verify we can set the value of a single qualifier value element
aClass.Qualifiers_("q1") = 234
WScript.Echo "After direct assignment q1 has value [234]:", aClass.Qualifiers_("q1")
aClass.Put_ ()
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
|
Sub Main()
Debug.Print Is_Numeric("")
Debug.Print Is_Numeric("-5.32")
Debug.Print Is_Numeric("-51,321 32")
Debug.Print Is_Numeric("123.4")
Debug.Print Is_Numeric("123,4")
Debug.Print Is_Numeric("123;4")
Debug.Print Is_Numeric("123.4x")
End Sub
Private Function Is_Numeric(s As String) As Boolean
Dim Separat As String, Other As String
Separat = Application.DecimalSeparator
Other = IIf(Separat = ",", ".", ",")
Is_Numeric = IsNumeric(Replace(s, Other, Separat))
End Function
|
on error resume next
Set objISWbemPropertySet = GetObject("winmgmts:{impersonationLevel=impersonate}!root/cimv2:Win32_LogicalDisk=""C:""").Properties_
for each property in objISWbemPropertySet
WScript.Echo property.Name
next
if err <> 0 then
WScript.Echo "Error"
else
Wscript.Echo "OK"
end if
|
<gh_stars>1-10
'this enumerates from 0
Enum fruits
apple
banana
cherry
End Enum
'here we use our own enumeration
Enum fruits2
pear = 5
mango = 10
kiwi = 20
pineapple = 20
End Enum
Sub test()
Dim f As fruits
f = apple
Debug.Print "apple equals "; f
Debug.Print "kiwi equals "; kiwi
Debug.Print "cherry plus kiwi plus pineapple equals "; cherry + kiwi + pineapple
End Sub
|
<gh_stars>10-100
'***************************************************************************
'This script tests array out-of-bounds conditions on properties and
'qualifiers
'***************************************************************************
On Error Resume Next
while true
Set Service = GetObject("winmgmts:root/default")
Set Class = Service.Get()
Class.Path_.Class = "ARRAYPROP00"
Set Property = Class.Properties_.Add ("p1", 19, true)
Property.Value = Array (12, 787, 34124)
Set Qualifier = Property.Qualifiers_.Add("wibble", Array ("fred", "the", "hamster"))
'************************************************************
' PROPERTY
'************************************************************
'Out-of-bounds read
WScript.Echo Class.Properties_("p1")(3)
if Err <> 0 Then
WScript.Echo "As expected got read OOB:", Err.Description
Err.Clear
End if
'Out-of-bounds write ; should expand the array
Class.Properties_("p1")(3) = 783837
if Err <> 0 Then
WScript.Echo "ERROR:", Err.Description
Err.Clear
End if
'Now read should be in bounds
WScript.Echo "Value of ARRAYPROP00.Class.p1(3) is [783837]:", Class.Properties_("p1")(3)
'Out-of-bounds write ; should expand the array
Class.p1(4) = 783844
if Err <> 0 Then
WScript.Echo "ERROR:", Err.Description
Err.Clear
End if
'Now read should be in bounds
WScript.Echo "Value of ARRAYPROP00.Class.p1(4) is [783844]:", Class.p1(4)
if Err <> 0 Then
WScript.Echo "ERROR:", Err.Description
Err.Clear
End if
'************************************************************
' QUALIFIER
'************************************************************
'Out-of-bounds read
WScript.Echo Property.Qualifiers_("wibble")(3)
if Err <> 0 Then
WScript.Echo "As expected got read OOB:", Err.Description
Err.Clear
End if
'Out-of-bounds write ; should expand the array
Property.Qualifiers_("wibble")(3) = "jam"
if Err <> 0 Then
WScript.Echo "ERROR:", Err.Description
Err.Clear
End if
'Now read should be in bounds
WScript.Echo "Value of qualifier(3) is [jam]:", Property.Qualifiers_("wibble")(3)
if Err <> 0 Then
WScript.Echo "ERROR:", Err.Description
Err.Clear
End if
wend
|
<filename>base/cluster/admin/msclus/vbtest/module1.bas
Attribute VB_Name = "Module1"
Option Explicit
Sub ListTheClusters(oClusterApp As MSClusterLib.Application, ClusTree As TreeView)
Dim oClusters As Clusters
Set oClusters = oClusterApp.Clusters
Dim nCount As Integer
nCount = oClusters.Count
Dim i As Integer
Dim ChildNode As Node
ClusTree.Nodes.Add , , "Clusters", "Clusters"
For i = 1 To nCount
Set ChildNode = ClusTree.Nodes.Add("Clusters", tvwChild, oClusters(i), oClusters(i))
ChildNode.Tag = "Cluster"
Next i
End Sub
Sub ListTheNodes(oCluster As Cluster, ClusTree As TreeView)
Dim s As String
Dim oNodes As ClusNodes
Set oNodes = oCluster.Nodes
Dim nCount As Integer
nCount = oNodes.Count
Debug.Print nCount & " nodes"
Dim oNode As ClusNode
Dim i As Integer
Dim ChildNode As Node
Dim RootNode As Node
Set RootNode = ClusTree.Nodes.Add(, , "Nodes", oCluster.Name)
For i = 1 To nCount
Set oNode = oNodes(i)
s = oNode.Name & "(" & oNode.NodeID & ")"
Set ChildNode = ClusTree.Nodes.Add("Nodes", tvwChild, oNode.Name, s)
ChildNode.Tag = "Node"
ListTheResourceGroups oNode, ClusTree, oNode.Name
Set oNode = Nothing
Next
End Sub
Sub ListTheResourceGroups(oNode As ClusNode, ClusTree As TreeView, Key As String)
Dim oResourceGroups As ClusResGroups
Set oResourceGroups = oNode.ResourceGroups
Dim nCount As Integer
nCount = oResourceGroups.Count
Debug.Print nCount & " resource groups"
Dim oResourceGroup As ClusResGroup
Dim i As Integer
Dim ChildNode As Node
For i = 1 To nCount
Set oResourceGroup = oResourceGroups(i)
Set ChildNode = ClusTree.Nodes.Add(Key, tvwChild, oResourceGroup.Name, oResourceGroup.Name)
ChildNode.Tag = "Group"
ListTheResources oResourceGroup, ClusTree, oResourceGroup.Name
Set oResourceGroup = Nothing
Next
End Sub
Sub ListTheResources(oGroup As ClusResGroup, ClusTree As TreeView, Key As String)
Dim oResources As ClusResources
Set oResources = oGroup.Resources
Dim oResource As ClusResource
Dim i As Integer
Dim nCount As Integer
nCount = oResources.Count
Dim ChildNode As Node
For i = 1 To nCount
Set oResource = oResources(i)
Set ChildNode = ClusTree.Nodes.Add(Key, tvwChild, oResource.Name, oResource.Name)
ChildNode.Tag = "Resource"
Set oResource = Nothing
Next
End Sub
Sub ListTheResourceTypes(oCluster As Cluster, ClusTree As TreeView)
Dim oResourceTypes As ClusResTypes
Set oResourceTypes = oCluster.ResourceTypes
Dim oResourceType As ClusResType
Dim i As Integer
Dim nCount As Integer
nCount = oResourceTypes.Count
ClusTree.Nodes.Add , tvwChild, "Types", "Resource Types"
Dim ChildNode As Node
For i = 1 To nCount
Set oResourceType = oResourceTypes(i)
Set ChildNode = ClusTree.Nodes.Add("Types", tvwChild, , oResourceType.Name)
ChildNode.Tag = "Type"
Set oResourceType = Nothing
Next
End Sub
Sub ListProperties(oProps As ClusProperties, lstView As ListView)
Dim i As Integer
Dim nCount As Integer
Dim oProp As ClusProperty
nCount = oProps.Count
lstView.ListItems.Clear
Dim lstItem As ListItem
For i = 1 To nCount
Set oProp = oProps(i)
Set lstItem = lstView.ListItems.Add(i, , oProp.Name)
lstItem.SubItems(1) = oProp.Value
Set oProp = Nothing
Next
End Sub
|
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3510
ClientLeft = 60
ClientTop = 345
ClientWidth = 4785
LinkTopic = "Form1"
ScaleHeight = 3510
ScaleWidth = 4785
StartUpPosition = 3 'Windows Default
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 495
Left = 120
TabIndex = 8
Top = 2880
Width = 4455
_ExtentX = 7858
_ExtentY = 873
_Version = 393216
Appearance = 1
End
Begin VB.TextBox TextJobID
Height = 285
Left = 2175
TabIndex = 0
Top = 120
Width = 2415
End
Begin VB.TextBox TextProviderID
Height = 285
Left = 2160
TabIndex = 2
Top = 600
Width = 2415
End
Begin VB.TextBox TextFileName
Height = 285
Left = 2160
TabIndex = 4
Top = 1080
Width = 2415
End
Begin VB.CommandButton CommandTransfer
Caption = "Transfer"
Height = 495
Left = 120
TabIndex = 6
Top = 1560
Width = 4455
End
Begin VB.Label LabelStatus
Height = 495
Left = 120
TabIndex = 7
Top = 2160
Width = 4455
End
Begin VB.Label LabelJobID
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "JobID"
Height = 195
Left = 1650
TabIndex = 1
Top = 165
Width = 420
End
Begin VB.Label LabelProviderID
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "ProviderID"
Height = 195
Left = 1305
TabIndex = 3
Top = 645
Width = 750
End
Begin VB.Label LabelFileName
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "FileName"
Height = 255
Left = 1320
TabIndex = 5
Top = 1095
Width = 735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private obj As MPCUpload
Private WithEvents job As UPLOADMANAGERLib.MPCUploadJob
Attribute job.VB_VarHelpID = -1
Private Sub CommandTransfer_Click()
Set job = obj.CreateJob
job.Sig = "{A4E4318A-028E-11d3-9397-00C04F72DAF7}"
job.Server = "http://pchealth_srv1/upload/uploadserver.dll"
job.JobID = Form1.TextJobID
job.ProviderID = Form1.TextProviderID
job.GetDataFromFile Form1.TextFileName
job.Mode = UL_FOREGROUND
job.PersistToDisk = True
job.History = UL_HISTORY_LOG_AND_DATA
Call job.ActivateAsync
End Sub
Private Sub Form_Load()
Set obj = CreateObject("UploadManager.MPCUpload")
End Sub
Private Sub job_onStatusChange(ByVal mpcujJob As UPLOADMANAGERLib.IMPCUploadJob, ByVal Status As UPLOADMANAGERLib.tagUL_STATUS)
Dim str As String
If (Status = UL_NOTACTIVE) Then str = "UL_NOTACTIVE"
If (Status = UL_ACTIVE) Then str = "UL_ACTIVE"
If (Status = UL_TRANSMITTING) Then str = "UL_TRANSMITTING"
If (Status = UL_SUSPENDED) Then str = "UL_SUSPENDED"
If (Status = UL_ABORTED) Then str = "UL_ABORTED"
If (Status = UL_FAILED) Then str = "UL_FAILED"
If (Status = UL_DELETED) Then str = "UL_DELETED"
If (Status = UL_COMPLETED) Then str = "UL_COMPLETED"
Form1.LabelStatus = str
End Sub
Private Sub job_onProgressChange(ByVal mpcujJob As UPLOADMANAGERLib.IMPCUploadJob, ByVal lCurrentSize As Long, ByVal lTotalSize As Long)
ProgressBar1.Value = CDbl(lCurrentSize) / CDbl(lTotalSize) * 100
End Sub
|
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmUnimodemId
BorderStyle = 0 'None
Caption = "Unimodem ID"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 9480
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 5730
ScaleWidth = 9480
ShowInTaskbar = 0 'False
Begin VB.TextBox Text1
Height = 285
Left = 0
Locked = -1 'True
TabIndex = 1
Top = 0
Width = 9495
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 0
Top = 5430
Width = 9480
_ExtentX = 16722
_ExtentY = 529
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 3
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 13070
TextSave = ""
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "9/25/98"
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "12:35 PM"
Key = ""
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin TabDlg.SSTab SSTab1
Height = 5055
Left = 0
TabIndex = 2
TabStop = 0 'False
Top = 360
Width = 9405
_ExtentX = 16589
_ExtentY = 8916
_Version = 393216
Tabs = 1
TabsPerRow = 8
TabHeight = 794
ShowFocusRect = 0 'False
TabCaption(0) = "UnimodemID"
TabPicture(0) = "frmUnimodemId.frx":0000
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label2"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "ProgressBar1"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Combo1"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Command1"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).ControlCount= 4
Begin VB.CommandButton Command1
Caption = "&Generate ID"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2160
TabIndex = 4
Top = 720
Width = 1215
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
ItemData = "frmUnimodemId.frx":001C
Left = 240
List = "frmUnimodemId.frx":0080
Style = 2 'Dropdown List
TabIndex = 3
Top = 840
Width = 1695
End
Begin ComctlLib.ProgressBar ProgressBar1
Height = 255
Left = 240
TabIndex = 6
Top = 1320
Width = 3135
_ExtentX = 5530
_ExtentY = 450
_Version = 327682
Appearance = 1
Max = 14
End
Begin VB.Label Label2
Caption = "&Select port:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 5
Top = 600
Width = 1215
End
End
End
Attribute VB_Name = "frmUnimodemId"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Sub GetModemId Lib "modemid.dll" _
(ByVal lpszCommPort As String, ByVal lpszLogFile As String, _
ByVal dwBufferSize As Long, ByVal lpszIDBuffer As String, _
ByVal pfnCallback As Long)
Dim CommPort As String
Dim LogFile As String
Dim BufferSize As Long
Dim UnimodemID As String
Private Sub Command1_Click()
Command1.Enabled = False
Text1.Text = ""
StatusBar1.Panels(1).Text = "Querying modem."
CommPort = Combo1.Text
LogFile = "Idlog.txt"
BufferSize = 20
UnimodemID = Space(256)
Call GetModemId(ByVal CommPort, ByVal LogFile, ByVal BufferSize, _
ByVal UnimodemID, AddressOf ModemCallback)
Text1.Text = UnimodemID
StatusBar1.Panels(1).Text = "Finished."
SBCount = 0
ProgressBar1.Value = ProgressBar1.Min
Command1.Enabled = True
End Sub
Private Sub Form_Load()
SBCount = 0
ProgressBar1.Value = ProgressBar1.Min
Combo1.Text = "Com1"
StatusBar1.Panels(1).Text = "Select a com port and click the Generate button."
End Sub
Public Sub ClearControl()
Text1.Text = ""
End Sub
Public Sub EditCopy()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
Clipboard.Clear
Clipboard.SetText Text1.Text
End Sub
Public Sub EditPaste()
End Sub
Private Sub Form_Resize()
Text1.Width = frmUnimodemId.Width
SSTab1.Width = frmUnimodemId.Width - 75
SSTab1.Height = frmUnimodemId.Height - 675
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
dim i
i = 43
Assert i=42, "There's got to be more to life than this!"
|
<filename>Task/Stern-Brocot-sequence/VBScript/stern-brocot-sequence.vb
sb = Array(1,1)
i = 1 'considered
j = 2 'precedent
n = 0 'loop counter
Do
ReDim Preserve sb(UBound(sb) + 1)
sb(UBound(sb)) = sb(UBound(sb) - i) + sb(UBound(sb) - j)
ReDim Preserve sb(UBound(sb) + 1)
sb(UBound(sb)) = sb(UBound(sb) - j)
i = i + 1
j = j + 1
n = n + 1
Loop Until n = 2000
WScript.Echo "First 15: " & DisplayElements(15)
For k = 1 To 10
WScript.Echo "The first instance of " & k & " is in #" & ShowFirstInstance(k) & "."
Next
WScript.Echo "The first instance of " & 100 & " is in #" & ShowFirstInstance(100) & "."
Function DisplayElements(n)
For i = 0 To n - 1
If i < n - 1 Then
DisplayElements = DisplayElements & sb(i) & ", "
Else
DisplayElements = DisplayElements & sb(i)
End If
Next
End Function
Function ShowFirstInstance(n)
For i = 0 To UBound(sb)
If sb(i) = n Then
ShowFirstInstance = i + 1
Exit For
End If
Next
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Sorting-algorithms-Bubble-sort/VBScript/sorting-algorithms-bubble-sort-1.vb
sub decr( byref n )
n = n - 1
end sub
sub incr( byref n )
n = n + 1
end sub
sub swap( byref a, byref b)
dim tmp
tmp = a
a = b
b = tmp
end sub
function bubbleSort( a )
dim changed
dim itemCount
itemCount = ubound(a)
do
changed = false
decr itemCount
for i = 0 to itemCount
if a(i) > a(i+1) then
swap a(i), a(i+1)
changed = true
end if
next
loop until not changed
bubbleSort = a
end function
|
'Best Shuffle Task
'VBScript Implementation
Function bestshuffle(s)
Dim arr:Redim arr(Len(s)-1)
'The Following Does the toCharArray() Functionality
For i = 0 To Len(s)-1
arr(i) = Mid(s, i + 1, 1)
Next
arr = shuffler(arr) 'Make this line a comment for deterministic solution
For i = 0 To UBound(arr):Do
If arr(i) <> Mid(s, i + 1, 1) Then Exit Do
For j = 0 To UBound(arr)
If arr(i) <> arr(j) And arr(i) <> Mid(s, j + 1, 1) And arr(j) <> Mid(s, i + 1, 1) Then
tmp = arr(i)
arr(i) = arr(j)
arr(j) = tmp
End If
Next
Loop While False:Next
shuffled_word = Join(arr,"")
'This section is the scorer
score = 0
For k = 1 To Len(s)
If Mid(s,k,1) = Mid(shuffled_word,k,1) Then
score = score + 1
End If
Next
bestshuffle = shuffled_word & ",(" & score & ")"
End Function
Function shuffler(array)
Set rand = CreateObject("System.Random")
For i = UBound(array) to 0 Step -1
r = rand.next_2(0, i + 1)
tmp = array(i)
array(i) = array(r)
array(r) = tmp
Next
shuffler = array
End Function
'Testing the function
word_list = Array("abracadabra","seesaw","elk","grrrrrr","up","a")
For Each word In word_list
WScript.StdOut.WriteLine word & "," & bestshuffle(word)
Next
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
'////////////////////////////////////////////////////////////////////////////
'
' Copyright (c) 1999-2000 Microsoft Corp. All Rights Reserved.
'
' File name:
'
' lib.vbs
'
' Abstract:
'
' Windows Embedded Prototype Script for Printers
'
' Remarks:
'
' This file encapsulates dependency mapping functionality. When a target
' designer user adds a printer driver component, this script examines the
' resource in the printer driver component and maps it to another component.
' For example, if a driver uses pscript5.dll, it must be a postscript
' printer, and it shall have the dependency for core postscript driver
' component.
'
' In order to do this, we have the mapIt function. mapIt needs an array of
' booleans that indicate whether a component is mapped or not. It works this
' way, first the client should go through all the resources and populate the
' componentFlagArray and then it should add the dependencies according to
' this array. To do it this way we remove the duplicate dependencies and we
' decouple the logic of selecting mapped dependent components and the logic
' of adding dependencies.
'
' Right now we have only three components, aka Core PostScript, Core Unidrv,
' and Core Plotter. Eventually we going to expand it so that every section
' in ntprint.inf, such as section [CNBJ], should be a separate component and
' should be mapped in this script.
'
' Author:
'
' <NAME> (lzhu) 11-29-2000
'
'////////////////////////////////////////////////////////////////////////////
Option Explicit
' define a component type
Class ComponentType
Public nComponentID ' This is a zero based index and id
Public strComponentVIGUID ' VI GUID of this component
Public enumClass
Public enumType
Public enumMinRevision
End Class
' define a tuple that maps a file to a component
Class PrinterFilesMappingTuple
Public strFileName
Public nComponentID
End Class
'//////////////////////////////////////////////////////////////////////////////////
'
' define the tables to store the mapping relations
'
'/////////////////////////////////////////////////////////////////////////////////
' define the table of components
Public g_componentTuples()
ReDim g_componentTuples(10) ' No need to increase this number
Public g_nComponents: g_nComponents = 0 ' Num of components
' define the table of mappings
Public g_printerFilesMappingTuples()
ReDim g_printerFilesMappingTuples(20) ' No need to increase this number
Public g_nTableEntries: g_nTableEntries = 0 ' Num of table entries
' whether the tables above are initialized
Public g_bAreTablesInitialized: g_bAreTablesInitialized = False
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' addTuple
'
' Function description:
'
' This subroutine adds one mapping tuple at a time and updates the mapping
' table in g_printerFilesMappingTuples
'
' Arguments:
'
' strFileName -- the file to be mapped
' nComponent -- the component ID
'
'//////////////////////////////////////////////////////////////////////////////////
Sub addTuple(strFileName, nComponentID)
'
' ReDim is expensive, to avoid excessive redim we double the array size when
' the table is not large enough
'
If (UBound(g_printerFilesMappingTuples) < g_nTableEntries) Then
ReDim Preserve g_printerFilesMappingTuples(2*UBound(g_printerFilesMappingTuples))
End If
Set g_printerFilesMappingTuples(g_nTableEntries) = New PrinterFilesMappingTuple
g_printerFilesMappingTuples(g_nTableEntries).strFileName = strFileName
g_printerFilesMappingTuples(g_nTableEntries).nComponentID = nComponentID
g_nTableEntries = g_nTableEntries + 1
End Sub
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' addComponent
'
' Function description:
'
' This sub adds one component at a time to the component table
' g_componentTuples and it increments the number of component
' g_nComponents.
'
' Arguments:
'
' enumClass -- the component class
' enumType -- the component type
' strComponentVIGUID -- the VI GUID for the component
' enumMinRevision -- the minimum revision for the component
'
' Return value:
'
' The component ID for the component just added
'
'//////////////////////////////////////////////////////////////////////////////////
Function addComponent(enumClass, enumType, strComponentVIGUID, enumMinRevision)
Dim oneComponent: Set oneComponent = New ComponentType
oneComponent.nComponentID = g_nComponents
oneComponent.enumClass = enumClass
oneComponent.enumType = enumType
oneComponent.strComponentVIGUID = strComponentVIGUID
oneComponent.enumMinRevision = enumMinRevision
'
' add one more element into component table
'
'
' ReDim is expensive, to avoid excessive redim we double the array size
' when the table is not large enough
'
If (UBound(g_componentTuples) < g_nComponents) Then
ReDim Preserve g_componentTuples(2*UBound(g_componentTuples))
End If
Set g_componentTuples(g_nComponents) = oneComponent
g_nComponents = g_nComponents + 1
addComponent = oneComponent.nComponentID
End Function
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' InitializeTables
'
' Function description:
'
' This function initializes the tables of mapping tuples and the table of
' components which are stored in g_printerFilesMappingTuples and
' g_componentTuples respectively. It is safe to call this sub more than
' once.
'
' Arguments:
'
' None
'
'//////////////////////////////////////////////////////////////////////////////////
Sub InitializeTables()
' make sure this routine is executed only once
If g_bAreTablesInitialized Then Exit Sub
g_bAreTablesInitialized = True
Dim strComponentVIGUID, enumMinRevision
'////////////////////////////////////////////////////////////////////////////
'
' Printer Components
'
' Remark: This part needs to be manually updated
'
'////////////////////////////////////////////////////////////////////////////
' Core PostScript Component
Dim corePS_ID
strComponentVIGUID = "{C32DA828-9D90-4311-8FC5-AEFC65FAE2D3}"
enumMinRevision = 1
corePS_ID = addComponent(cmiInclude, cmiExactlyOne, strComponentVIGUID, enumMinRevision)
' Core Unidrv Component
Dim coreUnidrv_ID
strComponentVIGUID = "{7EC3F69D-1DA9-4C8C-8F76-FA28E5531454}"
enumMinRevision = 1
coreUnidrv_ID = addComponent(cmiInclude, cmiExactlyOne, strComponentVIGUID, enumMinRevision)
' Core Plotter Component
Dim corePlotter_ID
strComponentVIGUID = "{7EC3F69D-1DA9-4C8C-8F76-FA28E5531454}"
enumMinRevision = 1
corePlotter_ID = addComponent(cmiInclude, cmiExactlyOne, strComponentVIGUID, enumMinRevision)
'////////////////////////////////////////////////////////////////////////////
'
' Add the mapping table
'
'////////////////////////////////////////////////////////////////////////////
' mapping for PostScript
addTuple "pscript5.dll", corePS_ID
addTuple "ps5ui.dll", corePS_ID
' mapping for UniDrv
addTuple "unidrvui.dll", coreUnidrv_ID
addTuple "unidrv.dll", coreUnidrv_ID
' mapping for plotter
addTuple "plotter.dll", corePlotter_ID
addTuple "plotui.dll", corePlotter_ID
End Sub
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' isValid
'
' Function description:
'
' This function checks whether the componentFlagArray has exactly one elment for each
' compenent.
'
' Arguments:
'
' componentFlagArray -- an array of flags that indicate which component
' is mapped
'
' Return value
'
' True if componentFlagArray has exactly one element for each component
'
'///////////////////////////////////////////////////////////////////////////////////
Function isValid(componentFlagArray)
If (Not UBound(componentFlagArray) = (g_nComponents - 1)) Or (Not g_bAreTablesInitialized) Then
isValid = False
Exit Function
End If
isValid = True
End Function
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' mapIt
'
' Function description:
'
' This function fills the componentFlagArry, which must be an array of
' booleans in componentFlagArry with number of elements equal to the number of components
' in componentTuples
'
' Example usage:
'
' Dim componentFlagArray()
' Dim componentFlagArray(g_nComponentIndex)
'
' ' initialize this array to have all vlaues False if you prefer to
'
' If Not isValid(componentFlagArray) Then
' < your function name > = False
' Exit Function
' End If
'
' call mapIt(strFileName, componentFlagArray)
'
' Arguments:
'
' strFileName -- the name of dependent file
' componentFlagArray -- an array of flags that indicate which component
' is mapped
'
' Return value
'
' True if strFileName is mapped to a component, False otherwise
'
'///////////////////////////////////////////////////////////////////////////////////
Function mapIt(strFileName, componentFlagArray())
mapIt = False
Dim i
For i = 0 To (g_nTableEntries - 1)
If 0 = StrComp(strFileName, g_printerFilesMappingTuples(i).strFileName, 1) Then
componentFlagArray(g_printerFilesMappingTuples(i).nComponentID) = True
mapIt = True
Exit Function
End If
Next
End Function
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' initComponentFlagArray
'
' Function description:
'
' This function initializes componentFlagArray
'
' Arguments:
'
' componentFlagArray -- an array of flags that indicate which component
' is mapped
'
'///////////////////////////////////////////////////////////////////////////////////
Sub initComponentFlagArray(componentFlagArray)
Dim i
For i = 0 To UBound(componentFlagArray)
componentFlagArray(i) = False
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
'***************************************************************************
'This script tests the manipulation of property values, in the case that the
'property is a not an array type
'***************************************************************************
On Error Resume Next
while true
Set Service = GetObject("winmgmts:root/default")
Set Class = Service.Get()
Class.Path_.Class = "SIMPLEPROPTEST00"
Set Property = Class.Properties_.Add ("p1", 19)
Property.Value = 12567
WScript.Echo "The initial value of p1 is [12567]:", Class.Properties_("p1")
'****************************************
'First pass of tests works on non-dot API
'****************************************
WScript.Echo ""
WScript.Echo "PASS 1 - Use Non-Dot Notation"
WScript.Echo ""
'Verify we can report the value of an element of the property value
v = Class.Properties_("p1")
WScript.Echo "By indirection p1 has value [12567]:",v
'Verify we can report the value directly
WScript.Echo "By direct access p1 has value [12567]:", Class.Properties_("p1")
'Verify we can set the value of a single property value element
Class.Properties_("p1") = 234
WScript.Echo "After direct assignment p1 has value [234]:", Class.Properties_("p1")
'****************************************
'Second pass of tests works on dot API
'****************************************
WScript.Echo ""
WScript.Echo "PASS 2 - Use Dot Notation"
WScript.Echo ""
'Verify we can report the value of a property using the "dot" notation
WScript.Echo "By direct access p1 has value [234]:", Class.p1
'Verify we can report the value of a property using the "dot" notation
v = Class.p1
WScript.Echo "By indirect access p1 has value [234]:", v
'Verify we can set the value using dot notation
Class.p1 = -1
WScript.Echo "By direct access via the dot notation p1 has been set to [-1]:", Class.p1
Class.Put_ ()
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
wend
|
<gh_stars>1-10
Function sum_and_product(arr)
sum = 0
product = 1
For i = 0 To UBound(arr)
sum = sum + arr(i)
product = product * arr(i)
Next
WScript.StdOut.Write "Sum: " & sum
WScript.StdOut.WriteLine
WScript.StdOut.Write "Product: " & product
WScript.StdOut.WriteLine
End Function
myarray = Array(1,2,3,4,5,6)
sum_and_product(myarray)
|
Set objSet = GetObject("winmgmts:").ExecQuery(_
"select * from Win32_ShadowCopy")
for each obj in objSet
WScript.Echo "ID: " & obj.ID
WScript.Echo "SetID: " & obj.SetID
WScript.Echo "ProviderID: " & obj.ProviderID
WScript.Echo "InstallDate: " & obj.InstallDate
WScript.Echo "DeviceObject: " & obj.DeviceObject
WScript.Echo "VolumeName: " & obj.VolumeName
WScript.Echo "OriginatingMachine: " & obj.OriginatingMachine
WScript.Echo "ServiceMachine: " & obj.ServiceMachine
WScript.Echo "ExposedName: " & obj.ExposedName
WScript.Echo "ExposedPath: " & obj.ExposedPath
WScript.Echo "State: " & obj.State
WScript.Echo "Persistent: " & obj.Persistent
WScript.Echo "ClientAccessible: " & obj.ClientAccessible
WScript.Echo "NoAutoRelease: " & obj.NoAutoRelease
WScript.Echo "NoWriters: " & obj.NoWriters
WScript.Echo "Transportable: " & obj.Transportable
WScript.Echo "NotSurfaced: " & obj.NotSurfaced
WScript.Echo "HardwareAssisted: " & obj.HardwareAssisted
WScript.Echo "Differential: " & obj.Differential
WScript.Echo "Imported: " & obj.Imported
WScript.Echo "ExposedRemotely: " & obj.ExposedRemotely
WScript.Echo "ExposedLocally: " & obj.ExposedLocally
WScript.Echo ""
next
|
Debug.Print Application.Name
|
<filename>Task/99-Bottles-of-Beer/VBScript/99-bottles-of-beer-1.vb
sub song( numBottles )
dim i
for i = numBottles to 0 step -1
if i > 0 then
wscript.echo pluralBottles(i) & " of beer on the wall"
wscript.echo pluralBottles(i) & " of beer"
if i = 1 then
wscript.echo "take it down"
else
wscript.echo "take one down"
end if
wscript.echo "and pass it round"
wscript.echo pluralBottles(i-1) & " of beer on the wall"
wscript.echo
else
wscript.echo "no more bottles of beer on the wall"
wscript.echo "no more bottles of beer"
wscript.echo "go to the store"
wscript.echo "and buy some more"
wscript.echo pluralBottles(numBottles) & " of beer on the wall"
wscript.echo
end if
next
end sub
function pluralBottles( n )
select case n
case 1
pluralBottles = "one bottle"
case 0
pluralBottles = "no more bottles"
case else
pluralBottles = n & " bottles"
end select
end function
song 3
|
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "KeywordCreator"
ClientHeight = 6825
ClientLeft = 3075
ClientTop = 2340
ClientWidth = 9855
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6825
ScaleWidth = 9855
Begin VB.Frame Frame1
Caption = "Operational Mode:"
Height = 735
Left = 210
TabIndex = 17
Top = 2295
Width = 3570
Begin VB.OptionButton optIncremental
Caption = "Validate Only"
Height = 420
Index = 2
Left = 2295
TabIndex = 18
Top = 225
Width = 1155
End
Begin VB.OptionButton optIncremental
Caption = "Reset Pass"
Height = 375
Index = 1
Left = 1275
TabIndex = 11
Top = 240
Width = 945
End
Begin VB.OptionButton optIncremental
Caption = "Additive Pass"
Height = 420
Index = 0
Left = 165
TabIndex = 10
Top = 195
Width = 1155
End
End
Begin VB.TextBox txtLogFile
Height = 375
Left = 135
TabIndex = 8
Top = 1785
Width = 8070
End
Begin VB.CommandButton cmdLogFile
Caption = "&Log File..."
Height = 375
Left = 8280
TabIndex = 9
Top = 1800
Width = 1485
End
Begin VB.TextBox txtCabFile
Height = 375
Left = 135
TabIndex = 2
Top = 570
Width = 8070
End
Begin VB.CommandButton cmdBrowse
Caption = "&Input Cab..."
Height = 375
Left = 8280
TabIndex = 3
Top = 600
Width = 1485
End
Begin VB.TextBox txtSaveCab
Height = 375
Left = 135
TabIndex = 4
Top = 975
Width = 8070
End
Begin VB.CommandButton cmdSave
Caption = "&Output Cab..."
Height = 375
Left = 8280
TabIndex = 5
Top = 990
Width = 1485
End
Begin VB.TextBox txtQueriesFolder
Height = 375
Left = 135
TabIndex = 0
Top = 165
Width = 8070
End
Begin VB.CommandButton cmdBrowseQueries
Caption = "&Queries Folder..."
Height = 375
Left = 8280
TabIndex = 1
Top = 180
Width = 1485
End
Begin VB.TextBox txtBaseCab
Height = 375
Left = 135
TabIndex = 6
Top = 1380
Width = 8070
End
Begin VB.CommandButton cmdBase
Caption = "&Base Cab..."
Height = 375
Left = 8280
TabIndex = 7
Top = 1395
Width = 1485
End
Begin VB.TextBox txtLog
Height = 3120
Left = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 16
TabStop = 0 'False
Top = 3120
Width = 9765
End
Begin MSComctlLib.ProgressBar prgBar
Height = 210
Left = 0
TabIndex = 15
Top = 6360
Visible = 0 'False
Width = 9810
_ExtentX = 17304
_ExtentY = 370
_Version = 393216
Appearance = 1
End
Begin MSComctlLib.StatusBar stbProgress
Align = 2 'Align Bottom
Height = 210
Left = 0
TabIndex = 14
Top = 6615
Width = 9855
_ExtentX = 17383
_ExtentY = 370
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin MSComDlg.CommonDialog dlg
Left = -90
Top = -150
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 375
Left = 8850
TabIndex = 13
Top = 2640
Width = 855
End
Begin VB.CommandButton cmdGo
Caption = "&OK"
Height = 375
Left = 7920
TabIndex = 12
Top = 2640
Width = 855
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' Utility Stuff, all this could go to a COM Object and be distributed
' like this.
Private m_WsShell As IWshShell ' Used to Shell and Wait for Sub-Processes
Private m_fso As Scripting.FileSystemObject ' For filesystem operations
Private m_fhLog As Scripting.TextStream ' This we use to log the output to a file
Public g_dictStopWords As Scripting.Dictionary
Private dictStopSigns As Scripting.Dictionary
Private strOperatorsAnd As String
Private strOperatorsOr As String
Private strOperatorsNot As String
Private m_dictUriList As Scripting.Dictionary
Private Type oDomHhtEntry
strHhtFile As String
oDomHht As DOMDocument
End Type
Private m_aDomHht() As oDomHhtEntry
Private WithEvents p_frmFolderChooser As frmFolderChooser
Attribute p_frmFolderChooser.VB_VarHelpID = -1
Enum OperationalMode
AdditivePriorityPass = 0
ResetPriorityPass = 1
ValidateOnly = 2
AutoKeywords = 3
End Enum
Private m_OperationalMode As OperationalMode
Enum ProcessingState
PROC_PROCESSING = 2 ^ 0
PROC_STOP_PROCESSING_NOW = 2 ^ 2
PROC_PROCESSING_STOPPED = 2 ^ 3
End Enum
Private Sub Form_Initialize()
Set m_WsShell = CreateObject("Wscript.Shell")
Set m_fso = New Scripting.FileSystemObject
Set m_dictUriList = New Scripting.Dictionary
m_OperationalMode = 0
End Sub
Private Sub Form_Load()
Me.Caption = App.EXEName & " (v" & App.Major & "." & App.Minor & "." & App.Revision & _
"): Prioritized Keyword creation tool"
Me.optIncremental(0).Value = True
cmdGo.Default = True
cmdClose.Cancel = True
Set p_frmFolderChooser = New frmFolderChooser
Dim strCommand As String
strCommand = Trim$(Command$)
If (strCommand = "") Then
Exit Sub
End If
txtQueriesFolder = GetOption(strCommand, "q", True)
txtCabFile = GetOption(strCommand, "i", True)
txtSaveCab = GetOption(strCommand, "o", True)
txtBaseCab = GetOption(strCommand, "b", True)
txtLogFile = GetOption(strCommand, "l", True)
If (OptionExists(strCommand, "1", True)) Then
optIncremental(0).Value = True
ElseIf (OptionExists(strCommand, "2", True)) Then
optIncremental(1).Value = True
ElseIf (OptionExists(strCommand, "3", True)) Then
optIncremental(2).Value = True
End If
cmdGo_Click
cmdClose_Click
Common_Exit:
End Sub
Private Sub optIncremental_Click(Index As Integer)
m_OperationalMode = Index
End Sub
Sub WriteLog(strMsg As String, Optional ByVal bWriteToStatusBar As Boolean = True)
With Me
.txtLog = .txtLog & vbCrLf & strMsg
If (bWriteToStatusBar) Then
.stbProgress.SimpleText = strMsg
End If
If (Len(.txtLog) > 65000) Then
TrimLogTop
End If
End With
If (Not m_fhLog Is Nothing) Then
m_fhLog.WriteLine strMsg
End If
DoEvents
End Sub
Sub WriteStatus(strMsg As String)
With Me
.stbProgress.SimpleText = strMsg
End With
DoEvents
End Sub
Sub TrimLogTop()
Dim lPos As Long
With Me
lPos = InStrRev(Left$(.txtLog, 1000), vbCrLf)
If (lPos > 0) Then
.txtLog = Mid$(.txtLog, lPos + 2)
End If
End With
End Sub
Private Function p_getTemplateName( _
ByVal strBase As String, _
Optional ByVal strFolder As String = "", _
Optional ByVal strExt As String = "", _
Optional ByVal strPreAmble As String = "", _
Optional ByVal strTrailer As String = "", _
Optional ByVal bReturnFullName = False _
) As String
Dim strCandidateFileName As String
Dim lx As Long: lx = 1
Do
strCandidateFileName = _
IIf(strFolder = "", m_fso.GetParentFolderName(strBase), strFolder) & "\" & _
strPreAmble & _
m_fso.GetBaseName(strBase) & _
strTrailer & IIf(lx > 1, "_" & lx, "") & "." & _
IIf(strExt = "", m_fso.GetExtensionName(strBase), strExt)
lx = lx + 1
Loop While (m_fso.FileExists(strCandidateFileName))
p_getTemplateName = IIf(bReturnFullName, _
strCandidateFileName, _
m_fso.GetFileName(strCandidateFileName) _
)
End Function
Private Sub SetRunningState(ByVal bRunning As Boolean)
With Me
.cmdGo.Enabled = Not bRunning
.cmdBrowse.Enabled = Not bRunning
.cmdSave.Enabled = Not bRunning
.txtQueriesFolder.Enabled = Not bRunning
.txtSaveCab.Enabled = Not bRunning
If (bRunning) Then
.cmdClose.Caption = "&Stop"
Else
.cmdClose.Caption = "&Close"
End If
End With
End Sub
Private Function p_Hex2dec(ByRef strHex As String) As Long
p_Hex2dec = CLng("&H" + strHex)
End Function
Private Function p_Percent2Ascii(ByRef strPercentHex As String) As String
p_Percent2Ascii = ""
On Error GoTo Common_Exit
p_Percent2Ascii = ChrW(p_Hex2dec(Mid$(strPercentHex, 2)))
Common_Exit:
End Function
Private Function p_NormalizeUriNotation(ByRef strUri As String) As String
p_NormalizeUriNotation = ""
Dim pRv As String: pRv = ""
Dim lx As Long
lx = 1
Do While (lx <= Len(strUri))
Dim cThis As String
cThis = Mid$(strUri, lx, 1)
If (Len(strUri) - lx > 2) Then
If (cThis = "%") Then
Dim cChar As String
cChar = p_Percent2Ascii(Mid$(strUri, lx, 3))
If (Len(cChar) > 0) Then
pRv = pRv + cChar
lx = lx + 2 ' The reinitialization at the end bumps us one more up.
Else
pRv = pRv + cThis
End If
Else
pRv = pRv + cThis
End If
Else
pRv = pRv + cThis
End If
lx = lx + 1
Loop
p_NormalizeUriNotation = Trim$(pRv)
Common_Exit:
End Function
Function Cab2Folder(ByVal strCabFile As String)
Cab2Folder = ""
' We grab a Temporary Filename and create a folder out of it
Dim strFolder As String
strFolder = Environ("TEMP") + "\" + m_fso.GetTempName
m_fso.CreateFolder strFolder
' We uncab CAB contents into the Source CAB Contents dir.
Dim strcmd As String
strcmd = "cabarc X """ + strCabFile + """ " + strFolder + "\"
m_WsShell.Run strcmd, True, True
Cab2Folder = strFolder
End Function
Sub Folder2Cab( _
ByVal strFolder As String, _
ByVal strCabFile As String _
)
' We recab using the Destination directory contents
' cabarc -s 6144 N ..\algo.cab *.*
If (m_fso.FileExists(strCabFile)) Then
m_fso.DeleteFile strCabFile, Force:=True
End If
Dim strcmd As String
strcmd = "cabarc -s 6144 N """ + strCabFile + """ " + strFolder + "\*.*"
m_WsShell.Run strcmd, True, True
End Sub
' ============ END UTILITY STUFF ========================
' ============ BoilerPlate Form Code
Private Sub cmdBrowseQueries_Click()
Load p_frmFolderChooser
p_frmFolderChooser.SetFolder 0, txtQueriesFolder.Text
p_frmFolderChooser.Show vbModal
End Sub
Private Sub p_frmFolderChooser_FolderChosen( _
ByVal i_intIndex As Long, _
ByVal strFolder As String _
)
txtQueriesFolder.Text = strFolder
End Sub
Private Sub cmdBase_Click()
dlg.Filter = "All Files (*.*)|*.*|Cab Files (*.cab)|*.cab"
dlg.FilterIndex = 2
dlg.FileName = ""
dlg.ShowOpen
If (Len(dlg.FileName) > 0) Then
Me.txtBaseCab = dlg.FileName
End If
End Sub
Private Sub cmdBrowse_Click()
dlg.Filter = "All Files (*.*)|*.*|Cab Files (*.cab)|*.cab"
dlg.FilterIndex = 2
dlg.FileName = ""
dlg.ShowOpen
If (Len(dlg.FileName) > 0) Then
Me.txtCabFile = dlg.FileName
End If
End Sub
Private Sub cmdSave_Click()
dlg.Filter = "All Files (*.*)|*.*|Cab Files (*.cab)|*.cab"
dlg.FilterIndex = 2
dlg.FileName = p_getTemplateName(Me.txtCabFile, strTrailer:="_out")
dlg.ShowSave
If (Len(dlg.FileName) > 0) Then
Me.txtSaveCab = dlg.FileName
End If
End Sub
Private Sub cmdLogFile_Click()
dlg.Filter = "All Files (*.*)|*.*|Log Files (*.log)|*.log"
dlg.FilterIndex = 2
dlg.FileName = p_getTemplateName(Me.txtCabFile, strExt:="log", strTrailer:="_out")
dlg.ShowSave
If (Len(dlg.FileName) > 0) Then
Me.txtLogFile = dlg.FileName
End If
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdGo_Click()
With Me
.txtCabFile.Text = Trim$(.txtCabFile.Text)
.txtSaveCab.Text = Trim$(.txtSaveCab.Text)
.txtCabFile.Enabled = False
.txtSaveCab.Enabled = False
.cmdBrowse.Enabled = False
.cmdSave.Enabled = False
.cmdGo.Enabled = False
If (Len(.txtCabFile.Text) > 0) Then
FixCab .txtCabFile.Text, .txtSaveCab.Text, Trim$(.txtBaseCab.Text), .txtLogFile
End If
.txtCabFile.Enabled = True
.txtSaveCab.Enabled = True
.cmdBrowse.Enabled = True
.cmdSave.Enabled = True
.cmdGo.Enabled = True
End With
End Sub
Sub FixCab( _
ByVal strCabFile As String, _
ByVal strSaveCab As String, _
ByVal strBaseCab As String, _
ByVal strLogFile As String _
)
Dim strErrMsg As String: strErrMsg = ""
If (Not m_fso.FileExists(strCabFile)) Then
strErrMsg = "Cannot find " & strCabFile
MsgBox strErrMsg
GoTo Common_Exit
End If
If (Len(strLogFile) = 0) Then
strLogFile = p_getTemplateName(strCabFile, strExt:="log", strTrailer:="_out", bReturnFullName:=True)
Me.txtLogFile = strLogFile
End If
Set m_fhLog = m_fso.CreateTextFile(strLogFile, True, True)
p_LogRunInformation
Dim strCabFolder As String
prgBar.Visible = True
WriteStatus "Uncabbing " & strCabFile
strCabFolder = Cab2Folder(strCabFile)
' Now we start processing based on the command passed
Select Case (m_OperationalMode)
Case AdditivePriorityPass, ResetPriorityPass
Dim strBaseCabFolder As String
If (strBaseCab <> "") Then
If (Not m_fso.FileExists(strBaseCab)) Then
MsgBox "Cannot find " & strBaseCab
GoTo Common_Exit
End If
prgBar.Visible = True
WriteStatus "Uncabbing " & strBaseCab
strBaseCabFolder = Cab2Folder(strBaseCab)
Else
strBaseCabFolder = strCabFolder
End If
WriteStatus "Extracting Stop Words and Stop Signs"
GetStopWordsAndStopSigns strBaseCabFolder
WriteStatus "Applying Fixes "
Dim bGoodFix As Boolean
bGoodFix = FixPerSe(strCabFolder)
If (Not bGoodFix) Then
MsgBox "Error: Fix Failed", Title:=App.EXEName
Else
WriteStatus "Recabbing " & strCabFile
Folder2Cab strCabFolder, strSaveCab
End If
Case ValidateOnly
p_ValidatePass strCabFolder
Case Else
MsgBox "Not a valid command"
GoTo Common_Exit
End Select
' Now we delete the Temporary Folders
prgBar.Visible = False
WriteStatus "Deleting Temporary Files"
m_fso.DeleteFolder strCabFolder, Force:=True
m_fhLog.Close: Set m_fhLog = Nothing
Common_Exit:
WriteStatus "Done" + IIf(Len(strErrMsg) > 0, " - " + strErrMsg, "")
End Sub
Sub p_LogRunInformation()
WriteLog Me.Caption, False
WriteLog String$(100, "="), False
WriteLog App.EXEName & " run on " & Now
WriteLog "Operational Mode = " & IIf(m_OperationalMode = AdditivePriorityPass, _
"Additive Priority", _
IIf(m_OperationalMode = ResetPriorityPass, _
"Reset Priority", _
"Validation" _
) _
) & " Pass"
With Me
If (Len(.txtQueriesFolder) > 0) Then
WriteLog "Queries Folder = " & .txtQueriesFolder
End If
If (Len(.txtCabFile) > 0) Then
WriteLog "Input Cab File = " & .txtCabFile
End If
If (Len(.txtSaveCab) > 0) Then
WriteLog "Output Cab File = " & .txtSaveCab
End If
If (Len(.txtBaseCab) > 0) Then
WriteLog "Reference Cab File = " & .txtBaseCab
End If
If (Len(.txtLogFile) > 0) Then
WriteLog "Output Log File = " & .txtLogFile
End If
End With
WriteLog String$(100, "="), False
End Sub
Sub GetStopWordsAndStopSigns(ByVal strCabFolder As String)
Dim oElem As IXMLDOMElement ' Used for all element Creation
' We parse Package_Description.xml to find the HHT Files
Dim oDomPkg As DOMDocument: Set oDomPkg = New DOMDocument
Dim strPkgFile As String: strPkgFile = strCabFolder + "\package_description.xml"
oDomPkg.async = False
oDomPkg.Load strPkgFile
If (oDomPkg.parseError <> 0) Then GoTo Common_Exit
Dim oMetaDataNode As IXMLDOMNode
Set oMetaDataNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/METADATA")
strOperatorsAnd = ""
strOperatorsOr = ""
strOperatorsNot = ""
Dim oDomHhtNode As IXMLDOMNode
' now we go through each HHT and check for fix relevancy.
For Each oDomHhtNode In oMetaDataNode.selectNodes("HHT")
Dim strHhtFile As String
strHhtFile = oDomHhtNode.Attributes.getNamedItem("FILE").Text
' Let's load the HHT
Dim oDomHht As DOMDocument: Set oDomHht = New DOMDocument
oDomHht.async = False
oDomHht.Load strCabFolder + "\" + strHhtFile
If (oDomHht.parseError <> 0) Then GoTo Common_Exit
p_LoadStopWords oDomHht
p_LoadStopSigns oDomHht
p_LoadVerbalOperators oDomHht
Next
If (dictStopSigns.Count = 0) Then
WriteLog "Warning: Your StopSigns list is empty.", False
WriteLog vbTab + "This may be due to the fact that you are not adding a Base Cab", False
WriteLog vbTab + "or that you are working in a language where StopSigns do not exist", False
End If
If (g_dictStopWords.Count = 0) Then
WriteLog "Warning: Your StopWords list is empty.", False
WriteLog vbTab + "This may be due to the fact that you are not adding a Base Cab", False
WriteLog vbTab + "or that you are working in a language where StopWords do not exist", False
End If
SetVerbalOperators strOperatorsAnd, strOperatorsOr, strOperatorsNot
Common_Exit:
Exit Sub
End Sub
Private Function p_GetHht( _
ByRef oDomHhtNode As IXMLDOMNode, _
ByVal strCabFolder As String, _
Optional ByRef strHhtFile As String = "" _
) As IXMLDOMNode
Set p_GetHht = Nothing
If (oDomHhtNode Is Nothing) Then GoTo Common_Exit
strHhtFile = oDomHhtNode.Attributes.getNamedItem("FILE").Text
' Let's load the HHT
Dim oDomHht As DOMDocument: Set oDomHht = New DOMDocument
oDomHht.async = False
oDomHht.Load strCabFolder + "\" + strHhtFile
If (oDomHht.parseError <> 0) Then
p_DisplayParseError oDomHht.parseError
GoTo Common_Exit
End If
Set p_GetHht = oDomHht
Common_Exit:
End Function
Function p_ValidatePass(ByVal strCabFolder As String) As Boolean
p_ValidatePass = True ' because this pass should never fail.
' We parse Package_Description.xml to find the HHT Files
Dim oDomPkg As DOMDocument: Set oDomPkg = New DOMDocument
Dim strPkgFile As String: strPkgFile = strCabFolder + "\package_description.xml"
oDomPkg.async = False
oDomPkg.Load strPkgFile
If (oDomPkg.parseError <> 0) Then GoTo Common_Exit
' We first open all HHTs this way we only loop through
' them in memory next.
p_OpenAllHhts strCabFolder, oDomPkg
If (Not p_MeetsAcceptanceTest) Then
WriteLog "your prioritization numbers exceed acceptance criteria"
WriteLog "you need to prioritize fewer keywords for priority to be effective"
Else
WriteLog "Your prioritization numbers meet acceptance criteria"
End If
Common_Exit:
End Function
Function FixPerSe(ByVal strCabFolder As String) As Boolean
FixPerSe = False
Dim oElem As IXMLDOMElement ' Used for all element Creation
' We parse Package_Description.xml to find the HHT Files
Dim oDomPkg As DOMDocument: Set oDomPkg = New DOMDocument
Dim strPkgFile As String: strPkgFile = strCabFolder + "\package_description.xml"
oDomPkg.async = False
oDomPkg.Load strPkgFile
If (oDomPkg.parseError <> 0) Then GoTo Common_Exit
Dim oDomHhtNode As IXMLDOMNode
Dim strHhtFile As String
' We first open all HHTs this way we only loop through
' them in memory next.
p_OpenAllHhts strCabFolder, oDomPkg
If (m_OperationalMode = ResetPriorityPass) Then
p_ZapAllPriorityEntries
Else
If (Not p_MeetsAcceptanceTest) Then
GoTo Common_Exit
End If
End If
' Now we create a collection that has all the Uris and its questions
p_BuildUriList
' now we go through each HHT and check for fix relevancy.
Dim lx As Long
For lx = 0 To UBound(m_aDomHht)
With m_aDomHht(lx)
Dim oListTopics As IXMLDOMNodeList
Set oListTopics = .oDomHht.selectNodes("/METADATA/TAXONOMY_ENTRIES/TAXONOMY_ENTRY[ not( @ENTRY ) ]")
If (Not oListTopics Is Nothing) Then
' We go through this HHT ONLY if it has
' Taxonomy Entries for Topics
Dim oTaxoNode As IXMLDOMNode, strUri As String
Me.prgBar.Visible = True
Me.prgBar.Max = oListTopics.length + 1
Me.prgBar.Value = 0
.oDomHht.setProperty "SelectionLanguage", "XPath"
Dim intNewKeywords As Long, intOldKeywords As Long, _
intTotalNewKeywords As Long, intTotalOldKeywords As Long
For Each oTaxoNode In oListTopics
strUri = LCase$(XMLGetAttribute(oTaxoNode, "URI"))
If (m_dictUriList.Exists(strUri)) Then
' The URI exists so we need to set the keywords.
Dim oUQ As UriQueries
Set oUQ = m_dictUriList.Item(strUri)
oUQ.SetTaxonomyEntryKeywords oTaxoNode
intTotalNewKeywords = intTotalNewKeywords + intNewKeywords
intTotalOldKeywords = intTotalOldKeywords + intOldKeywords
End If
Me.prgBar.Value = Me.prgBar.Value + 1
WriteStatus "Fixing URIs in HHTs " & " [" & Me.prgBar.Value & "/" & Me.prgBar.Max & "]"
Next
.oDomHht.Save .strHhtFile
End If
End With
Next
If (Not p_MeetsAcceptanceTest) Then
GoTo Common_Exit
End If
' Now we save the resulting package_description.xml
oDomPkg.Save strPkgFile
' Finally we log an entry that specifies the amount of Keywords that
' have priority attributes.
FixPerSe = True
Common_Exit:
Exit Function
End Function
Private Sub p_OpenAllHhts( _
ByVal strCabFolder As String, _
ByRef oDomPkg As IXMLDOMNode _
)
Dim oMetaDataNode As IXMLDOMNode
Set oMetaDataNode = oDomPkg.selectSingleNode("HELPCENTERPACKAGE/METADATA")
Dim oDomHhtNode As IXMLDOMNode, oDomHht As IXMLDOMNode
Dim strHhtFile As String
Dim lx As Long
For Each oDomHhtNode In oMetaDataNode.selectNodes("HHT")
Set oDomHht = p_GetHht(oDomHhtNode, strCabFolder, strHhtFile)
ReDim Preserve m_aDomHht(lx)
With m_aDomHht(lx)
Set .oDomHht = oDomHht
.strHhtFile = strCabFolder + "\" + strHhtFile
End With
lx = lx + 1
Next
Common_Exit:
End Sub
Private Sub p_ZapAllPriorityEntries()
Dim lx As Long
For lx = 0 To UBound(m_aDomHht)
' Let's point to the right HHT
Dim oDomHht As IXMLDOMNode
Set oDomHht = m_aDomHht(lx).oDomHht
Dim oDomNodeList As IXMLDOMNodeList
Set oDomNodeList = oDomHht.selectNodes("//KEYWORD[ @PRIORITY ]")
If (Not oDomNodeList Is Nothing) Then
Dim oDomNode As IXMLDOMNode
For Each oDomNode In oDomNodeList
oDomNode.Attributes.removeNamedItem ("PRIORITY")
Next
End If
Next lx
End Sub
Private Function p_MeetsAcceptanceTest() As Boolean
p_MeetsAcceptanceTest = False
Dim lngKwHht As Long, lngKwPriHht As Long, _
lngTotalKwHht As Long, lngTotalKwPriHht As Long, _
lngKwGt12k As Long, _
lngKwEq10k As Long, _
lngKwEq5k As Long, _
lngKwEq3_3k As Long, _
lngTotalKwGt12k As Long, _
lngTotalKwEq10k As Long, _
lngTotalKwEq5k As Long, _
lngTotalKwEq3_3k As Long
' lngTotalTaxoEntries As Long, lngTaxoEntries As Long
Dim lx As Long
' We assess that this set has less than 25% of the Keywords
' with the PRIORITY attribute set.
' lngTotalTaxoEntries = 0
lngTotalKwHht = 0: lngTotalKwPriHht = 0:
lngTotalKwGt12k = 0: lngTotalKwEq10k = 0: lngTotalKwEq5k = 0: lngTotalKwEq3_3k = 0
For lx = 0 To UBound(m_aDomHht)
With m_aDomHht(lx)
' Dim oList As IXMLDOMNodeList
' Set oList = .oDomHht.selectNodes("//TAXONOMY_ENTRY")
' lngTaxoEntries = IIf(oList Is Nothing, 0, oList.length)
' lngTotalTaxoEntries = lngTotalTaxoEntries + lngTaxoEntries
p_GetPrioKw .oDomHht, lngKwHht, lngKwPriHht, _
lngKwGt12k, _
lngKwEq10k, _
lngKwEq5k, _
lngKwEq3_3k
lngTotalKwHht = lngTotalKwHht + lngKwHht
lngTotalKwPriHht = lngTotalKwPriHht + lngKwPriHht
lngTotalKwGt12k = lngTotalKwGt12k + lngKwGt12k
lngTotalKwEq10k = lngTotalKwEq10k + lngKwEq10k
lngTotalKwEq5k = lngTotalKwEq5k + lngKwEq5k
lngTotalKwEq3_3k = lngTotalKwEq3_3k + lngKwEq3_3k
WriteLog m_fso.GetFileName(m_aDomHht(lx).strHhtFile) & _
": There are " & lngKwHht & " keywords and " & _
lngKwPriHht & " of them are prioritized "
If (lngKwGt12k > 0) Then
WriteLog "No keywords are allowed with Priority greater than 12000"
GoTo Common_Exit
End If
End With
Next lx
Dim lngPercentPri As Long:
' The following is just a hack to avoid division by 0
' it does not alter statistics.
If (lngTotalKwHht = 0) Then lngTotalKwHht = 1
lngPercentPri = lngTotalKwPriHht / lngTotalKwHht * 100
WriteLog Me.txtCabFile & " has " & Format$(lngPercentPri, "#0.0##") & "% Keywords with Priority Attribute"
WriteLog vbTab & Format$(lngKwEq10k / lngTotalKwHht * 100, "#0.0##") & "% Keywords for single word queries"
WriteLog vbTab & Format$(lngKwEq5k / lngTotalKwHht * 100, "#0.0##") & "% Keywords for two word queries"
If (lngKwEq3_3k > 0) Then
WriteLog vbTab & Format$(lngKwEq3_3k / lngTotalKwHht * 100, "#0.0##") & "% Keywords for three word queries"
End If
' now we do the acceptance test... we leave a small back-door for
' Fix HHTs which will have up to 5 topics ... really 25 keywords
If (lngPercentPri > 25 And lngTotalKwHht > 25) Then
WriteLog "a Maximum of 25% Keywords can be prioritized."
GoTo Common_Exit
End If
p_MeetsAcceptanceTest = True
Common_Exit:
End Function
Private Sub p_BuildUriList()
Dim strUserQuery As String, strExpectedUri As String
Dim rsQs As ADODB.Recordset
Dim Folder As Scripting.Folder
Dim File As Scripting.File
Set rsQs = New ADODB.Recordset
rsQs.Fields.Append "User Query", adVarWChar, 512
rsQs.Fields.Append "Expected Uri", adVarWChar, 512
rsQs.Open
Set Folder = m_fso.GetFolder(Me.txtQueriesFolder)
For Each File In Folder.Files
If (LCase$(Right(File.Name, 3) = "xml")) Then
If (LCase$(Left(File.Name, 7)) = "queries") Then
p_XlXml2Recordset File.Path, rsQs
Else
WriteLog "Ignoring " & File.Path
End If
ElseIf (LCase$(Right(File.Name, 3) = "xls")) Then
If (LCase$(Left(File.Name, 7)) = "queries") Then
p_Xls2Recordset File.Path, rsQs
Else
WriteLog "Ignoring " & File.Path
End If
End If
Next
rsQs.Sort = "[Expected Uri],[User Query]"
If (rsQs.RecordCount = 0) Then
Exit Sub
End If
rsQs.MoveFirst
m_dictUriList.RemoveAll
Dim oUQ As UriQueries
Do While (Not rsQs.EOF)
strUserQuery = rsQs("User Query")
strExpectedUri = rsQs("Expected Uri")
If (Not m_dictUriList.Exists(strExpectedUri)) Then
Set oUQ = New UriQueries
oUQ.Uri = strExpectedUri
m_dictUriList.Add strExpectedUri, oUQ
Else
Set oUQ = m_dictUriList.Item(strExpectedUri)
End If
oUQ.AddQuestion strUserQuery
rsQs.MoveNext
Loop
End Sub
Private Sub p_GetPrioKw( _
ByRef oDomHht As IXMLDOMNode, _
ByRef o_lngKwHht As Long, _
ByRef o_lngKwPriHht As Long, _
ByRef o_lngKwGt12k As Long, _
ByRef o_lngKwEq10k As Long, _
ByRef o_lngKwEq5k As Long, _
ByRef o_lngKwEq3_3k As Long _
)
Dim oListKW As IXMLDOMNodeList
Set oListKW = oDomHht.selectNodes("//KEYWORD")
If (Not oListKW Is Nothing) Then
o_lngKwHht = oListKW.length
End If
Set oListKW = oDomHht.selectNodes("//KEYWORD[ @PRIORITY ]")
If (Not oListKW Is Nothing) Then
o_lngKwPriHht = oListKW.length
End If
Set oListKW = oDomHht.selectNodes("//KEYWORD[ @PRIORITY > 12000 ]")
If (Not oListKW Is Nothing) Then
o_lngKwGt12k = oListKW.length
End If
Set oListKW = oDomHht.selectNodes("//KEYWORD[ @PRIORITY = 10000 ]")
If (Not oListKW Is Nothing) Then
o_lngKwEq10k = oListKW.length
End If
Set oListKW = oDomHht.selectNodes("//KEYWORD[ @PRIORITY = 5000 ]")
If (Not oListKW Is Nothing) Then
o_lngKwEq5k = oListKW.length
End If
Set oListKW = oDomHht.selectNodes("//KEYWORD[ @PRIORITY = 3333 ]")
If (Not oListKW Is Nothing) Then
o_lngKwEq3_3k = oListKW.length
End If
End Sub
Public Function p_RemoveStopSigns( _
ByVal i_strText As String _
) As String
Dim intIndex As Long
Dim intLength As Long
Dim str As String
Dim char As String
str = i_strText
intLength = Len(str)
For intIndex = intLength To 1 Step -1
char = Mid$(str, intIndex, 1)
If (dictStopSigns.Exists(char)) Then
If (dictStopSigns(char) = CONTEXT_ANYWHERE_E) Then
' Replace the character with a space
str = Mid$(str, 1, intIndex - 1) & " " & Mid$(str, intIndex + 1)
ElseIf (intIndex > 1) Then
' Context is CONTEXT_AT_END_OF_WORD_E, and this isn't the first char
If (Mid$(str, intIndex - 1, 1) <> " ") Then
' Previous character is not a space
If ((intIndex = intLength) Or (Mid$(str, intIndex + 1, 1) = " ")) Then
' This is the last character or the next character is a space
' Replace the character with a space
str = Mid$(str, 1, intIndex - 1) & " " & Mid$(str, intIndex + 1)
End If
End If
End If
End If
Next
p_RemoveStopSigns = str
End Function
Sub p_LoadStopSigns(ByRef oDomtaxo As DOMDocument)
On Error Resume Next
Dim oDomNode As IXMLDOMNode, oNodeList As IXMLDOMNodeList
Dim l As Long
WriteStatus "Loading Stop Signs"
If (dictStopSigns Is Nothing) Then
Set dictStopSigns = New Scripting.Dictionary
End If
Set oNodeList = oDomtaxo.selectNodes("/METADATA/STOPSIGN_ENTRIES/*")
For Each oDomNode In oNodeList
If (oDomNode.Attributes.getNamedItem("CONTEXT").Text = "ENDOFWORD") Then
l = CONTEXT_AT_END_OF_WORD_E
Else
l = CONTEXT_ANYWHERE_E
End If
dictStopSigns.Add oDomNode.Attributes.getNamedItem("STOPSIGN").Text, l
Next
End Sub
Sub p_LoadStopWords(ByRef oDomtaxo As DOMDocument)
On Error Resume Next
Dim oDomNode As IXMLDOMNode, oNodeList As IXMLDOMNodeList
WriteStatus "Loading Stop Words"
If (g_dictStopWords Is Nothing) Then
Set g_dictStopWords = New Scripting.Dictionary
End If
g_dictStopWords.CompareMode = BinaryCompare
Set oNodeList = oDomtaxo.selectNodes("/METADATA/STOPWORD_ENTRIES/*")
For Each oDomNode In oNodeList
g_dictStopWords.Add LCase$(oDomNode.Attributes.getNamedItem("STOPWORD").Text), True
Next
End Sub
Sub p_LoadVerbalOperators(ByRef oDomtaxo As DOMDocument)
On Error Resume Next
Dim oDomNode As IXMLDOMNode, oNodeList As IXMLDOMNodeList
Dim strOperation As String
Dim strOperator As String
WriteStatus "Loading Verbal Operators"
Set oNodeList = oDomtaxo.selectNodes("/METADATA/OPERATOR_ENTRIES/*")
For Each oDomNode In oNodeList
strOperation = UCase$(oDomNode.Attributes.getNamedItem("OPERATION").nodeValue)
strOperator = oDomNode.Attributes.getNamedItem("OPERATOR").nodeValue
Select Case strOperation
Case "AND"
If (strOperatorsAnd = "") Then
strOperatorsAnd = strOperator
Else
strOperatorsAnd = strOperatorsAnd & ";" & strOperator
End If
Case "OR"
If (strOperatorsOr = "") Then
strOperatorsOr = strOperator
Else
strOperatorsOr = strOperatorsOr & ";" & strOperator
End If
Case "NOT"
If (strOperatorsNot = "") Then
strOperatorsNot = strOperator
Else
strOperatorsNot = strOperatorsNot & ";" & strOperator
End If
End Select
Next
End Sub
Sub p_Xls2Recordset( _
ByVal strXlsFile As String, _
ByVal rs As ADODB.Recordset _
)
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim strErrMsg As String: strErrMsg = ""
If (Not m_fso.FileExists(strXlsFile)) Then
MsgBox "Cannot find " & strXlsFile
GoTo Common_Exit
End If
prgBar.Visible = True
WriteLog "Parsing " & strXlsFile
Dim rs1 As ADODB.Recordset: Set rs1 = New ADODB.Recordset
cnn.Open "DRIVER=Microsoft Excel Driver (*.xls);ReadOnly=0;DBQ=" & _
strXlsFile & ";HDR=0;"
rs1.Open "SELECT * FROM `Sheet1$`", cnn, adOpenStatic, adLockReadOnly
Do While Not rs1.EOF
If (IsNull(rs1("User Query"))) Then
GoTo LContinue
End If
rs.AddNew
rs("User Query") = LCase$(Trim$(rs1("User Query"))) & ""
rs("Expected Uri") = LCase$(Trim$(rs1("Expected Uri"))) & ""
rs.Update
LContinue:
rs1.MoveNext
Loop
rs.Sort = "[User Query],[Expected Uri]"
Common_Exit:
End Sub
Sub p_XlXml2Recordset( _
ByVal strXlXmlFile As String, _
ByVal rs As ADODB.Recordset _
)
Dim strErrMsg As String: strErrMsg = ""
If (Not m_fso.FileExists(strXlXmlFile)) Then
MsgBox "Cannot find " & strXlXmlFile
GoTo Common_Exit
End If
prgBar.Visible = True
WriteLog "Parsing " & strXlXmlFile
Dim oDomXlXml As DOMDocument: Set oDomXlXml = GetXmlFile(strXlXmlFile)
' first we Find the Names of the rows
Dim oDomNodeWorksheet As IXMLDOMNode
Dim oDomWksList As IXMLDOMNodeList
Set oDomWksList = oDomXlXml.selectNodes("/Workbook/Worksheet")
Set oDomNodeWorksheet = oDomWksList.Item(0)
' Now we need to get to the first row to read the column names
' and lock up the output HSCSearchTester Columns from there
Dim oDomRowList As IXMLDOMNodeList
Set oDomRowList = oDomNodeWorksheet.selectNodes("Table/Row")
Dim oDomCellDataList As IXMLDOMNodeList
Set oDomCellDataList = oDomRowList.Item(0).selectNodes("Cell/Data")
Const xlUserQuery As Integer = 2 ^ 0, _
xlExpectedUri As Integer = 2 ^ 1
Dim xlInputColumns As Integer: xlInputColumns = 0
Dim ixColUserQuery As Integer
Dim ixColExpectedUri As Integer
Dim lx As Long: lx = 0
Dim oDomCellData As IXMLDOMNode
For Each oDomCellData In oDomCellDataList
Select Case LCase$(oDomCellData.Text)
Case "user query"
xlInputColumns = (xlInputColumns Or xlUserQuery)
ixColUserQuery = lx
Case "uri", "expected uri", "desired uri"
xlInputColumns = (xlInputColumns Or xlExpectedUri)
ixColExpectedUri = lx
End Select
lx = lx + 1
Next
' We do some validation so that they send us a specific Spreadsheet
' format. Namely only column names validation
If ((xlInputColumns And (xlUserQuery Or xlExpectedUri)) <> _
(xlUserQuery Or xlExpectedUri)) Then
WriteLog "Invalid Input XL Spreadsheet.", False
WriteLog "", False
WriteLog vbTab + "You must include at least the following columns:", False
WriteLog vbTab + vbTab + "- User Query", False
WriteLog vbTab + vbTab + "- Expected URI", False
WriteLog "", False
GoTo Common_Exit
End If
' now we dump all Excel Data into the Recordset
Dim oDomRow As IXMLDOMNode
lx = 0
For Each oDomRow In oDomRowList
If (lx <> 0) Then
rs.AddNew
Dim ixCol As Integer: ixCol = 0
For Each oDomCellData In oDomRow.selectNodes("Cell/Data")
Select Case ixCol
Case ixColUserQuery
rs("User Query") = LCase$(Trim$(oDomCellData.Text))
Case ixColExpectedUri
rs("Expected Uri") = LCase$(p_NormalizeUriNotation(Trim$(oDomCellData.Text)))
End Select
ixCol = ixCol + 1
Next
rs.Update
End If
lx = lx + 1
Next
' Some recordset Validations:
'
' We do them here, so when Excel via ADO is integrated we
' validate in a single place
'
' we discard:
' - all repeats of User Query/URI Pairs and flag as warnings these
' - all records that have either an Empty Expected URI or Empty User Query
' rs.MoveFirst
' Dim strPrevUserQuery As String, strPrevExpectedUri As String, _
' strUserQuery As String, strExpectedUri As String
'
' strPrevUserQuery = ""
' strPrevExpectedUri = ""
' Do While (Not rs.EOF)
' strUserQuery = rs("User Query")
' strExpectedUri = rs("Expected Uri")
' If (Len(strUserQuery) = 0 Or Len(strExpectedUri) = 0) Then
' WriteLog "Warning Row[" & rs("XlRow") & "] has empty data and will not be included in set", False
' WriteLog vbTab + "User Query = '" + strUserQuery + "'", False
' WriteLog vbTab + "Expected Uri = '" + strExpectedUri + "'", False
' rs.Delete
' rs.Update
' ElseIf (strPrevUserQuery = strUserQuery) Then
' If (strPrevExpectedUri = strExpectedUri) Then
' WriteLog "Warning Row[" & rs("XlRow") & "] is a duplicate and will not be included in set", False
' WriteLog vbTab + "User Query = '" + strUserQuery + "'", False
' WriteLog vbTab + "Expected Uri = '" + strExpectedUri + "'", False
' rs.Delete
' rs.Update
' Else
' strPrevExpectedUri = strExpectedUri
' End If
' Else
' ' strPrevUserQuery <> strUserQuery
' strPrevUserQuery = strUserQuery
' strPrevExpectedUri = strExpectedUri
' End If
' rs.MoveNext
' Loop
'
' ' BUGBUG: This step should be unneeded, but due to the fact that I already coded
' ' the validation using the above sort, I simply re-sort. So
' ' the validation above should be reauthored for this order.
' ' Now we need Re-sort the Recordset based on URI and User Query.
' rs.Sort = "[Expected Uri],[User Query]"
' rs.MoveFirst
Common_Exit:
End Sub
Private Function GetXmlFile(ByVal strFile As String) As DOMDocument
Set GetXmlFile = Nothing
Dim oDomDoc As DOMDocument: Set oDomDoc = New DOMDocument
oDomDoc.async = False
oDomDoc.Load strFile
If (oDomDoc.parseError <> 0) Then
p_DisplayParseError oDomDoc.parseError
GoTo Common_Exit
End If
Set GetXmlFile = oDomDoc
Common_Exit:
End Function
'============= Utilities =============
Private Sub p_DisplayParseError( _
ByRef i_ParseError As IXMLDOMParseError _
)
Dim strError As String
strError = "Error: " & i_ParseError.reason & _
"Line: " & i_ParseError.Line & vbCrLf & _
"Linepos: " & i_ParseError.linepos & vbCrLf & _
"srcText: " & i_ParseError.srcText
MsgBox strError, vbOKOnly, "Error while parsing"
End Sub
|
<gh_stars>10-100
'Copyright (c)<2000>Microsoft Corporation. All rights reserved.
Dim WshShell
Dim te
Set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
WshShell.RegDelete "HKLM\Software\Microsoft\ServerAppliance\ElementManager\WebElementDefinitions\TabsMaintenanceAlertEmail\"
WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_Task\SetAlertEmail\"
WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\ServerAppliance\AlertEmail\"
WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\ServerAppliance\ElementManager\WebElementDefinitions\AlertDefinitionsMSSAKitComm4C00000B\"
WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\ServerAppliance\ElementManager\WebElementDefinitions\AlertDefinitionsMSSAKitComm4C00000BUA\"
'END
On Error Resume Next
te = WshShell.RegRead("HKLM\Software\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_TASK\ApplianceInitializationTask\TaskExecutables")
'Remove alloccurances of SetChimeSettings incase there are more
te = Replace(te," Setalertemail.alertemail.1"," ",1,-1,1)
WshShell.RegWrite "HKLM\Software\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_TASK\ApplianceInitializationTask\TaskExecutables",te
|
<filename>Task/Sorting-algorithms-Gnome-sort/VBScript/sorting-algorithms-gnome-sort-2.vb
dim a
dim b
a = array( "zanzibar", "aardvark","ampicillin","zulu","gogodala", "wolverhampton")
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( 234,567,345,568,2345,89,547,23,649,5769,456,456,567)
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( true, false, true, true, false, false, true, false)
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( 1,2,2,4,67789,-3,-45.99)
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( now(), now()-1,now()+2)
b = gnomeSort( a )
wscript.echo join(a, ", ")
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
Attribute VB_Name = "Strings"
Option Explicit
Public Function XmlText( _
ByVal i_str As String _
) As String
Dim intIndex As Long
Dim intLength As Long
Dim strChar As String
Dim str As String
str = RemoveExtraSpaces(i_str)
intLength = Len(str)
XmlText = ""
For intIndex = 1 To intLength
strChar = Mid$(str, intIndex, 1)
Select Case strChar
Case Is = "<"
XmlText = XmlText & "<"
Case Is = ">"
XmlText = XmlText & ">"
Case Is = "&"
XmlText = XmlText & "&"
Case Is = "'"
XmlText = XmlText & "'"
Case Is = """"
XmlText = XmlText & """
Case Else
XmlText = XmlText & strChar
End Select
Next
End Function
Public Function RemoveExtraSpaces( _
ByVal i_strText As String _
) As String
Dim arrStr() As String
Dim intIndex As Long
RemoveExtraSpaces = ""
arrStr = Split(i_strText)
For intIndex = LBound(arrStr) To UBound(arrStr)
If (arrStr(intIndex) <> "") Then
If (RemoveExtraSpaces = "") Then
RemoveExtraSpaces = RemoveExtraSpaces & arrStr(intIndex)
Else
RemoveExtraSpaces = RemoveExtraSpaces & " " & arrStr(intIndex)
End If
End If
Next
End Function
Public Function RemoveCRLF( _
ByVal i_strText As String _
) As String
Dim intIndex As Long
Dim strCurrentChar As String
RemoveCRLF = ""
For intIndex = 1 To Len(i_strText)
strCurrentChar = Mid$(i_strText, intIndex, 1)
If ((strCurrentChar = vbCr) Or (strCurrentChar = vbLf)) Then
' Ignore this char
Else
RemoveCRLF = RemoveCRLF & strCurrentChar
End If
Next
End Function
Public Function ChangeBackSlashToSlash( _
ByVal i_str As String _
) As String
Dim intIndex As Long
Dim str As String
str = i_str
For intIndex = 1 To Len(str)
If (Mid$(str, intIndex, 1) = "\") Then
str = Mid$(str, 1, intIndex - 1) & "/" & Mid$(str, intIndex + 1)
End If
Next
ChangeBackSlashToSlash = str
End Function
Private Function p_IsSpecialChar( _
ByVal i_chr As String _
) As Boolean
Select Case i_chr
Case " ", vbTab, "/", "\"
p_IsSpecialChar = True
Case Else
p_IsSpecialChar = XMLSpecialCharacter(i_chr)
End Select
End Function
' HHTs: Create an ENTRY from a string.
Public Function Mangle( _
ByVal i_strName _
) As String
Dim intIndex As Long
Dim chr As String
Mangle = ""
For intIndex = 1 To Len(i_strName)
chr = Mid$(i_strName, intIndex, 1)
Mangle = Mangle & IIf(p_IsSpecialChar(chr), "_", chr)
Next
End Function
|
<reponame>f110/wing<gh_stars>1-10
' This is not a label:
REM This is not a label:
repeat:
PRINT "Going 'round again"
GOTO repeat
END
|
Option Explicit
Sub Main()
Dim i As Variant
For i = 1 To 27
Debug.Print "Factorial(" & i & ")= , recursive : " & Format$(FactRec(i), "#,###") & " - iterative : " & Format$(FactIter(i), "#,####")
Next
End Sub 'Main
Private Function FactRec(n As Variant) As Variant
n = CDec(n)
If n = 1 Then
FactRec = 1#
Else
FactRec = n * FactRec(n - 1)
End If
End Function 'FactRec
Private Function FactIter(n As Variant)
Dim i As Variant, f As Variant
f = 1#
For i = 1# To CDec(n)
f = f * i
Next i
FactIter = f
End Function 'FactIter
|
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmupdate
BorderStyle = 3 'Fixed Dialog
Caption = "edit pop -"
ClientHeight = 4230
ClientLeft = 540
ClientTop = 1590
ClientWidth = 7305
Icon = "popupd.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 4230
ScaleWidth = 7305
ShowInTaskbar = 0 'False
WhatsThisButton = -1 'True
WhatsThisHelp = -1 'True
Begin VB.CommandButton cmbUpclose
Cancel = -1 'True
Caption = "cancel"
Height = 375
Left = 6135
TabIndex = 35
Top = 3780
WhatsThisHelpID = 10040
Width = 1035
End
Begin VB.CommandButton cbupdate
Caption = "ok"
Default = -1 'True
Height = 375
Left = 4890
TabIndex = 34
Top = 3780
WhatsThisHelpID = 10030
Width = 1035
End
Begin TabDlg.SSTab SSTab1
Height = 3570
HelpContextID = 10060
Left = 90
TabIndex = 36
Top = 105
WhatsThisHelpID = 10060
Width = 7095
_ExtentX = 12515
_ExtentY = 6297
_Version = 393216
Style = 1
Tab = 1
TabHeight = 520
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "<NAME> Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
TabCaption(0) = "access"
TabPicture(0) = "popupd.frx":000C
Tab(0).ControlEnabled= 0 'False
Tab(0).Control(0)= "picContainer(0)"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).ControlCount= 1
TabCaption(1) = "set"
TabPicture(1) = "popupd.frx":0028
Tab(1).ControlEnabled= -1 'True
Tab(1).Control(0)= "picContainer(1)"
Tab(1).Control(0).Enabled= 0 'False
Tab(1).ControlCount= 1
TabCaption(2) = "com"
TabPicture(2) = "popupd.frx":0044
Tab(2).ControlEnabled= 0 'False
Tab(2).Control(0)= "picContainer(2)"
Tab(2).Control(0).Enabled= 0 'False
Tab(2).ControlCount= 1
Begin VB.PictureBox picContainer
BorderStyle = 0 'None
Height = 2940
Index = 2
Left = -74835
ScaleHeight = 2940
ScaleWidth = 6690
TabIndex = 33
TabStop = 0 'False
Top = 510
Visible = 0 'False
Width = 6690
Begin VB.TextBox txtcomment
ForeColor = &H00000000&
Height = 2670
Left = 210
MaxLength = 256
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 120
WhatsThisHelpID = 50000
Width = 6330
End
End
Begin VB.PictureBox picContainer
BorderStyle = 0 'None
Height = 3060
Index = 0
Left = -74880
ScaleHeight = 3060
ScaleWidth = 6855
TabIndex = 30
TabStop = 0 'False
Top = 375
Width = 6855
Begin VB.TextBox maskAccNo
Height = 300
Left = 4860
MaxLength = 40
TabIndex = 25
Top = 1995
WhatsThisHelpID = 30050
Width = 1710
End
Begin VB.TextBox maskArea
Height = 300
Left = 1560
MaxLength = 10
TabIndex = 23
Top = 1995
WhatsThisHelpID = 30060
Width = 1290
End
Begin VB.ComboBox dbCmbCty
Height = 315
Left = 1560
Style = 2 'Dropdown List
TabIndex = 19
Top = 750
WhatsThisHelpID = 30020
Width = 3015
End
Begin VB.ComboBox cmbRegion
Height = 315
Left = 1560
Style = 2 'Dropdown List
TabIndex = 21
Top = 1320
WhatsThisHelpID = 30040
Width = 3015
End
Begin VB.TextBox txtid
BackColor = &H8000000F&
ForeColor = &H00000000&
Height = 285
HelpContextID = 3000
Left = 4725
MaxLength = 25
TabIndex = 31
TabStop = 0 'False
Top = 195
Visible = 0 'False
Width = 510
End
Begin VB.TextBox txtcity
ForeColor = &H00000000&
Height = 300
Left = 1545
MaxLength = 30
TabIndex = 17
Top = 180
WhatsThisHelpID = 30010
Width = 3000
End
Begin VB.ComboBox cmbstatus
ForeColor = &H00000000&
Height = 315
ItemData = "popupd.frx":0060
Left = 1560
List = "popupd.frx":0062
Style = 2 'Dropdown List
TabIndex = 27
Top = 2535
WhatsThisHelpID = 30070
Width = 1545
End
Begin VB.Label CountryLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "&Country/ Dependency:"
Height = 495
Left = 45
TabIndex = 18
Top = 720
WhatsThisHelpID = 30020
Width = 1440
End
Begin VB.Label POPLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "&POP name:"
Height = 255
Left = 0
TabIndex = 16
Top = 180
WhatsThisHelpID = 30010
Width = 1455
End
Begin VB.Label RegionLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "&Region:"
Height = 255
Left = 15
TabIndex = 20
Top = 1335
WhatsThisHelpID = 30040
Width = 1440
End
Begin VB.Label AreaLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "&Area code:"
Height = 255
Left = 30
TabIndex = 22
Top = 2055
WhatsThisHelpID = 30060
Width = 1455
End
Begin VB.Label AccessLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "access num"
Height = 255
Left = 3180
TabIndex = 24
Top = 2055
WhatsThisHelpID = 30050
Width = 1590
End
Begin VB.Label StatusLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "status"
Height = 255
Left = 30
TabIndex = 26
Top = 2595
WhatsThisHelpID = 30070
Width = 1440
End
Begin VB.Label Label3
ForeColor = &H000000C0&
Height = 255
Left = 5265
TabIndex = 32
Top = 585
Visible = 0 'False
Width = 855
End
End
Begin VB.PictureBox picContainer
BorderStyle = 0 'None
Height = 3045
Index = 1
Left = 120
ScaleHeight = 3045
ScaleWidth = 6855
TabIndex = 29
TabStop = 0 'False
Top = 435
Visible = 0 'False
Width = 6855
Begin VB.Frame FlagFrame
Caption = "Service settings"
Height = 3015
Left = 165
TabIndex = 15
Top = 0
WhatsThisHelpID = 40030
Width = 2595
Begin VB.CheckBox FlagCheck
Caption = "cust 2"
Height = 255
Index = 7
Left = 225
TabIndex = 8
Top = 2670
WhatsThisHelpID = 40090
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "Sign on"
Height = 255
Index = 0
Left = 240
TabIndex = 1
Top = 255
WhatsThisHelpID = 40040
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "Sign up"
Height = 255
Index = 1
Left = 240
TabIndex = 2
Top = 600
WhatsThisHelpID = 40050
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "Modem"
Height = 255
Index = 2
Left = 240
TabIndex = 4
Top = 1290
WhatsThisHelpID = 40070
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "ISDN"
Height = 255
Index = 3
Left = 240
TabIndex = 5
Top = 1635
WhatsThisHelpID = 40080
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "cust 1"
Height = 255
Index = 4
Left = 225
TabIndex = 7
Top = 2325
WhatsThisHelpID = 40090
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "multi"
Height = 255
Index = 5
Left = 240
TabIndex = 6
Top = 1980
WhatsThisHelpID = 40100
Width = 2280
End
Begin VB.CheckBox FlagCheck
Caption = "surcrg"
Height = 255
Index = 6
Left = 240
TabIndex = 3
Top = 945
WhatsThisHelpID = 40060
Width = 2280
End
End
Begin VB.Frame AnalogFrame
Caption = "Analog speed"
Height = 1590
Left = 3570
TabIndex = 28
Top = 1395
Width = 3135
Begin VB.ComboBox cmbmax
ForeColor = &H00000000&
Height = 315
ItemData = "popupd.frx":0064
Left = 1380
List = "popupd.frx":0080
TabIndex = 14
Top = 1035
WhatsThisHelpID = 40020
Width = 1095
End
Begin VB.ComboBox cmbmin
ForeColor = &H00000000&
Height = 315
ItemData = "popupd.frx":00BC
Left = 1365
List = "popupd.frx":00D8
TabIndex = 12
Top = 525
WhatsThisHelpID = 40010
Width = 1095
End
Begin VB.Label MaxLabel
Alignment = 1 'Right Justify
Caption = "M&ax:"
Height = 255
Left = 105
TabIndex = 13
Top = 1065
WhatsThisHelpID = 40020
Width = 1200
End
Begin VB.Label MinLabel
Alignment = 1 'Right Justify
Caption = "&Min:"
Height = 255
Left = 135
TabIndex = 11
Top = 555
WhatsThisHelpID = 40010
Width = 1155
End
End
Begin VB.TextBox txtscript
ForeColor = &H00000000&
Height = 285
Left = 3525
MaxLength = 50
TabIndex = 10
Top = 630
WhatsThisHelpID = 40000
Width = 3135
End
Begin VB.Label DunLabel
Caption = "&Dial-up networking script:"
Height = 255
Left = 3525
TabIndex = 9
Top = 345
WhatsThisHelpID = 40000
Width = 3165
End
End
End
End
Attribute VB_Name = "frmupdate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public ID As String
Public status As String
Private Sub cbupdate_Click()
'main POP save routine
Dim response As Integer, deltnum As Integer, deltafind As Integer
Dim Message As String, dialogtype As Long, title As String
Dim i As Integer, deltasql As String
Dim m As Integer
Dim v As Long
Dim n As Long
Dim bool As Integer
Dim mydesc As String
ReDim bitvaluearray(10) As bitValues
Dim sqlstm, countryname As String
Dim itmX As ListItem
Dim strTemp As String
Dim strOldPOPName As String
Dim bOutOfService As Boolean
On Error GoTo ErrTrap
If dbCmbCty.Text = "" Then
MsgBox LoadResString(6044)
SSTab1.Tab = 0
dbCmbCty.SetFocus
Exit Sub
ElseIf txtcity.Text = "" Then
MsgBox LoadResString(6045)
SSTab1.Tab = 0
txtcity.SetFocus
Exit Sub
ElseIf maskArea.Text = "" Then
MsgBox LoadResString(6046)
SSTab1.Tab = 0
maskArea.SetFocus
Exit Sub
ElseIf maskAccNo.Text = "" Then
MsgBox LoadResString(6047)
SSTab1.Tab = 0
maskAccNo.SetFocus
Exit Sub
End If
Screen.MousePointer = 11
If GsysDial!AccessNumberId = updateFound Then
result = 0
For m = 0 To 7
Select Case m
Case 0, 2, 3, 5 'handle idosyncrocies of flags
result = result + (2 ^ m) * Abs(FlagCheck(m).Value - 1)
Case Else
result = result + (2 ^ m) * FlagCheck(m).Value
End Select
Next m
bOutOfService = False
If GsysDial!status = "1" And _
cmbstatus.ItemData(cmbstatus.ListIndex) <> "1" Then _
bOutOfService = True
strOldPOPName = GsysDial!CityName
GsysDial.Edit
GsysDial!CityName = txtcity.Text
GsysDial!CountryNumber = dbCmbCty.ItemData(dbCmbCty.ListIndex)
GsysDial!RegionID = cmbRegion.ItemData(cmbRegion.ListIndex)
GsysDial!AreaCode = maskArea.Text
GsysDial!AccessNumber = maskAccNo.Text
GsysDial!status = cmbstatus.ItemData(cmbstatus.ListIndex)
'If Label8.Caption <> "" Then GsysDial!StatusDate = Label8.Caption
If Trim(cmbmin.Text) <> "" Or Val(cmbmin.Text) = 0 Then
GsysDial!MinimumSpeed = Val(cmbmin.Text)
Else
GsysDial!MinimumSpeed = Null
End If
If Trim(cmbmax.Text) <> "" Or Val(cmbmax.Text) = 0 Then
GsysDial!MaximumSpeed = Val(cmbmax.Text)
Else
GsysDial!MaximumSpeed = Null
End If
GsysDial!ScriptID = txtscript.Text
GsysDial!FlipFactor = 0
GsysDial!Flags = result
GsysDial!Comments = txtcomment.Text
GsysDial.Update
If cmbstatus.ItemData(cmbstatus.ListIndex) = "1" Or bOutOfService Then
'insert the delta table
Set GsysDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
If GsysDelta.RecordCount = 0 Then
deltnum = 1
Else
GsysDelta.MoveLast
deltnum = GsysDelta!deltanum
If deltnum > 6 Then
deltnum = deltnum - 1
End If
End If
For i = 1 To deltnum
deltasql = "Select * from delta where DeltaNum = " & i% & _
" AND AccessNumberId = '" & updateFound & "' " & _
" order by DeltaNum"
Set GsysDelta = gsyspb.OpenRecordset(deltasql, dbOpenDynaset)
If Not (GsysDelta.BOF And GsysDelta.EOF) Then
GsysDelta.Edit
Else
GsysDelta.AddNew
GsysDelta!deltanum = i%
GsysDelta!AccessNumberId = updateFound
End If
If Not bOutOfService Then
GsysDelta!CountryNumber = dbCmbCty.ItemData(dbCmbCty.ListIndex)
GsysDelta!AreaCode = maskArea.Text
GsysDelta!AccessNumber = maskAccNo.Text
If Trim(cmbmin.Text) <> "" Or Val(cmbmin.Text) = 0 Then
GsysDelta!MinimumSpeed = Val(cmbmin.Text)
Else
GsysDelta!MinimumSpeed = Null
End If
If Trim(cmbmax.Text) <> "" Or Val(cmbmax.Text) = 0 Then
GsysDelta!MaximumSpeed = Val(cmbmax.Text)
Else
GsysDelta!MaximumSpeed = Null
End If
GsysDelta!RegionID = cmbRegion.ItemData(cmbRegion.ListIndex)
GsysDelta!CityName = txtcity.Text
GsysDelta!ScriptID = txtscript.Text
GsysDelta!Flags = result
GsysDelta.Update
Else ' insert a delete for the pop
GsysDelta!CountryNumber = 0
GsysDelta!AreaCode = 0
GsysDelta!AccessNumber = 0
GsysDelta!MinimumSpeed = 0
GsysDelta!MaximumSpeed = 0
GsysDelta!RegionID = 0
GsysDelta!CityName = "0"
GsysDelta!ScriptID = "0"
GsysDelta!Flags = 0
GsysDelta.Update
End If
Next i%
End If
Me.Hide
frmMain.PopList.Sorted = False
Set itmX = frmMain.PopList.SelectedItem
With itmX
.Text = txtcity.Text
.SubItems(1) = maskArea.Text
.SubItems(2) = maskAccNo.Text
.SubItems(3) = dbCmbCty.Text
.SubItems(4) = cmbRegion.Text
.SubItems(5) = cmbstatus.Text
End With
frmMain.PopList.SelectedItem.EnsureVisible
frmMain.PopList.SetFocus
End If
LogPOPEdit strOldPOPName, GsysDial
GsysDial.Close
GsysDelta.Close
Set GsysDial = Nothing
Set GsysDelta = Nothing
Me.Hide
Unload Me
Screen.MousePointer = 0
On Error GoTo 0
Exit Sub
ErrTrap:
Screen.MousePointer = 0
MsgBox LoadResString(6056) & Chr(13) & Chr(13) & Err.Description, vbExclamation
Exit Sub
'If Err.Number = 3201 Then
' MsgBox "You must select country name, region description before save. Cannot continue.", 48
' Screen.MousePointer = 0
' Exit Sub
'ElseIf Err.Number = 3317 Then
' MsgBox "You must enter the area code and access number."
' Screen.MousePointer = 0
'' Exit Sub
'End If
'Do While GsysDelta.EOF = False
' If GsysDelta!AccessNumberId = updateFound Then
' deltafind = 1
' Exit Do
' Else
' GsysDelta.MoveNext
' End If
'Loop
'GsysDelta!CountryNumber = dbCmbCty.ItemData(dbCmbCty.ListIndex)
'GsysDelta!AreaCode = maskarea.Text
'GsysDelta!AccessNumber = maskaccno.Text
'If Trim(cmbmin.Text) <> "" Or Val(cmbmin.Text) = 0 Then
' GsysDelta!MinimumSpeed = Val(cmbmin.Text)
'Else
' GsysDelta!MinimumSpeed = Null
'End If
'If Trim(cmbmax.Text) <> "" Or Val(cmbmax.Text) = 0 Then
' GsysDelta!MaximumSpeed = Val(cmbmax.Text)
'Else
' GsysDelta!MaximumSpeed = Null
'End If
'GsysDelta!regionID = cmbRegion.ItemData(cmbRegion.ListIndex)
'GsysDelta!CityName = txtcity.Text
'GsysDelta!ScriptID = txtscript.Text
'GsysDelta!Flags = result
'GsysDelta.Update
End Sub
Private Sub cmbmax_KeyPress(KeyAscii As Integer)
KeyAscii = FilterNumberKey(KeyAscii)
End Sub
Private Sub cmbmin_KeyPress(KeyAscii As Integer)
KeyAscii = FilterNumberKey(KeyAscii)
End Sub
'Private Sub cmbstatus_Change()
'If cmbstatus.Text <> "" Then
' Label8.Caption = Date
'Else
' Label8.Caption = ""
'End If
'End Sub
'Private Sub cmbstatus_Click()
' If cmbstatus.Text <> "" Then
' Label8.Caption = Date
' Else
' Label8.Caption = ""
' End If
'End Sub
Private Sub cmbUpclose_Click()
On Error Resume Next
Screen.MousePointer = 11
Me.Hide
Unload Me
GsysDial.Close
GsysDelta.Close
Set GsysDial = Nothing
Set GsysDelta = Nothing
frmMain.PopList.SetFocus
Screen.MousePointer = 0
On Error GoTo 0
End Sub
Private Sub Form_Deactivate()
Unload Me
End Sub
Function LoadPOPRes()
Dim cRef As Integer
On Error GoTo LoadErr
cRef = 4000
Me.Caption = LoadResString(cRef + 59) & " " & gsCurrentPB
SSTab1.TabCaption(0) = LoadResString(cRef + 38)
SSTab1.TabCaption(1) = LoadResString(cRef + 39)
SSTab1.TabCaption(2) = LoadResString(cRef + 45)
POPLabel.Caption = LoadResString(cRef + 46)
CountryLabel.Caption = LoadResString(cRef + 47)
RegionLabel.Caption = LoadResString(cRef + 48)
AreaLabel.Caption = LoadResString(cRef + 49)
AccessLabel.Caption = LoadResString(cRef + 50)
StatusLabel.Caption = LoadResString(cRef + 51)
' status list
With cmbstatus
.AddItem gStatusText(1)
.ItemData(.NewIndex) = 1
.AddItem gStatusText(0)
.ItemData(.NewIndex) = 0
End With
' region list
With cmbRegion
.AddItem gRegionText(0), 0
.ItemData(.NewIndex) = 0
'.AddItem gRegionText(-1), 1
'.ItemData(.NewIndex) = -1
End With
'EditLabel.Caption = LoadResString(cRef + 57)
FlagFrame.Caption = LoadResString(cRef + 52)
dunLabel.Caption = LoadResString(cRef + 53)
analogFrame.Caption = LoadResString(cRef + 54)
MinLabel.Caption = LoadResString(cRef + 55)
MaxLabel.Caption = LoadResString(cRef + 56)
For cRef = 4080 To 4087
FlagCheck(cRef - 4080).Caption = LoadResString(cRef)
Next
cbupdate.Caption = LoadResString(1002)
cmbUpclose.Caption = LoadResString(1003)
' set fonts
SetFonts Me
SSTab1.Font.Charset = gfnt.Charset
SSTab1.Font.Name = gfnt.Name
SSTab1.Font.Size = gfnt.Size
On Error GoTo 0
Exit Function
LoadErr:
Exit Function
End Function
Private Sub Form_KeyPress(KeyAscii As Integer)
CheckChar KeyAscii
End Sub
Private Sub Form_Load()
Dim DBName As Variant
Dim i As Integer
Dim intX, intRegion As Integer
Dim check As Integer
Dim ID As Integer
Dim n As Long
Dim RS As Recordset
Dim bool As Integer
Dim mydesc As String
Dim strTemp As String
ReDim bitvaluearray(31) As bitValues
On Error GoTo LoadErr
Screen.MousePointer = 11
LoadPOPRes
check = 0 'Initialization
Set GsysDial = gsyspb.OpenRecordset("Select * from DialUpPort where AccessNumberId=" & updateFound, dbOpenDynaset)
Set GsysDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
LoadList dbCmbCty, "Country", "CountryName", "CountryNumber"
LoadList cmbRegion, "Region", "regiondesc", "regionid"
ID = updateFound ' check this out - problems dbl clicking a pop
'strTemp = frmMain.PopList.SelectedItem.key
'ID = Val(Right$(strTemp, Len(strTemp) - 4))
If GsysDial.RecordCount <> 0 Then
GsysDial.MoveFirst
'Do While GsysDial.EOF = False
' If GsysDial!AccessNumberId = ID Then
check = 1
' Exit Do
' Else
' GsysDial.MoveNext
' End If
'Loop
End If
If check = 1 Then
txtid.Text = GsysDial!AccessNumberId
Label3.Caption = GsysDial!CountryNumber
maskArea.Text = GsysDial!AreaCode
status = GsysDial!status
'Label8.Caption = GsysDial!StatusDate
Select Case status
Case 0
cmbstatus = gStatusText(status)
Case 1
cmbstatus = gStatusText(status)
Case Else
cmbstatus = ""
'Label8.Caption = ""
End Select
maskAccNo = GsysDial!AccessNumber
If IsNull(GsysDial!MinimumSpeed) Or GsysDial!MinimumSpeed = 0 Then
cmbmin.Text = ""
Else
cmbmin.Text = GsysDial!MinimumSpeed
End If
If IsNull(GsysDial!MaximumSpeed) Or GsysDial!MaximumSpeed = 0 Then
cmbmax.Text = ""
Else
cmbmax.Text = GsysDial!MaximumSpeed
End If
intRegion = GsysDial!RegionID
If intRegion <> 0 Then
For intX = 0 To cmbRegion.ListCount - 1
If cmbRegion.ItemData(intX) = intRegion Then
cmbRegion.ListIndex = intX
End If
Next
Else
cmbRegion.ListIndex = 0
End If
If IsNull(GsysDial!ScriptID) Then
txtscript.Text = ""
Else
txtscript.Text = GsysDial!ScriptID
End If
If IsNull(GsysDial!Comments) Then
txtcomment.Text = ""
Else
txtcomment.Text = GsysDial!Comments
End If
If IsNull(GsysDial!CityName) Then
txtcity.Text = ""
Else
txtcity.Text = GsysDial!CityName
End If
n = GsysDial!Flags
Set RS = gsyspb.OpenRecordset("select * from bitflag order by bit, value")
RS.MoveFirst
While Not RS.EOF
bitvaluearray(RS!Bit).desc(RS!Value) = RS!desc
RS.MoveNext
Wend
For i = 0 To 7
bool = isBitSet(n, i)
mydesc = bitvaluearray(i).desc(bool)
'handle the oddities that i introduced with the old
' list format, i.e. some flags are NOT by default.
Select Case i
Case 0, 2, 3, 5
FlagCheck(i).Value = Abs(bool - 1)
Case Else
FlagCheck(i).Value = bool
End Select
Next i
End If
If check = 0 Then
Screen.MousePointer = 0
Exit Sub
End If
SSTab1.Tab = 0
CenterForm Me, Screen
Screen.MousePointer = 0
Exit Sub
LoadErr:
Exit Sub
End Sub
Private Sub LoadList(list As Control, sTableName As String, sName As String, sID As String)
Dim RS As Recordset
'list.Clear
Set RS = gsyspb.OpenRecordset("SELECT " & sName & "," & sID & " FROM " & sTableName & " order by " & sName)
While Not RS.EOF
list.AddItem RS(sName)
list.ItemData(list.NewIndex) = RS(sID)
RS.MoveNext
Wend
RS.Close
End Sub
Private Sub Label3_Change()
Dim temp
Dim sqlstm As String
Dim countryid As Long
If Label3.Caption <> "" Then
countryid = Val(Label3.Caption)
sqlstm = "Select CountryName from Country where CountryNumber = " & countryid
Set temp = gsyspb.OpenRecordset(sqlstm, dbOpenSnapshot)
dbCmbCty.Text = temp!countryname
End If
End Sub
Private Sub maskaccno_GotFocus()
SelectText maskAccNo
End Sub
Private Sub maskaccno_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
'0-9 A-Z a-z * # Bkspc Hyphen Space ctrl-C ctrl-V
Case 48 To 57, 65 To 90, 97 To 122, 42, 35, 8, 45, 32, 3, 22
Case Else
KeyAscii = 0
Beep
End Select
End Sub
Private Sub maskarea_GotFocus()
SelectText maskArea
End Sub
Private Sub maskarea_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
'0-9 A-Z a-z * # Bkspc Hyphen Space ctrl-C ctrl-V
Case 48 To 57, 65 To 90, 97 To 122, 42, 35, 8, 45, 32, 3, 22
Case Else
KeyAscii = 0
Beep
End Select
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
picContainer(PreviousTab).Visible = False
picContainer(SSTab1.Tab).Visible = True
End Sub
Private Sub txtcity_GotFocus()
SelectText txtcity
End Sub
Private Sub txtcity_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 44
KeyAscii = 0
Beep
End Select
End Sub
Private Sub txtid_KeyDown(KeyCode As Integer, Shift As Integer)
KeyCode = 0
End Sub
Private Sub txtid_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub txtscript_GotFocus()
SelectText txtscript
End Sub
Private Sub txtscript_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 44
KeyAscii = 0
Beep
End Select
End Sub
|
<gh_stars>1-10
Sub write_event(event_type,msg)
Set objShell = CreateObject("WScript.Shell")
Select Case event_type
Case "SUCCESS"
n = 0
Case "ERROR"
n = 1
Case "WARNING"
n = 2
Case "INFORMATION"
n = 4
Case "AUDIT_SUCCESS"
n = 8
Case "AUDIT_FAILURE"
n = 16
End Select
objShell.LogEvent n, msg
Set objShell = Nothing
End Sub
Call write_event("INFORMATION","This is a test information.")
|
Set objNetwork = CreateObject("WScript.Network")
WScript.Echo objNetwork.ComputerName
|
Option Base 1
Private Function mean_angle(angles As Variant) As Double
Dim sins() As Double, coss() As Double
ReDim sins(UBound(angles))
ReDim coss(UBound(angles))
For i = LBound(angles) To UBound(angles)
sins(i) = Sin(WorksheetFunction.Radians(angles(i)))
coss(i) = Cos(WorksheetFunction.Radians(angles(i)))
Next i
mean_angle = WorksheetFunction.Degrees( _
WorksheetFunction.Atan2( _
WorksheetFunction.sum(coss), _
WorksheetFunction.sum(sins)))
End Function
Public Sub main()
Debug.Print Format(mean_angle([{350,10}]), "##0")
Debug.Print Format(mean_angle([{90, 180, 270, 360}]), "##0")
Debug.Print Format(mean_angle([{10, 20, 30}]), "##0")
End Sub
|
<gh_stars>1-10
arr = Array(-7,1,5,2,-4,3,0)
WScript.StdOut.Write equilibrium(arr,UBound(arr))
WScript.StdOut.WriteLine
Function equilibrium(arr,n)
sum = 0
leftsum = 0
'find the sum of the whole array
For i = 0 To UBound(arr)
sum = sum + arr(i)
Next
For i = 0 To UBound(arr)
sum = sum - arr(i)
If leftsum = sum Then
equilibrium = equilibrium & i & ", "
End If
leftsum = leftsum + arr(i)
Next
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData
Private Sub optional_parameters(theRange As String, _
Optional ordering As Integer = 0, _
Optional column As Integer = 1, _
Optional reverse As Integer = 1)
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add _
Key:=Range(theRange).Columns(column), _
SortOn:=SortOnValues, _
Order:=reverse, _
DataOption:=ordering 'the optional parameter ordering and above reverse
With ActiveSheet.Sort
.SetRange Range(theRange)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Public Sub main()
'Sort the strings in the active sheet in Excel
'Supply the range of cells to be sorted
'Optionally specify ordering, default is 0,
'which is normal sort, text and data separately;
'ordering:=1 treats text as numeric data.
'Optionally specify column number, default is 1
'Optionally specify reverse, default is 1
'which sorts in ascending order.
'Specifying reverse:=2 will sort in descending order.
optional_parameters theRange:="A1:C4", ordering:=1, column:=2, reverse:=1
End Sub
|
<filename>Task/Integer-comparison/VBA/integer-comparison.vba
Public Sub integer_comparison()
first_integer = CInt(InputBox("Give me an integer."))
second_integer = CInt(InputBox("Give me another integer."))
Debug.Print IIf(first_integer < second_integer, "first integer is smaller than second integer", "first integer is not smaller than second integer")
Debug.Print IIf(first_integer = second_integer, "first integer is equal to second integer", "first integer is not equal to second integer")
Debug.Print IIf(first_integer > second_integer, "first integer is bigger than second integer", "first integer is not bigger than second integer")
End Sub
|
Public Sub mean_time()
Dim angles() As Double
s = [{"23:00:17","23:40:20","00:12:45","00:17:19"}]
For i = 1 To UBound(s)
s(i) = 360 * TimeValue(s(i))
Next i
Debug.Print Format(mean_angle(s) / 360 + 1, "hh:mm:ss")
End Sub
|
10 PRINT COS(2)
20 PRINT ATN(2)
30 PRINT LOG(2)
40 PRINT SIN(2)
50 PRINT TAN(2)
60 PRINT SQR(2)
70 PRINT ABS(2)
80 PRINT RND(100)
90 PRINT INT(12.2)
|
<reponame>npocmaka/Windows-Server-2003<filename>enduser/sakit/sak/setup/misc/createwebsite.vbs
'
' createwebsite.vbs: Configure IIS Websites for the SAK
'
' Copyright (c) 2002 Microsoft Corporation
'
'Constants
const NS_IIS = "IIS://"
const ADMIN_ID = 1
const SHARES_ID = 2
const ADMIN_SITE_NAME = "Administration"
const SHARES_SITE_NAME = "Shares"
const ADS_PROPERTY_UPDATE = 2
'registry keys
const REGKEY_WEBFRAMEWORK = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerAppliance\WebFramework\"
const CONST_TYPE_DWORD ="REG_DWORD"
'This array is messy, but a necessary evil. If a file is added to the Shares site, at it here
Dim arrSharesFiles(95)
arrSharesFiles(0) = "autoconfiglang.asp"
arrSharesFiles(1) = "inc_accountsgroups.asp"
arrSharesFiles(2) = "inc_base.asp"
arrSharesFiles(3) = "inc_debug.asp"
arrSharesFiles(4) = "inc_errorcode.asp"
arrSharesFiles(5) = "inc_framework.asp"
arrSharesFiles(6) = "inc_global.asp"
arrSharesFiles(7) = "inc_global.js"
arrSharesFiles(8) = "inc_pagekey.asp"
arrSharesFiles(9) = "inc_registry.asp"
arrSharesFiles(10) = "ots_taskview.js"
arrSharesFiles(11) = "sh_alertdetails.asp"
arrSharesFiles(12) = "sh_alertpanel.asp"
arrSharesFiles(13) = "sh_defaultfooter.asp"
arrSharesFiles(14) = "sh_fileupload.asp"
arrSharesFiles(15) = "sh_page.asp"
arrSharesFiles(16) = "sh_page.js"
arrSharesFiles(17) = "sh_propfooter.asp"
arrSharesFiles(18) = "sh_resourcepanel.asp"
arrSharesFiles(19) = "sh_restarting.asp"
arrSharesFiles(20) = "sh_statusbar.asp"
arrSharesFiles(21) = "sh_statusdetails.asp"
arrSharesFiles(22) = "sh_task.asp"
arrSharesFiles(23) = "sh_task.js"
arrSharesFiles(24) = "sh_taskframes.asp"
arrSharesFiles(25) = "sh_tasks.asp"
arrSharesFiles(26) = "sh_tree.asp"
arrSharesFiles(27) = "sh_wizardfooter.asp"
arrSharesFiles(28) = "style\mssastyles.css"
arrSharesFiles(29) = "images\aboutbox_logo.gif"
arrSharesFiles(30) = "images\alert.gif"
arrSharesFiles(31) = "images\AlertEmailX32.gif"
arrSharesFiles(32) = "images\alert_white.gif"
arrSharesFiles(33) = "images\arrow_green.gif"
arrSharesFiles(34) = "images\arrow_red.gif"
arrSharesFiles(35) = "images\arrow_silver.gif"
arrSharesFiles(36) = "images\arrow_yellow.gif"
arrSharesFiles(37) = "images\BackupX32.gif"
arrSharesFiles(38) = "images\book_closed.gif"
arrSharesFiles(39) = "images\book_opened.gif"
arrSharesFiles(40) = "images\book_page.gif"
arrSharesFiles(41) = "images\butGreenArrow.gif"
arrSharesFiles(42) = "images\butGreenArrowDisabled.gif"
arrSharesFiles(43) = "images\butGreenArrowLeft.gif"
arrSharesFiles(44) = "images\butGreenArrowLeftDisabled.gif"
arrSharesFiles(45) = "images\butPageNextDisabled.gif"
arrSharesFiles(46) = "images\butPageNextEnabled.gif"
arrSharesFiles(47) = "images\butPagePreviousDisabled.gif"
arrSharesFiles(48) = "images\butPagePreviousEnabled.gif"
arrSharesFiles(49) = "images\butRedX.gif"
arrSharesFiles(50) = "images\butRedXDisabled.gif"
arrSharesFiles(51) = "images\butSearchDisabled.gif"
arrSharesFiles(52) = "images\butSearchEnabled.gif"
arrSharesFiles(53) = "images\butSortAscending.gif"
arrSharesFiles(54) = "images\butSortDescending.gif"
arrSharesFiles(55) = "images\CommunityX32.gif"
arrSharesFiles(56) = "images\configure_32x32.gif"
arrSharesFiles(57) = "images\critical_error.gif"
arrSharesFiles(58) = "images\critical_errorX32.gif"
arrSharesFiles(59) = "images\DateTimeX32.gif"
arrSharesFiles(60) = "images\datetime_icon.gif"
arrSharesFiles(61) = "images\dir.gif"
arrSharesFiles(62) = "images\disks.gif"
arrSharesFiles(63) = "images\disks_32x32.gif"
arrSharesFiles(64) = "images\down.gif"
arrSharesFiles(65) = "images\drive.gif"
arrSharesFiles(66) = "images\EventLogX32.gif"
arrSharesFiles(67) = "images\example_logo.gif"
arrSharesFiles(68) = "images\file.gif"
arrSharesFiles(69) = "images\folder.gif"
arrSharesFiles(70) = "images\folder_32x32.gif"
arrSharesFiles(71) = "images\green_arrow.gif"
arrSharesFiles(72) = "images\help_32x32.gif"
arrSharesFiles(73) = "images\information.gif"
arrSharesFiles(74) = "images\maintenance.gif"
arrSharesFiles(75) = "images\maintenance_32x32.gif"
arrSharesFiles(76) = "images\network.gif"
arrSharesFiles(77) = "images\network_32x32.gif"
arrSharesFiles(78) = "images\node_close.gif"
arrSharesFiles(79) = "images\node_open.gif"
arrSharesFiles(80) = "images\oem_logo.gif"
arrSharesFiles(81) = "images\OpenFolderX16.gif"
arrSharesFiles(82) = "images\server.gif"
arrSharesFiles(83) = "images\services.gif"
arrSharesFiles(84) = "images\services_32x32.gif"
arrSharesFiles(85) = "images\ShutdownX32.gif"
arrSharesFiles(86) = "images\SoftwareUpdateX32.gif"
arrSharesFiles(87) = "images\StatusBarBreak.gif"
arrSharesFiles(88) = "images\TabSeparator.gif"
arrSharesFiles(89) = "images\TerminalServiceX32.gif"
arrSharesFiles(90) = "images\up.gif"
arrSharesFiles(91) = "images\updir.gif"
arrSharesFiles(92) = "images\users.gif"
arrSharesFiles(93) = "images\users_32x32.gif"
arrSharesFiles(94) = "images\winnte_logo.gif"
arrSharesFiles(95) = "images\WinPwr_h_R.gif"
Function CreateAdminSite
Call CreateWebsite(ADMIN_ID)
End Function
Function CreateSharesSite
Call CreateWebsite(SHARES_ID)
End Function
Function CreateWebsite(nType)
On Error Resume Next
Dim strSystemDir
Dim strSystemDrive
Set WshShell = CreateObject("WScript.Shell")
strSystemDrive = WshShell.ExpandEnvironmentStrings("%SystemDrive%")
Set objEnv = WshShell.Environment("Process")
if (nType = ADMIN_ID) then
Call CreateWebSrv( "localhost", ":8099:", ":8098:", ADMIN_SITE_NAME, objEnv("SYSTEMROOT") + "\system32\serverappliance\web", ADMIN_ID)
Call WriteAdminServerRegistryEntries(WshShell)
elseif (nType = SHARES_ID) then
strSharesDir = GetSharesDirectory()
' Copy the files for the Shares site
Call CopyFiles(strSharesDir)
' Create the website
Call CreateWebSrv( "localhost", ":80:", ":443:", SHARES_SITE_NAME, strSharesDir, SHARES_ID)
else
'Wscript.echo "Bad argument: " & nType
end if
Call UpdateMimeMap(nType)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function WriteAdminServerRegistryEntries
'
' Description:
' Writes the entries to the registry that will be used for the
' Administration web site ports
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function WriteAdminServerRegistryEntries(WshShell)
On Error Resume Next
WshShell.RegWrite REGKEY_WEBFRAMEWORK & "AdminPort", 8099, CONST_TYPE_DWORD
WshShell.RegWrite REGKEY_WEBFRAMEWORK & "SSLAdminPort", 8098, CONST_TYPE_DWORD
If Err.Number <> 0 Then
Err.Clear
End If
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function CreateTSWebVirtualDir
'
' Description:
' Create a virtual directory for Terminal Server named 'tsweb' at
' %system32%\serverappliance\web\admin\tsweb
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CreateTSWebVirtualDir(oAdminWebRoot, strWebDir)
On Error Resume Next
Set oTSWebDir = oAdminWebRoot.Create("IIsWebVirtualDir", "tsweb")
Set WshShell = CreateObject("WScript.Shell")
oTSWebDir.Path = strWebDir & "\admin\tsweb\"
oTSWebDir.AccessRead = True
oTSWebDir.AccessWrite = False
oTSWebDir.AccessExecute = False
oTSWebDir.AccessScript = False
oTSWebDir.EnableDefaultDoc = False
oTSWebDir.ContentIndexed = False
oTSWebDir.SetInfo
Set oTSWebDir = Nothing
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function CreateWebSrv
'
' Parameters:
' sHost The name of the host of the server (ie. localhost)
' sServerBinding The port for non-secure connections
' sSecureBinding The SSL port
' sWebSrvName Name of the web site to be created (set as the ServerComment property)
' sPath Physical path to the root of the web site
' siteType ADMIN_ID or SHARES_ID
'
' Description:
' Creates a website and sets the properties on the site according
' to what is necessary for Administration or Shares sites. There are
' small differences between settings on the sites. For example,
' SHARES_ID has a number of differences between the Administration sites.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CreateWebSrv(sHost , sServerBinding , sSecureBinding, sWebSrvName , sPath, siteType)
On Error Resume Next
g_sErrInfo = ""
g_bCancel = False
'Wscript.echo "Creating " & sWebSrvName & " website at " & sPath
Dim oWebSvc , oWebSrv , oWebRoot , oFs , iWebSrvNum , asServerBindings
Dim strWebSiteRegValue : strWebSiteRegValue = REGKEY_WEBFRAMEWORK & sWebSrvName & "SiteID"
asServerBindings = Array(0)
asServerBindings(0) = sServerBinding
If (sHost = "" Or asServerBindings(0) = "" Or sWebSrvName = "") Then
g_sErrInfo = "A required parameter was passed incorrectly."
CreateWebSrv = 1
Exit Function
End If
'
' Check to see if the website already exists
'
Set WshShell = CreateObject("WScript.Shell")
nSiteID = WshShell.RegRead(strWebSiteRegValue)
If (nSiteID <> 0) Then
Set oWebSite = GetObject(NS_IIS & sHost & "/w3svc/" & nSiteID)
If Err.number = 0 Then
'The website already exists
Exit Function
End If
Err.Clear
End If
Set oWebSvc = GetObject(NS_IIS & sHost & "/w3svc")
'Get the next available Web server name [number]
iWebSrvNum = GetNextWebSrvNum(sHost)
'Create the web site
Set oWebSrv = oWebSvc.Create("IIsWebServer", CStr(iWebSrvNum))
If Err.Number <> 0 Then
'wscript.echo "Error creating website " & sWebSrvName & " at " & iWebSrvNum
Exit Function
End If
'
' Set the settings for the new web site
'
oWebSrv.ServerSize = 1 '// fewer than 100k Or medium sized server
'// Should I do this for the Admin sites??
' Set the non-secure port binding
oWebSrv.ServerBindings = sServerBinding
' Set the SSL Port
oWebSrv.SecureBindings = sSecureBinding
' Require the SSL Port
oWebSrv.AccessSSL = True
' Other web site settings
oWebSrv.AspEnableParentPaths = False
oWebSrv.AspScriptLanguage = "VBScript"
oWebSrv.DefaultDoc = "Default.asp"
oWebSrv.ServerComment = sWebSrvName
oWebSrv.AuthAnonymous = False
If siteType = SHARES_ID Then
oWebSrv.AuthBasic = False
oWebSrv.AuthNTLM = True
Else
oWebSrv.AuthBasic = True
oWebSrv.AuthNTLM = False
End If
oWebSrv.SetInfo
'// Ensure physical Path exists
Set oFs = CreateObject("Scripting.FileSystemObject")
If Not (oFs.FolderExists(sPath)) Then
Call oFs.CreateFolder(sPath)
End If
Set oWebRoot = oWebSrv.Create("IIsWebVirtualDir", "Root")
oWebRoot.Path = sPath
Set oFs = Nothing
oWebRoot.AccessRead = True
If (siteType = SHARES_ID) Then
oWebRoot.AccessWrite = True
Else
oWebRoot.AccessWrite = False
End If
oWebRoot.AccessExecute = False
oWebRoot.AccessScript = True
oWebRoot.AppCreate (True)
oWebRoot.AppFriendlyName = "Default Application"
oWebRoot.SetInfo
'
' If we're creating the Administration site, make the necessary
' adjustments to enable ASP globally
' and create a virtual dir for tsweb
'
If (siteType = ADMIN_ID) Then
Call EnableASPForAllSites(sHost, WshShell)
Call CreateTSWebVirtualDir(oWebRoot, sPath)
End If
Set oWebRoot = Nothing
Set oWebSrv = Nothing
Set oWebSvc = Nothing
CreateWebSrv = iWebSrvNum
Call WshShell.RegWrite(strWebSiteRegValue, iWebSrvNum, CONST_TYPE_DWORD)
Exit Function
ErrorHandler:
g_sErrInfo = Err.Number - vbObjectError & ", " & Err.Description & ", " & Err.LastDllError
CreateWebSrv = 1
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function EnableASPForAllSites
'
' Parameters:
' sHost The name of the host of the server (ie. localhost)
' WshShell Shell object
'
' Description:
' Add Remote Admin Tools to the list of Applications that use ASP
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function EnableASPForAllSites(sHost, WshShell)
On Error Resume Next
strProduct = Session.Property("CustomActionData")
Set IIS = GetObject(NS_IIS & sHost & "/w3svc")
'
' Detect if asp is currently in the list of ISAPIs
'
Dim bFound : bFound = False
'Search for Remote Admin Tools in ApplicationDependencies
appDepend = IIS.ApplicationDependencies
For i=0 To UBound(appDepend)
If instr(1,appDepend(i),strProduct) > 0 Then
'ASP was already added to Remote Admin Tools
bFound = True
Exit For
End If
Next
'If Remote Admin Tools wasn't found in the dependencies on ASP, add it
If Not bFound Then
' Add ASP as a dependency for Remote Admin Tools
ReDim Preserve appDepend(UBound(appDepend)+1)
appDepend(UBound(appDepend)) = strProduct & ";ASP"
'Save the entry back to the metabase
IIS.ApplicationDependencies = appDepend
IIS.SetInfo
End If
'Now modify asp.dll to be allowed in WebSvcExtRestrictionList
webExt = IIS.WebSvcExtRestrictionList
strTurnedOn = "0"
For i=0 To UBound(webExt)
If instr(1,webExt(i),"asp.dll") > 0 Then
If Left(webExt(i), 1) = "1" Then
'It's already on!
Exit For
End If
'ASP was already added to Remote Admin Tools
webExt(i) = "1" & Right(webExt(i), Len(webExt(i))-1)
'Set the new Restriction list with ASP turned on
IIS.WebSvcExtRestrictionList = webExt
IIS.SetInfo
strTurnedOn = "1"
Exit For
End If
Next
Dim strTurnAspOn : strTurnAspOn = REGKEY_WEBFRAMEWORK & "ASPWasEnabled"
Call WshShell.RegWrite(strTurnAspOn, strTurnedOn)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function DisableASPForAllSites
'
' Parameters:
' sHost The name of the host of the server (ie. localhost)
'
' Description:
' Remove Remote Admin Tools from the list of Applications that use ASP
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DisableASPForAllSites(sHost)
On Error Resume Next
strProduct = Session.Property("CustomActionData")
Set IIS = GetObject(NS_IIS & sHost & "/w3svc")
'
' Remove Remote Admin Tools from list of dependencies on ASP
'
Dim bFound : bFound = False
'Search for Remote Admin Tools in ApplicationDependencies
appDepend = IIS.ApplicationDependencies
For i=0 To UBound(appDepend)
If instr(1,appDepend(i),strProduct) > 0 Then
'Removing ASP dependency on Remote Admin Tools
appDepend(i) = appDepend(UBound(appDepend))
ReDim Preserve appDepend(UBound(appDepend)-1)
IIS.ApplicationDependencies = appDepend
IIS.SetInfo
Exit For
End If
Next
'If we turned on ASP during install, turn it back off
Dim strTurnAspOn : strTurnAspOn = REGKEY_WEBFRAMEWORK & "ASPWasEnabled"
Set WshShell = CreateObject ("WScript.Shell")
If WshShell.RegRead(strTurnAspOn) = "1" Then
'Search for ASP in WebSvcExtRestrictionList and turn it off
webExt = IIS.WebSvcExtRestrictionList
For i=0 To UBound(webExt)
If instr(1,webExt(i),"asp.dll") > 0 Then
If Left(webExt(i), 1) = "0" Then
'It's already off!
Exit For
End If
webExt(i) = "0" & Right(webExt(i), Len(webExt(i))-1)
'Set the new Restriction list with ASP turned off
IIS.WebSvcExtRestrictionList = webExt
IIS.SetInfo
Exit For
End If
Next
End If
WshShell.RegDelete(strTurnAspOn)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function GetNextWebSrvNum
'
' Parameters:
' sHost Localhost
'
' Description:
' Searches for an available web site name, which will be of
' the form IIS://localhost/w3svc/1
' If 0 is returned, there was an error.
' It starts with a random number and increments it until it
' finds an available site
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetNextWebSrvNum( sHost )
On Error Resume Next
If (sHost = "") Then
'g_sErrInfo = "A required parameter was passed incorrectly."
GetNextWebSrvNum = 0
Exit Function
End If
Dim oWebSrv , iWebSrvNum, bContinue
'Start with a random site ID between 1 and 32000
' (The limiting number isn't really 32000, but we just need a big range)
Randomize
iWebSrvNum = CLng(32000 * Rnd + 1)
bContinue = True
'
'Try different site IDs until one is available
' (It is highly likely to succeed on the first try)
'
While bContinue
Set oWebSrv = GetObject(NS_IIS & sHost & "/w3svc/" & iWebSrvNum)
If Err.number <> 0 Then
Err.Clear
bContinue = False
Else
iWebSrvNum = iWebSrvNum + 1
End If
WEnd
GetNextWebSrvNum = iWebSrvNum
'WScript.Echo "Site number: " & GetNextWebSrvNum
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function GetSharesDirectory
'
' Description:
' Determines where the directory for the Shares web site will be
' ie. C:\SAShares
' It searches for the first available NTFS drive that is not the system
' drive. If there is not a drive besides the system drive, it will
' use the system drive.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetSharesDirectory
On Error Resume Next
Dim WshShell, strSystemDrive
Set WshShell = CreateObject("WScript.Shell")
strWindowsDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
GetSharesDirectory = strWindowsDir & "\system32\ServerAppliance\SAShares"
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function CopyFiles
'
' Description:
' This function copies the Shares Site files from the ServerAppliance
' Directory to the %systemdrive%\inetpub directory
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CopyFiles(strTargetPath)
On Error Resume Next
Set oShell = CreateObject ("WScript.shell")
Set objEnv = oShell.Environment("Process")
strWebDir = objEnv("SYSTEMROOT") + "\system32\ServerAppliance\Web\Admin"
'The SAShares folder is created by the CreateFolder table and the ACLs are set
' to Administrators only, so we need to add User read/execute access
Call AddUserReadACL(strTargetPath)
Call oShell.Run("cmd.exe /C Mkdir " & strTargetPath & "\style",0, TRUE)
Call oShell.Run("cmd.exe /C Mkdir " & strTargetPath & "\images",0, TRUE)
strCopyCmd = "cmd.exe /C Copy " & strWebDir
For i=0 To UBound(arrSharesFiles)
Call oShell.Run(strCopyCmd & "\" & arrSharesFiles(i) & " " & strTargetPath & "\" & arrSharesFiles(i), 0, True)
Next
Call oShell.Run(strCopyCmd & "\Shares\sharessite.asp " & strTargetPath & "\default.asp",0, TRUE)
Set oShell = Nothing
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' The administration web site needs to be deleted when the SAK is uninstalled.
' During uninstallation, all of the files at \winnt\system32\serverappliance\web
' directory are deleted, which is where the admin site points to. Therefore,
' there wouldn't be anything left for this web site to contain. Otherwise,
' an error would appear if the user went to the admin site in the IIS MMC snapin.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DeleteAdminSite()
On Error Resume Next
DeleteSite(ADMIN_SITE_NAME)
Call DisableASPForAllSites("localhost")
End Function
Function DeleteSharesSite()
On Error Resume Next
If DeleteSite(SHARES_SITE_NAME) Then
'If the Shares site was found and deleted, then delete the corresponding files
Set oShell = CreateObject ("WScript.Shell")
strSharesDir = GetSharesDirectory()
strDeleteCmd = "cmd.exe /C del " & strSharesDir & "\"
For i=0 To UBound(arrSharesFiles)
Call oShell.Run(strDeleteCmd & arrSharesFiles(i), 0, True)
Next
Call oShell.Run(strDeleteCmd & "\default.asp",0, TRUE)
Call oShell.Run(strDeleteCmd & "\SharesList.txt",0, TRUE)
'Attempt to remove directories will fail if they're not empty
Call oShell.Run("cmd.exe /C rmdir " & strSharesDir & "\style", 0, TRUE)
Call oShell.Run("cmd.exe /C rmdir " & strSharesDir & "\images", 0, TRUE)
End If
End Function
Function StartDefaultSite()
On Error Resume Next
'Restart the default site
Set defaultSite = GetObject("IIS://localhost/w3svc/1")
defaultSite.Start
End Function
Function DeleteSite(strSiteName)
On Error Resume Next
DeleteSite = False
Set WshShell = CreateObject("WScript.Shell")
Set webService = GetObject("IIS://localhost/w3svc")
strWebSiteRegValue = REGKEY_WEBFRAMEWORK & strSiteName & "SiteID"
nSiteID = WshShell.RegRead(strWebSiteRegValue)
WshShell.RegDelete(strWebSiteRegValue)
'wscript.echo "Delete site: " & strSiteName & " at " & nSiteID
If (nSiteID <> 0) Then
Set oWebSite = GetObject(NS_IIS & "localhost/w3svc/" & nSiteID)
If Err.number = 0 Then
'The website exists, so delete it
webService.delete "IIsWebServer", oWebSite.Name
DeleteSite = True
End If
End If
End Function
Function CreateServerIDProperty
On Error Resume Next
'Create new ServerID property in the schema
propName = "ServerID"
'
' Check to see if the property already exists
'
Set prop = GetObject("IIS://localhost/schema/" & propName)
If Err.Number = 0 Then
'wscript.echo "Property already exists: " & propName
else
'wscript.echo "Property doesn't exist: " & propName
'
' If the property doesn't exist, create it
'
Set schemaObj = GetObject("IIS://localhost/schema")
Set newProp = schemaObj.Create("Property", propName)
newProp.Syntax = "String"
newProp.Default = ""
newProp.SetInfo
'Link new property to the IIsWebServer class
'wscript.echo "Link to the IIsWebServer"
Set webServerClass = GetObject("IIS://localhost/schema/IIsWebServer")
Properties = webServerClass.OptionalProperties
ReDim Preserve Properties(UBound(Properties) + 1)
Properties(UBound(Properties)) = propName
webServerClass.OptionalProperties = Properties
webServerClass.SetInfo
'Link new property to the IIsFtpServer class
'wscript.echo "Link to the IIsFtpServer"
Set ftpServerClass = GetObject("IIS://localhost/schema/IIsFtpServer")
Properties = ftpServerClass.OptionalProperties
ReDim Preserve Properties(UBound(Properties) + 1)
Properties(UBound(Properties)) = propName
ftpServerClass.OptionalProperties = Properties
ftpServerClass.SetInfo
'
' Flush the metabase and reload WMI so that this new
' property will appear through WMI calls.
'
'wscript.echo "Flushing the metabase ..."
set compObj = GetObject("IIS://localhost")
compObj.SaveData()
'wscript.echo "Stopping winmgmt..."
Set wShell = CreateObject ("WScript.shell")
wShell.Run "net stop winmgmt /y",0, TRUE
'wscript.echo "Starting winmgmt..."
wShell.Run "net start winmgmt",0, TRUE
End If
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DetectStoppedSites
'
' Description:
' Detects whether the proper sites have been started as part
' of the installation process. In particular, the Administration
' and Shares sites are detected. The results are placed in the
' the registry as a REG_SZ called:
' HKLM\Software\Microsoft\ServerAppliance\WebFramework\StartSiteError
' It is then interpreted as a number, with each bit position
' representing whether a site is started.
' Bit 0 corresponds to the Administration site and
' Bit 1 corresponds to the Shares site.
' The caller of SaSetup.exe is responsible to interpret
' this registry entry and inform the user of errors.
'
' History:
' travisn 23-JUL-2001 Created
' travisn 7-AUG-2001 Comments added
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DetectStoppedSites
On Error Resume Next
'Declare and initialize variables
Dim oWebSrv, badAdminServer, badSharesServer, nAdminSiteID, nSharesSiteID
badAdminServer = 0
badSharesServer = 0
Set WshShell = CreateObject("WScript.Shell")
nAdminSiteID = WshShell.RegRead(REGKEY_WEBFRAMEWORK & ADMIN_SITE_NAME & "SiteID")
nSharesSiteID = WshShell.RegRead(REGKEY_WEBFRAMEWORK & SHARES_SITE_NAME & "SiteID")
If (nAdminSiteID <> 0) Then
Set oWebSrv = GetObject(NS_IIS & "localhost/w3svc/" & nAdminSiteID)
'
' Detect if the ServerState property is one of these 2:
' MD_SERVER_STATE_STOPPING OR MD_SERVER_STATE_STOPPED
'
If ( oWebSrv.ServerState = 3 OR oWebSrv.ServerState = 4) Then
' Admin Site is NOT started. Set the appropriate variable to ON
badAdminServer = 1
End If
End If
If (nSharesSiteID <> 0) Then
Set oWebSrv = GetObject(NS_IIS & "localhost/w3svc/" & nSharesSiteID)
If ( oWebSrv.ServerState = 3 OR oWebSrv.ServerState = 4) Then
' Shares Site is NOT started. Set the appropriate variable to ON
badSharesServer = 1
End If
End If
'
' Convert the stopped site information into a single variable
' with bits representing whether a site is running
' Codes for stoppedSites:
' 1: Admin site is not started
' 2: Shares site is not started
' 3: Both Admin and Shares sites are not started
'
Dim stoppedSites
stoppedSites = 0
If badAdminServer = 1 Then
stoppedSites = stoppedSites + 1
End If
If badSharesServer = 1 Then
stoppedSites = stoppedSites + 2
End If
'Write the value of stoppedSites to the registry
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite REGKEY_WEBFRAMEWORK & "StartSiteError", stoppedSites
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ShowAdminSiteError
Call ShowSiteError(ADMIN_ID)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ShowSharesSiteError
Call ShowSiteError(SHARES_ID)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ShowSiteError
'
' Description:
' If errors were reported during setup to start the Administration
' or Shares site, this script will display error dialog
' boxes to indicate to the user that he needs to reconcile
' the problem.
'
' This script should only be called if SaSetup.exe is run
' with the UI sequence enabled.
'
' The results are read from theregistry as a REG_SZ called:
' HKLM\Software\Microsoft\ServerAppliance\WebFramework\StartSiteError
' It is then interpreted as a number, with each bit position
' representing whether a site is started.
' Bit 0 corresponds to the Administration site and
' Bit 1 corresponds to the Shares site.
'
' History:
' travisn 7-JUL-2001 Created
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ShowSiteError(nSiteID)
On Error Resume Next
' Declare variables to read from the registry
Dim WshShell
Dim errorMsg
'Read the value of the registry entry for errors
Set WshShell = CreateObject("WScript.Shell")
errorMsg = WshShell.RegRead(REGKEY_WEBFRAMEWORK & "StartSiteError")
'Display the Administration site error
if errorMsg AND ADMIN_ID AND (nSiteID = ADMIN_ID) then
Call DisplayWarning (Session.Property("CustomActionData"))
end if
'Display the Shares site error
if errorMsg AND SHARES_ID AND (nSiteID = SHARES_ID) then
Call DisplayWarning (Session.Property("CustomActionData"))
end if
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function DisplayWarning(strWarning)
WARNING = &H02000000
Set messageRecord = Session.Installer.CreateRecord(1)
messageRecord.StringData(0) = "[1]"
messageRecord.StringData(1) = strWarning
Session.Message WARNING, messageRecord
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' StopDefaultSiteIfPristine
'
' Description:
' Stop the default site if it is still in its pristine state
' It is considered to not be in its pristine state if
' 1) The web site uses the default document list
' (used when the filename is not specified in the URL)
' 2) iisstart.asp is in this default document list
' 3) iisstart.asp is the first file in the list that exists
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function StopDefaultSiteIfPristine
On Error Resume Next
const defaultFileName1 = "iisstart.asp"
const defaultFileName2 = "iisstart.htm"
Dim oWebSrv , iisLoc, isDefaultSite
defaultSiteLoc = "IIS://localhost/w3svc/1"
isDefaultSite = false
Set siteRoot = GetObject(defaultSiteLoc & "/Root")
'
' Take the default site and determine if it has been modified
'
' Do a quick check to see if the default document list is being used and contains iisstart.asp
If siteRoot.enableDefaultDoc Then
Dim rootPath
Dim defaultFileList
rootPath = siteRoot.path & "\"
'Get the list of default files
defaultFileList = Split(siteRoot.defaultDoc, ",")
'
' Search the list of default files for the first file that actually exists.
' If the first one found is iisstart.asp, then it is determined to be the default site
'
Set oFs = CreateObject("Scripting.FileSystemObject")
For Each defaultFile In defaultFileList
If oFs.FileExists(rootPath & defaultFile) Then
'wscript.echo "File exists: " & defaultFile
If (defaultFile = DefaultFileName1 Or defaultFile = DefaultFileName2) Then
isDefaultSite = true
Exit For
Else
' The first file that exists was not iisstart.asp
Exit Function
End If
Else
'wscript.echo "File does NOT exist: " & defaultFile
End If
Next
Else
'wscript.echo "Default pages are turned off or do not include iisstart.asp"
End If
'
' If the web site is the default site then stop it
'
If ( isDefaultSite ) Then
'wscript.echo "Stop the default site"
set defaultWebSite = GetObject(defaultSiteLoc)
defaultWebSite.Stop
'This error is now reported in another place during setup
if ( Err.Number <> 0 ) Then
'wscript.echo "Unable to stop default site"
End If
End If
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub UpdateMimeMap
'
' Parameters:
' siteType ADMIN_ID or SHARES_ID
'
' Description:
' Updates the MIME map for the specified site to allow the appropriate
' types of files to be downloaded. Right now, that means adding the
' log file extensions for the administration web site. The shares
' site is not updated.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub UpdateMimeMap(siteType)
On Error Resume Next
Dim strRegKeySiteID
If (siteType = ADMIN_ID) Then
strRegKeySiteID = REGKEY_WEBFRAMEWORK & ADMIN_SITE_NAME & _
"SiteID"
Else
' We don't update the MIME Map for the shares site.
Exit Sub
' strRegKeySiteID = REGKEY_WEBFRAMEWORK & SHARES_SITE_NAME & _
' "SiteID"
End If
'
' Get the IIsWebServer object for the admin site.
'
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim nSiteID
nSiteID = WshShell.RegRead(strRegKeySiteID)
Dim oWebServer
Set oWebServer = GetObject("IIS://localhost/w3svc/" & nSiteID)
'
' Create the MimeMap objects.
'
Dim mmEVT
Set mmEVT = CreateObject("MimeMap")
mmEVT.Extension = ".evt"
mmEVT.MimeType = "application/octet-stream"
Dim mmCSV
Set mmCSV = CreateObject("MimeMap")
mmCSV.Extension = ".csv"
mmCSV.MimeType = "text/plain"
Dim mmLOG
Set mmLOG = CreateObject("MimeMap")
mmLOG.Extension = ".log"
mmLOG.MimeType = "text/plain"
'
' Add the new mappings.
'
Dim rgMimeMap
rgMimeMap = oWebServer.GetEx("MimeMap")
Dim bEVT: bEVT = True
Dim bCSV: bCSV = True
Dim bLOG: bLOG = True
Dim nUBound: nUBound = UBound(rgMimeMap) + 3
Dim oMapping
For Each oMapping In rgMimeMap
Select Case LCase(oMapping.Extension)
Case ".evt"
bEVT = False
nUBound = nUBound - 1
Case ".csv"
bCSV = False
nUBound = nUBound - 1
Case ".log"
bLOG = False
nUBound = nUBound - 1
End Select
Next
ReDim Preserve rgMimeMap(nUBound)
If (bLOG) Then
Set rgMimeMap(nUBound) = mmLOG
nUBound = nUBound - 1
End If
If (bCSV) Then
Set rgMimeMap(nUBound) = mmCSV
nUBound = nUBound - 1
End If
If (bEVT) Then
Set rgMimeMap(nUBound) = mmEVT
nUBound = nUBound - 1
End If
'
' Commit the changes.
'
Call oWebServer.PutEx(ADS_PROPERTY_UPDATE, "MimeMap", rgMimeMap)
Call oWebServer.SetInfo()
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function AddUserReadACL
'
' Description:
' Add User Read/Execute access to this folder
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function AddUserReadACL(strPath)
On Error Resume Next
Dim WshShell, strUserAccount, WmiConnection, oFs, objSid, caclsCommand
Dim USERS_SID, OPTIONS, READ
Set WshShell = CreateObject("WScript.Shell")
' Security ID definitions of the User account
USERS_SID = "S-1-5-32-545"
' cacls constants
OPTIONS = " /E /T /G " 'Edit ACL, All files in directory & subdirectories, Grant access
READ = ":R" 'Read Access
' Get localized account name for changing permissions on the User account
strWmiGetUser = "Win32_SID.SID=""" & USERS_SID & """"
Set WmiConnection = GetWMIConnection()
set objSid = WmiConnection.Get(strWmiGetUser)
If Err.number <> 0 Then
'DisplayWarning "Failed to get WMI User: " & Err.number & ", " & Err.Description
Exit Function
End If
strUserAccount = """" & objSid.AccountName & """"
'Run cacls to add Users to the folder
Set oFs = CreateObject("Scripting.FileSystemObject")
If oFs.FolderExists(strPath) Then
caclsCommand = "cmd /C echo y|cacls " 'Automatically select Yes to overwrite the permissions
WshShell.Run caclsCommand & strPath & OPTIONS & strUserAccount & READ, 0, True
End If
End Function
'-------------------------------------------------------------------------
'Function name: GetWMIConnection
'Description: Serves in getting connected to the server
'Input Variables: None
'Output Variables: None
'Returns: Object -connection to the server object
'This will try to create an object and connect to wmi
'-------------------------------------------------------------------------
Function GetWMIConnection()
Dim objLocator, objService
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer()
If Err.number = 0 Then
Set GetWMIConnection = objService
End If
'Set to nothing
Set objLocator=Nothing
Set objService=Nothing
End Function
|
<gh_stars>10-100
Attribute VB_Name = "Module1"
' Data from the main screen
Public strADSPath
Public strDomain
Public strFile
Public strPassword
Public strPrefix
Public strUsername
' Data from the product screen
Public strProdName
Public strProdDescription
Public strProdVMajor
Public strProdVMinor
' Data from the vendor screen
Public strVendName
'Public strVendPrefix
Public strVendAddress
Public strVendCity
Public strVendState
Public strVendCountry
Public strVendPostalCode
Public strVendTelephone
Public strVendEmail
'Public strVendContactName
Public Sub WriteXMLLine(strField, strValue)
Dim strText
strText = "<sd:comment-" & strField & ">" & strValue & "</sd:comment-" & strField & ">"
Print #1, strText
End Sub
|
Private Function OddWordSecond(Words As String) As String
Dim i&, count&, t$, cpt&, j&, l&, d&, f As Boolean
Const PUNCT As String = ",;:"
For i = 1 To Len(Words)
'first word
If i = 1 Then
cpt = 1
Do
t = t & Mid(Words, cpt, 1)
cpt = cpt + 1
Loop While InStr(PUNCT, Mid(Words, cpt, 1)) = 0 And cpt < Len(Words)
i = cpt
t = t & Mid(Words, i, 1)
End If
If Right(t, 1) = "." Then Exit For
'Odd words ==> reverse
While InStr(PUNCT, Mid(Words, cpt + 1, 1)) = 0 And cpt < Len(Words)
cpt = cpt + 1
Wend
l = IIf(f = True, i, i + 1)
d = IIf(cpt = Len(Words), cpt - 1, cpt)
For j = d To l Step -1
t = t & Mid(Words, j, 1)
Next
If cpt = Len(Words) Then t = t & ".": Exit For
f = True
i = cpt + 1
t = t & Mid(Words, i, 1)
'Even words
cpt = i + 1
t = t & Mid(Words, cpt, 1)
Do
cpt = cpt + 1
t = t & Mid(Words, cpt, 1)
Loop While InStr(PUNCT, Mid(Words, cpt, 1)) = 0 And cpt < Len(Words)
i = cpt
Next
OddWordSecond = t
End Function
|
strYear = WScript.StdIn.ReadLine
For i = 1 To 12
d = DateSerial(strYear, i + 1, 1) - 1
WScript.Echo d - Weekday(d) + 1
Next
|
<gh_stars>1-10
Option Explicit
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const MORSE_ALPHA As String = ".-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--.."
Private Const MORSE_NUMERIC As String = "-----,.----,..---,...--,....-,.....,-....,--...,---..,----."
Private Const ONE_UNIT As Integer = 100
Private Const BEEP_DOT As Integer = ONE_UNIT
Private Const BEEP_DASH As Integer = 3 * ONE_UNIT
Private Const BEEP_OTHER As Integer = 7 * ONE_UNIT
Private Const DELAY As Integer = ONE_UNIT
Private Const LETTERS_DELAY As Integer = 3 * ONE_UNIT
Private Const SPACE_DELAY As Integer = 7 * ONE_UNIT
Private Const FREQUENCY_CHARS As Integer = 1200
Private Const FREQUENCY_OTHERCHARS As Integer = 400
Sub Main()
Dim p$, temp$
p = ToMorse("Hel/lo 123 world")
temp = Replace(p, "+", "")
Debug.Print Replace(temp, "_", "")
PlayMorse p
End Sub
Private Function ToMorse(s As String) As String
Dim i&, t$, j&
s = UCase(s)
For i = 1 To Len(s)
j = Asc(Mid(s, i, 1))
Select Case j
Case 65 To 90 'alpha
t = t & Split(MORSE_ALPHA, ",")(j - 65) & "+" ' "+" ==> separate each characters
Case 48 To 57 'numerics
t = t & Split(MORSE_NUMERIC, ",")(j - 48) & "+"
Case 32 'space
t = t & " " & "+"
Case Else 'others
t = t & "_" & "+"
End Select
Next i
ToMorse = t
End Function
Private Sub PlayMorse(s As String)
Dim i&
For i = 1 To Len(s)
Select Case Mid(s, i, 1)
Case ".": Beep FREQUENCY_CHARS, BEEP_DOT
Case "-": Beep FREQUENCY_CHARS, BEEP_DASH
Case "_": Beep FREQUENCY_OTHERCHARS, BEEP_OTHER
Case "+": Sleep LETTERS_DELAY
Case " ": Sleep SPACE_DELAY
End Select
Sleep DELAY
Next i
End Sub
|
Dim lWatson
Dim lArchive
Dim lMiniArchive
Dim lCount
Dim cn
Dim oOCAData
Dim dDate
Dim x
on error resume next
Set oOCAData = CreateObject("OCAData.CountDaily.1")
Set cn = CreateObject("ADODB.Connection")
lCount = 0
lArchive = 0
lWatson = 0
lMiniArchive = 0
With cn
.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;Pwd=<PASSWORD>;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=tkwucdsqla02"
.CursorLocation = 2
.Open
End With
for x =2 to 1 Step -1
lWatson = oOCAData.GetFileCount(0, "\\tkofffso03\Watson\BlueScreen\", Date - x)
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive10\", Date - x)
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive9\", Date - x)
end if
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive8\", Date - x)
end if
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive6\", Date - x)
end if
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive5\", Date - x)
end if
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive4\", Date - x)
end if
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsa02\Ocaarchive3\", Date - x)
end if
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsb01\ocaarchive2\", Date - x)
End If
if lArchive = 0 then
lArchive = oOCAData.GetFileCount(1, "\\Tkwucdfsb01\ocaarchive\", Date - x)
end if
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive10\", Date - x)
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive9\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive8\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive7\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive6\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive5\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive4\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsa02\Ocaarchive3\", Date - x)
end if
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsb01\ocaarchive2\", Date - x)
End If
if lMiniArchive = 0 then
lMiniArchive = oOCAData.GetFileMiniCount(1, "\\Tkwucdfsb01\ocaarchive\", Date - x)
end if
dDate = Date - x
cn.Execute "SetFileCounts '" & dDate & "', " & lWatson & ", " & lArchive & ", " & lMiniArchive
Next
cn.Close
Set cn = Nothing
Set oOCAData = Nothing
|
' Get the performance counter instance for the Windows Management process
set refresher = CreateObject("WbemScripting.SWbemRefresher")
set services = GetObject ("winmgmts://alanbos5/root/cimv2")
if err then WScript.Echo Err.Description
set refreshableItem = refresher.AddEnum (services, "win32_perfrawdata_perfproc_process")
for i = 1 to 100000
WScript.Echo "***********************************"
refresher.Refresh
for each process in refreshableItem.ObjectSet
Wscript.Echo process.Name, process.HandleCount
next
next
|
Public nations As New Collection
Private Sub init()
nations.Add 24, "AD"
nations.Add 21, "CH"
nations.Add 22, "GB"
nations.Add 24, "SA"
nations.Add 20, "XK"
End Sub
Private Function mod97(ByVal c As String) As Integer
Dim n As Long
n = Val(Mid(c, 1, 9))
c = Mid(c, 10, Len(c) - 9)
n = n Mod 97
Do While Len(c) > 6
n = Val(Str(n) & Mid(c, 1, 7))
n = n Mod 97
c = Mid(c, 8, Len(c) - 7)
Loop
n = Val(Str(n) & c)
mod97 = n Mod 97
End Function
Private Function iban(ByVal code As String) As Boolean
'-- This routine does and should reject codes containing spaces etc.
'-- Use iban_s() below for otherwise.
On Error GoTo 1
lengths = nations(Mid(code, 1, 2))
If Len(code) = lengths Then
code = code & Mid(code, 1, 4)
code = Mid(code, 5, lengths)
Dim c As String: c = ""
Dim ch As String
For i = 1 To lengths
ch = Mid(code, i, 1)
If ch >= "0" And ch <= "9" Then
c = c & ch
Else
If ch >= "A" And ch <= "Z" Then
c = c & Str(Asc(ch) - 55)
Else
iban = False
End If
End If
Next i
c = Replace(c, " ", "")
iban = mod97(c) = 1
End If
Exit Function
1:
iban = False
End Function
Private Function iban_s(code As String) As Boolean
'-- strips any embedded spaces and hyphens before validating.
code = Replace(code, " ", "")
code = Replace(code, "-", "")
iban_s = iban(code)
End Function
Private Sub test(code As String, expected As Boolean)
Dim valid As Boolean
valid = iban_s(code)
Dim state As String
If valid = expected Then
state = IIf(valid, "ok", "invalid (as expected)")
Else
state = IIf(valid, "OK!!", "INVALID!!") & " (NOT AS EXPECTED)"
End If
Debug.Print code, state
End Sub
Public Sub main()
init
test "GB82 WEST 1234 5698 7654 32", True
test "GB82 TEST 1234 5698 7654 32", False
test "GB81 WEST 1234 5698 7654 32", False
test "SA03 8000 0000 6080 1016 7519", True
test "CH93 0076 2011 6238 5295 7", True
End Sub
|
Option Explicit
Sub Main()
Dim s As String, FF As Integer
'read a file line by line
FF = FreeFile
Open "C:\Users\" & Environ("username") & "\Desktop\input.txt" For Input As #FF
While Not EOF(FF)
Line Input #FF, s
Debug.Print s
Wend
Close #FF
'read a file
FF = FreeFile
Open "C:\Users\" & Environ("username") & "\Desktop\input.txt" For Input As #FF
s = Input(LOF(1), #FF)
Close #FF
Debug.Print s
'write a file
FF = FreeFile
Open "C:\Users\" & Environ("username") & "\Desktop\output.txt" For Output As #FF
Print #FF, s
Close #FF
End Sub
|
'Simple Stack class
'uses a dynamic array of Variants to stack the values
'has read-only property "Size"
'and methods "Push", "Pop", "IsEmpty"
Private myStack()
Private myStackHeight As Integer
'method Push
Public Function Push(aValue)
'increase stack height
myStackHeight = myStackHeight + 1
ReDim Preserve myStack(myStackHeight)
myStack(myStackHeight) = aValue
End Function
'method Pop
Public Function Pop()
'check for nonempty stack
If myStackHeight > 0 Then
Pop = myStack(myStackHeight)
myStackHeight = myStackHeight - 1
Else
MsgBox "Pop: stack is empty!"
End If
End Function
'method IsEmpty
Public Function IsEmpty() As Boolean
IsEmpty = (myStackHeight = 0)
End Function
'property Size
Property Get Size() As Integer
Size = myStackHeight
End Property
|
<reponame>LaudateCorpus1/RosettaCodeData
'In case of problem this will terminate the program (without cleanup):
If problem then End
'As VBA is run within an application, such as Excel, a more rigorous way would be:
If problem then Application.Quit
'This will stop the application, but will prompt you to save work.
|
Public Function RepeatStr(aString As String, aNumber As Integer) As String
Dim bString As String
bString = aString
If aNumber > 1 Then
For i = 2 To aNumber
bString = bString & aString
Next i
End If
RepeatStr = bString
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData
Public Sub text()
Debug.Print InputBox("Input a string")
Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.