a couple of CommandLineHelloWorld questions and one on ActiveX

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

a couple of CommandLineHelloWorld questions and one on ActiveX

Howard Ding
Hello,

I've been fooling around with the CommandLineHelloWorld in an attempt to
learn how to make a command line program.  I've had a couple things that
I don't understand happen.

1.  After deploying the CommandLineHelloWorld via Lagoon and then
running it, on my (W2K) box at home everything seems to work okay; the
program launches in a console and after pressing Enter it goes away.  On
my (NT4) box at work, everything prints to the console, but pressing
Enter seems to have no effect; the console never disappears.

2.  Let's say that I want to modify the program to pause before
displaying the prompt to exit.  I'd expect that adding a line like:

Processor sleep: 1000.

would make it pause for a second and then resume.  However, when I do
this it just hangs.  Clearly I don't understand something that is
happening.

The ActiveX question is this:  how does one deal with optional
parameters?  While I was experimenting, I found that I was able to omit
them from the end and things seemed to work, e.g. if we had a selector
arg1:arg2:arg3:arg4: where the last two are optional I could just send
something like:

Interface arg1: aNumber arg2: aNumber

and things seemed to work as one would expect.  Is this how things
should work?  Moreover, what if one wants to omit an optional parameter
but use a later optional parameter (e.g. in my example I want to pass
something for arg1, arg2, and arg4, but not arg3?).

Thanks for any advice,

Howard

--
Howard Ding
[hidden email]
http://math.sunysb.edu/~hading  http://thunder.prohosting.com/~hading


Reply | Threaded
Open this post in threaded view
|

Re: a couple of CommandLineHelloWorld questions and one on ActiveX

Ian Bartholomew
Howard,

> 1.  After deploying the CommandLineHelloWorld via Lagoon and then
> running it, on my (W2K) box at home everything seems to work okay; the
> program launches in a console and after pressing Enter it goes away.  On
> my (NT4) box at work, everything prints to the console, but pressing
> Enter seems to have no effect; the console never disappears.

Are you using patch level 1? There was a fix included in this (which just
deleted GUISessionManager>>onCloseConsole) which may have some effect on NT.
I can't say for sure as I use Win2000.

Ian


Reply | Threaded
Open this post in threaded view
|

Re: a couple of CommandLineHelloWorld questions and one on ActiveX

Blair McGlashan
In reply to this post by Howard Ding
Howard

You wrote in message news:[hidden email]...

>
> I've been fooling around with the CommandLineHelloWorld in an attempt to
> learn how to make a command line program.  I've had a couple things that
> I don't understand happen.
>
> 1.  After deploying the CommandLineHelloWorld via Lagoon and then
> running it, on my (W2K) box at home everything seems to work okay; the
> program launches in a console and after pressing Enter it goes away.  On
> my (NT4) box at work, everything prints to the console, but pressing
> Enter seems to have no effect; the console never disappears.

Apart from Ian's suggestion about installing Patch Level 1, I wonder if it
might be the case that the machine in question is configured not to close
consoles automatically when the application finishes. Rather than
double-clicking the app., try running it from the command line itself.
You'll know if it is finishing correctly because it will return.
Alternatively try inserting a 'self stdout nextPutAll: 'Bye'; cr; flush'
after the 'self stdin nextLine' to see if it gets past that.

>
> 2.  Let's say that I want to modify the program to pause before
> displaying the prompt to exit.  I'd expect that adding a line like:
>
> Processor sleep: 1000.
>
> would make it pause for a second and then resume.  However, when I do
> this it just hangs.  Clearly I don't understand something that is
> happening.

Hmmm, not sure what the story is there. I'll try it.

> The ActiveX question is this:  how does one deal with optional
> parameters?  While I was experimenting, I found that I was able to omit
> them from the end and things seemed to work, e.g. if we had a selector
> arg1:arg2:arg3:arg4: where the last two are optional I could just send
> something like:
>
> Interface arg1: aNumber arg2: aNumber
>
> and things seemed to work as one would expect.  Is this how things
> should work?  Moreover, what if one wants to omit an optional parameter
> but use a later optional parameter (e.g. in my example I want to pass
> something for arg1, arg2, and arg4, but not arg3?).

It only works because you are going through #doesNotUnderstand: processing,
i.e. the Smalltalk object doesn't actually implement a method with the
"shorter" selector, but it asks the underlying COM object if it understands
the primary keyword, and if so tries calling it with the parameters you have
passed. If some are optional, then this will often work, but it will be
slow.

What I recommend you do instead is to add some further wrapper methods of
your own by copying the one with all the parameters generated by the AX
wizard. You can then follow the common Smalltalk idiom of having shortcuts
that omit/default some of the parameters. What to pass for the optional
parameters? Well that depends on their type: Commonly they are VARIANTs, in
which case you should pass "VARIANT unspecified", for other types nil is
often appropriate (pointers, BSTRs). Oh, and if you add wrapper methods just
make sure they aren't in the auto-generated category, and then the wizard
won't overwrite them should you regenerate the interface.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: a couple of CommandLineHelloWorld questions and one on ActiveX

Howard Ding
Hi Blair,

Thanks for your advice.  I am at PL1.  When I first tried the
HelloWorld, I did do from the command line as well, with the same
problem.  However, I tried again from a fresh image and this part was
okay, so I guess somewhere in my previous experimentation I did
something I shouldn't have without realizing it.  The problem with
sleeping did persist even in the fresh image, though.

I thought there must be some magic going on that caused my experiments
with the activeX control to work (since there was clearly no selector
defined for what I was calling!), and you confirm that it was really
black and not white magic.  I suspected that the way you suggest would
be the proper way to go about things, but I didn't know about the
specific way to indicate an optional argument as not being passed, so
thanks for clearing it up.

Howard

--
Howard Ding
[hidden email]
http://math.sunysb.edu/~hading  http://thunder.prohosting.com/~hading