Worth to think about ...

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Ernest

Worth to think about ...

Post by Ernest » Wed Dec 11, 2002 7:46 pm

Marcus,
is there a chance to get something like this:

Code: Select all

StringReplace>Output Variable,Input Variable,Search String,Replace String 
:?:

Cheers
Ernest

Armstrong

Post by Armstrong » Wed Dec 11, 2002 11:51 pm

Ernest,

I doubt your suggested command will be implemented, though it, like my suggested cDoW, could immensely alleviat coding effort, especially for the new Macro Scheduler users. Of course, yours is far mroe challenging. Your bet is call external utility such as "word search & replace" from http://www.funduc.com/word_sr.htm.

Wish you luck.

Cheers,
Armstrong Wong
Hong Kong

Ernest

Post by Ernest » Thu Dec 12, 2002 10:08 am


User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 12, 2002 10:33 am

Hi,

A Replace function already exists in VBScript. Do this:

VBSTART
VBEND
VBEval>Replace("Hello World","World","Ernest"),result
MessageModal>result

The VBSTART and VBEND block can be empty since Replace is a standard VBScript function. result will end up equal to "Hello Ernest"

You can stick variables in like this:

Let>OrigString=Hello World
VBEval>Replace("%OrigString%","World","Ernest"),result
MessageModal>result

Since VBScript is now common to all versions of Macro Scheduler there isn't much point reinventing the wheel with another Replace function.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Replace Function

Post by support » Thu Dec 12, 2002 10:49 am

From the VBScript documentation:

Replace Function
Returns a string in which a specified substring has been replaced with another substring a specified number of times.

Replace(expression, find, replacewith[, start[, count[, compare]]])

Arguments
expression

Required. String expression containing substring to replace.

find

Required. Substring being searched for.

replacewith

Required. Replacement substring.

start

Optional. Position within expression where substring search is to begin. If omitted, 1 is assumed. Must be used in conjunction with count.

count

Optional. Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Must be used in conjunction with start.

compare

Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, the default value is 0, which means perform a binary comparison.

Settings
The compare argument can have the following values:

Constant Value Description
vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.


Return Values
Replace returns the following values:

If Replace returns
expression is zero-length Zero-length string ("").
expression is Null An error.
find is zero-length Copy of expression.
replacewith is zero-length Copy of expression with all occurences of find removed.
start > Len(expression) Zero-length string.
count is 0 Copy of expression.


Remarks
The return value of the Replace function is a string, with substitutions made, that begins at the position specified by start and and concludes at the end of the expression string. It is not a copy of the original string from start to finish.

The following example uses the Replace function to return a string:

Dim MyString
MyString = Replace("XXpXXPXXp", "p", "Y") ' A binary comparison starting at the beginning of the string. Returns "XXYXXPXXY".
MyString = Replace("XXpXXPXXp", "p", "Y", ' A textual comparison starting at position 3. Returns "YXXYXXY". 3, -1, 1)
Requirements
Version 2

See Also
Filter Function
MJT Net Support
[email protected]

Ernest

Post by Ernest » Thu Dec 12, 2002 2:07 pm

Thx for the hint.
You're right ("reinvent ..."), but an(y) additional MSched function would help those who not master VBScript.

Keep in mind that MSched is so successfull cause it's easy to learn. Otherwise VBS & WSH would be a choice (for free!) as well ... 8)

Ernest

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Dec 16, 2002 9:12 pm

Hi Ernest,

The unrivaled feature of Macro Schedule is its entended support for VBS. None of other macro products on the market offers such simple but powerful extension. Correct me if I'm wrong. Thanks.

Cheers,
Armstrong Wong
Hong Kong

Ernest

Post by Ernest » Wed Dec 18, 2002 11:16 pm

Hi,
I'm happy that MSched support has taken the chance to (indirectly) agree to my statement :wink:

Stolen from posting "clipboard contents not recognised" 8)

"MacroScript was designed to be easy for the non-programmer to understand and as such does not complicate the user with variable declarations and complicated ways to use them ..." (Msched Support)

That's what I've meant. It's definitely perfect that a geek has the chance to use MSched with VBS. But! on the other hand any additional commands/functions will help "non-programmers" to solve more complex issues as well, without having to know anything about VBS etc. ... :D

E.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Dec 18, 2002 11:26 pm

True, but we do have to find a balance somewhere. If we replicated all the capabilities of VBScript in simpler-to-use MacroScript the software would be 10 times the size! What we have done with MacroScript is concentrate on the key areas of windows automation. More advanced mathematical and string manipulation functions have been left to VBScript.

That said we do listen to suggestions, and many do get incorporated as new script commands in future versions, as you probably well know. So don't be surprised if you see new native MacroScript string functions in the next release. :)
MJT Net Support
[email protected]

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Dec 19, 2002 1:56 am

Hi Support & Ernest,

I tend to agree with Support as far as the product design is concerned. There are over ten of thousands of nifty functions out there on the market covering currency conversion, unit conversion, internal rate of return, gps waypoints download/upload ,....etc. Expanding the functions available from VBS and other external sources will also harm the performance of the Macro Scheduler ("MS").

What's Macro Scheduler in the first place? IMHO, it's a smart macro. That's, it simulates manual keystrokes based upon one or more events such as:
1. Date/Time;
2. Whether a window is active;
3. Whether pixels of a window has changed;
4. Whether If-condition is met or otherwise;
5. Whether a window is ready;
6. Whether Repeat-condition is met;

Therefore, the future development of Macro Scheduler should focus on 3 major areas:
1. Process/Task handling. For example,
Force suspension mode
Force hibernation mode
Wake up CPU at 18:00
Wake up NIC
Blue screen (GPF) handling

2. Event/Trigger. For example,
If keyboard is inactive for x minutes, do ....
If Firwire port is busy, do ....
If RS232 Com1 port is busy, do ....

3. Language construct. For example,

Do case
Case

Case

Otherwise

Endcase

Cheers,
Armstrong Wong
Hong Kong

Ernest

Post by Ernest » Thu Dec 19, 2002 8:59 am

Hi Armstrong,
I think you'll agree that your suggestions are in the main interest of a more experienced programmer (the one who won't have problem to take one of those billions toys). :wink:

I think about my nice colleague in Order Entry/Management who has to deal with repetative tasks (e.g. create consistent data on different systems in parallel), smart enough to understand MScheds easy syntax 8) but not willing to become an VBS-/JScript-/VB-/Perl-/ etc. coder. :roll:

Ernest

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Dec 19, 2002 11:30 am

Hi Ernest,

Thanks for sharing your view.

With due respect, on the other hand, in light of routine virus attacks, would you concur it might be too risky to allow anyone without any programming knowledge to write a Macro Scheduler script no matter how benign it may seem? It should be done so under supervision. That's exactly where a competent distributor or reseller ('provider") play a vital role. To be more explicit, the provider should be under obligation to walk the customer through the initial script coding.

Let's return back to our philosophical language design issue. Functions can always be extended via VBScript or calls to external .EXE, .COM, or .BAT,...etc., but not language construct. Code reability and maintenability can be enhanced or hindered by the language structure in one or another Conversely, the values of functions written in Clipper, Delphi, C#, VB, VBA,... can alway be returned to Macro Scheduler script. The language constructs in PL/1, Clipper, Delphi, C#, VB, VBA, VBScript,...etc. can't be transferred back to Macor Scheduler.

Even for the logical comparisons, Macro Scheduler only allows =, . It would be nice if Macro Scheduler could support >= and <=.

Look forward to hearing your insightful view. Thanks.

Cheers,
Armstrong Wong
Hong Kong

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts