1. Win32 askLine(), getLine(), getInput(), . . .
- Posted by Terry Constant <EUforum at terryconstant.com>
Sep 24, 2004
-
Last edited Sep 25, 2004
I have searched but not found a simple askLine() function (ignore
this name it is just a sample). I am looking for a function that
displays a window with a caption, a label/prompt, a single line
edit text box, Ok button and Cancel button. Something like the
askLine() function in Winbatch. The text entered by a user would
be returned as a string. Is there such a function or a library
with one or more such?
Further, I am just about finished reacquainting myself with
Euphoria and am ready to tackle Win32Lib which looks like an
excellent effort. Is there such a function/demo in its many
demos/tutorials that I missed?
Terry Constant
2. Re: Win32 askLine(), getLine(), getInput(), . . .
Terry Constant wrote:
>
> I have searched but not found a simple askLine() function (ignore
> this name it is just a sample). I am looking for a function that
> displays a window with a caption, a label/prompt, a single line
> edit text box, Ok button and Cancel button. Something like the
> askLine() function in Winbatch. The text entered by a user would
> be returned as a string. Is there such a function or a library
> with one or more such?
>
> Further, I am just about finished reacquainting myself with
> Euphoria and am ready to tackle Win32Lib which looks like an
> excellent effort. Is there such a function/demo in its many
> demos/tutorials that I missed?
>
I'm sure I wrote one for use with win32lib but I can't find it now. Maybe
I just dreamt it
Anyhow, I'll knock one up for you. It's not all
that hard to do.
--
Derek Parnell
Melbourne, Australia
3. Re: Win32 askLine(), getLine(), getInput(), . . .
On Fri, 24 Sep 2004 14:30:55 -0700, Terry Constant
<guest at RapidEuphoria.com> wrote:
>I am looking for a function that
>displays a window with a caption, a label/prompt, a single line
>edit text box, Ok button and Cancel button. Something like the
>askLine() function in Winbatch.
Try this:
-- inbox.ew
-- accept user input in a simple window
-- Note: you must have a WinMain running for this to work.
-- Author Pete Lomax 25/9/2004
--
-- usage: x=input_box(prompt,title,parent)
--
-- Demo version (including the required dummy WinMain).
-- Shows a dummy main window, opens a dialogue box with
-- "yadda yadda yadda yadda field" as the prompt.
-- If you enter any text, and press OK or <return>, it
-- updates the dummy main window title.
-- It then opens a second dialogue box this time prompting
-- for "second". Try resizing the window as well.
-- Just delete everything below the marker to use for real.
include win32lib.ew
integer inbox,ftxt,field,ok,cancel
inbox=0
sequence Text
integer ftsize
procedure IBhandler(integer self, integer event, sequence params)
sequence size
integer sX,sY
if find(event,{w32HResize,w32HActivate,w32HOpen}) then
size=getClientRect(self)
sX=size[3]-size[1]
sY=size[4]-size[2]
setRect(ftxt,10,15+(sY-88)/2,ftsize,20,1)
setRect(field,15+ftsize,10+(sY-88)/2,sX-ftsize-35,25,1)
setRect(ok,sX-170,sY-35,60,20,1)
setRect(cancel,sX-90,sY-35,60,20,1)
setFocus(field)
elsif event=w32HKeyPress then
if params[1]=VK_RETURN then
self=ok
event=w32HClick
elsif params[1]=VK_ESCAPE then
event=w32HClick
end if
end if
if event=w32HClick then
if self=ok then
Text=getText(field)
else
Text=""
end if
closeWindow(inbox)
end if
end procedure
global function input_box(sequence ftext, sequence title, integer
parent)
sequence size, tsize
integer sX, sY
if inbox=0 then
size = getClientRect(Screen)
sX=size[3]
sY=size[4]
inbox=create(Window,title, parent, (sX-400)/2,(sY-120)/2, 400,
120, 0)
tsize=getTextExtent(inbox,ftext)
ftsize=tsize[1]
ftxt =create(LText,ftext,inbox,10,15,ftsize,20,0)
field =create(EditText,"",inbox,15+ftsize,10,180,25,0)
ok =create(PushButton,"OK",inbox,230,55,60,20,0)
cancel=create(PushButton,"Cancel",inbox,310,55,60,20,0)
setHandler({ok,cancel,field}, {w32HClick,w32HKeyPress},
routine_id( "IBhandler" ))
setHandler(inbox,{w32HResize,w32HActivate,w32HOpen},routine_id("IBhandler"))
else
--
-- I don't notice any problems with not being able to do this,
-- but if/when the function is working, won't hurt to call it.
--if not setParent(inbox,parent) then ?9/0 end if -- not yet
working
--
setText(inbox,title)
setText(ftxt,ftext)
tsize=getTextExtent(inbox,ftext)
ftsize=tsize[1]
end if
Text=""
openDialog(inbox)
return Text
end function
--------- Delete everything below this to use it for real
---------------
constant Main=create(Window,"Dummy Main Window",0,100,100,300,100,0)
procedure onActivateMain(integer self, integer event, sequence params)
sequence msg
if self or event or length(params) then end if -- suppress
warnings
msg=input_box("yadda yadda yadda yadda field","Enter
Something",Main)
if length(msg) then
setText(Main,msg)
end if
msg=input_box("second","And this",Main)
if length(msg) then
setText(Main,msg)
end if
end procedure
setHandler(Main,w32HActivate,routine_id("onActivateMain"))
WinMain(Main,Normal)
Regards,
Pete
4. Re: Win32 askLine(), getLine(), getInput(), . . .
Terry Constant wrote:
>
> I have searched but not found a simple askLine() function (ignore
> this name it is just a sample). I am looking for a function that
> displays a window with a caption, a label/prompt, a single line
> edit text box, Ok button and Cancel button. Something like the
> askLine() function in Winbatch. The text entered by a user would
> be returned as a string. Is there such a function or a library
> with one or more such?
>
Sorry for the delay. I had the day off and took the family to the
State fair (aka Royal Melbourne Show).
This afternoon I knocked up something that might be what you're looking
for. It can be found at ...
http://www.users.bigpond/ddparnell/euphoria/input.ew
There is a demo program at ...
http://www.users.bigpond/ddparnell/euphoria/userInput_1.exw
There are no docs yet.
Basically, you add "include input.ew" after the win32lib.ew include, then
you use it like ...
sequence vals
vals = userInput({
"Title=Enter whatever",
"Field=Your dog's name"
})
You can have any number of 'field' entries and the function returns
one value (a sequence) for each field you specify. Also, you can
specify field lengths (as number of characters) by appending
';' and the character count after any field.
For example:
vals = userInput({
"Title=Enter whatever",
"Field=Your dog's name;20",
"Field=Your favorite team;30",
"Field=ZIP Code;6"
})
in which the routine will return three values, such as ...
{ "Woody", "Carlton", "3162" }
You can also add an optional 'apply' button such that when pressed,
your program gets the values but the dialog does not close. You must
however, supply a call back routine id to handle the apply button values.
Additionally, you can specify a minimum width (in characters) of the
entire dialog form...
procedure ApplyBtn(integer DialogID, integer ButtonID, sequence Values)
. . .
end procedure
vals = userInput({
"Title=Enter whatever",
"Field=Your dog's name;20",
"Field=Your favorite team;30",
"Field=ZIP Code;6",
"apply=" & routine_id("ApplyBtn"),
"minwidth=80"
})
If you can think of any improvements before I distribute it with
win32lib, please let me know. I can think of a few embellishments.
--
Derek Parnell
Melbourne, Australia
5. Re: Win32 askLine(), getLine(), getInput(), . . .
Derek Parnell wrote:
>
> Terry Constant wrote:
> >
> > I have searched but not found a simple askLine() function (ignore
> > this name it is just a sample). I am looking for a function that
> > displays a window with a caption, a label/prompt, a single line
> > edit text box, Ok button and Cancel button. Something like the
> > askLine() function in Winbatch. The text entered by a user would
> > be returned as a string. Is there such a function or a library
> > with one or more such?
> >
>
> Sorry for the delay. I had the day off and took the family to the
> State fair (aka Royal Melbourne Show).
>
> This afternoon I knocked up something that might be what you're looking
> for. It can be found at ...
>
> <a
> href="http://www.users.bigpond/ddparnell/euphoria/input.ew">http://www.users.bigpond/ddparnell/euphoria/input.ew</a>
>
> There is a demo program at ...
>
> <a
> href="http://www.users.bigpond/ddparnell/euphoria/userInput_1.exw">http://www.users.bigpond/ddparnell/euphoria/userInput_1.exw</a>
>
Those should be
http://www.users.bigpond.com/ddparnell/euphoria/input.ew
and
http://www.users.bigpond.com/ddparnell/euphoria/userInput_1.ew
--
Derek Parnell
Melbourne, Australia
6. Re: Win32 askLine(), getLine(), getInput(), . . .
Derek and Pete,
Thank you both. Your help was what I needed.
Terry Constant
7. Re: Win32 askLine(), getLine(), getInput(), . . .
>From: Derek Parnell <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
>Date: Sun, 26 Sep 2004 00:07:06 -0700
>
>posted by: Derek Parnell <ddparnell at bigpond.com>
>
>If you can think of any improvements before I distribute it with
>win32lib, please let me know. I can think of a few embellishments.
>
I was just thinking it would be better if you had the title as a
separate parameter. A) IT should always be specified (right?) and,
B) it means less parsing for you. Also ,it might be nice if you had a
flags parameter as well. Then you could make an OK/Cancel dialog,
or a Yes/No dialog, etc. Your site still appears to be down, so I
can't say much more.
>--
>Derek Parnell
>Melbourne, Australia
>
PS. To Rob... Is there any way I could have my e-mail sent without
the =20 stuff and not have to explicitly type Enters into it?
~[ WingZone ]~
http://wingzone.tripod.com/
34&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines=20
Start enjoying all the benefits of MSN=AE Premium right now and get the=
=20
first two months FREE*.
8. Re: Win32 askLine(), getLine(), getInput(), . . .
- Posted by Robert Craig <rds at RapidEuphoria.com>
Sep 26, 2004
-
Last edited Sep 27, 2004
Elliott S. de Andrade wrote:
> PS. To Rob... Is there any way I could have my e-mail sent without
> the =20 stuff and not have to explicitly type Enters into it?
OK, I added a couple of lines of code that should
strip out most (but not all) of the "equals 20" things.
Your messages seem to be the most affected.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
9. Re: Win32 askLine(), getLine(), getInput(), . . .
- Posted by Bernard Ryan <xotron at bluefrog.com>
Sep 26, 2004
-
Last edited Sep 27, 2004
Rob:
If the RECIPIENT'S MAIL program can't handle
quoted-printable (many older ones can't),
( NOTE: RDS and TOPICA are the RECIPIENTS )
the message will look peculiar with all the equal
signs and hexadecimal encoding.
So when you DECODE the e-mail and put it in
in Database or put it on the Web Page this
is where it is coming from.
Goto this site and it explains about the problem
this will cause equal 3D's and equal 20's ETC.
http://nihlibrary.ors.nih.gov/Relais/mime.htm
Bernie
My files in archive:
http://www.rapideuphoria.com/w32engin.zip
http://www.rapideuphoria.com/mixedlib.zip
http://www.rapideuphoria.com/eu_engin.zip
http://www.rapideuphoria.com/win32eru.zip
10. Re: Win32 askLine(), getLine(), getInput(), . . .
>From: Derek Parnell <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
>Date: Sun, 26 Sep 2004 00:07:06 -0700
>
>posted by: Derek Parnell <ddparnell at bigpond.com>
>
>If you can think of any improvements before I distribute it with
>win32lib, please let me know. I can think of a few embellishments.
>
Well, I was thinking... Why not just have the title as a separate
parameter? A) It should always be specified (right?) and B) it means less=
stuff for you to parse. Maybe a flags parameter as well. (Separate paramete=
r
for the same reasons. Then you could have, say, an OK/Cancel dialog, or jus=
t
an OK dialog, etc.) I'd give you more suggestions, but bigpond seems to be=
having problems, so I can't download it.
>--
>Derek Parnell
>Melbourne, Australia
>
~[ WingZone ]~
http://wingzone.tripod.com/
Technology=20=20
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=10=
34&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines=20
Start enjoying all the benefits of MSN=AE Premium right now and get the=
first two months FREE*.
11. Re: Win32 askLine(), getLine(), getInput(), . . .
- Posted by Derek Parnell <ddparnell at bigpond.com>
Sep 28, 2004
-
Last edited Sep 29, 2004
Elliott S. de Andrade wrote:
>
> >From: Derek Parnell <guest at RapidEuphoria.com>
> >Reply-To: EUforum at topica.com
> >To: EUforum at topica.com
> >Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
> >Date: Sun, 26 Sep 2004 00:07:06 -0700
> >
> >posted by: Derek Parnell <ddparnell at bigpond.com>
> >
> >If you can think of any improvements before I distribute it with
> >win32lib, please let me know. I can think of a few embellishments.
> >
>
> Well, I was thinking... Why not just have the title as a separate
> parameter? A) It should always be specified (right?) and B) it means less=
>
> stuff for you to parse. Maybe a flags parameter as well. (Separate paramete=
> r
> for the same reasons. Then you could have, say, an OK/Cancel dialog, or jus=
> t
> an OK dialog, etc.) I'd give you more suggestions, but bigpond seems to be=
>
> having problems, so I can't download it.
I'm sure my website is up. The links I just downloaded to test it were...
http://www.users.bigpond.com/ddparnell/euphoria/userInput_1.exw
http://www.users.bigpond.com/ddparnell/euphoria/input.ew
I've been working on the userInput function yesterday and the minimum
usage would be something like ...
result = userInput("Enter your name")
but it can also be much more sophisticated in that you have some control
over the layout, the control types used for input, and you can have
a callback routine in which you can initialize and/or validate fields
before returning to the main application.
For example ...
result = userInput({
"minwidth=20",
"Title=Enter your details",
"Field=(,25x3,(CText,ss_sunken)," &
"This information is private and will " &
"never be given to any 3rd party)",
"Field=",
"Columns=2",
"VertGap=18",
"ButtonGap=30",
"RightMargin = 50",
"LeftMargin = 50",
"TopMargin = 50",
"BottomMargin = 50",
"callback=" & routine_id("Apply"),
"button=(accept,&Okay,defpushbutton)",
"button=(cancel,&Stop)",
"button=(apply,&Apply)",
"button=(test,&TEST)",
"Field=(Personal Name,25,,<Given name>)",
"Field=(Age,7,DropDownList,(0-19, 20-29, 30-39, 40-49, 50-59, 60+))",
"Field=(Family Name,30)",
"Field=(ZIP,6)"
}
)
--
Derek Parnell
Melbourne, Australia
12. Re: Win32 askLine(), getLine(), getInput(), . . .
>From: Derek Parnell <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
>Date: Tue, 28 Sep 2004 14:55:18 -0700
>
>posted by: Derek Parnell <ddparnell at bigpond.com>
>
>I'm sure my website is up. The links I just downloaded to test it were...
>
I said the website didn't work, as in www.users.bigpond.com. It doesn't=
seem to resolve (for a couple people.) I have no idea whether it's a 404 or=
not.
>
>--
>Derek Parnell
>Melbourne, Australia
>
~[ WingZone ]~
http://wingzone.tripod.com/
s
to offer.=20
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=10=
34&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines=20
Start enjoying all the benefits of MSN=AE Premium right now and get the=
first two months FREE*.
13. Re: Win32 askLine(), getLine(), getInput(), . . .
Elliott S. de Andrade wrote:
>
> >From: Derek Parnell <guest at RapidEuphoria.com>
> >Reply-To: EUforum at topica.com
> >To: EUforum at topica.com
> >Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
> >Date: Tue, 28 Sep 2004 14:55:18 -0700
> >
> >posted by: Derek Parnell <ddparnell at bigpond.com>
> >
> >I'm sure my website is up. The links I just downloaded to test it were...
> >
>
> I said the website didn't work, as in www.users.bigpond.com. It doesn't=
>
> seem to resolve (for a couple people.) I have no idea whether it's a 404 or=
>
> not.
Yes, I know what you said.
The name "www.users.bigpond.com" resolves to IP 139.134.5.123 here.
What do you get when pinging?
You could also try "http://139.134.5.123/ddparnell/euphoria/input.ew" etc...
--
Derek Parnell
Melbourne, Australia
14. Re: Win32 askLine(), getLine(), getInput(), . . .
Derek Parnell wrote:
> I'm sure my website is up. The links I just downloaded to test it were...
It's up, but it was down for a time after you first posted those
links. Even for me, and littlepond is my ISP also.
15. Re: Win32 askLine(), getLine(), getInput(), . . .
>From: Derek Parnell <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
>Date: Tue, 28 Sep 2004 17:52:55 -0700
>
>posted by: Derek Parnell <ddparnell at bigpond.com>
>
>Elliott S. de Andrade wrote:
> >
> > >From: Derek Parnell <guest at RapidEuphoria.com>
> > >Reply-To: EUforum at topica.com
> > >To: EUforum at topica.com
> > >Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
> > >Date: Tue, 28 Sep 2004 14:55:18 -0700
> > >
> > >posted by: Derek Parnell <ddparnell at bigpond.com>
> > >
> > >I'm sure my website is up. The links I just downloaded to test it
>were...
> > >
> >
> > I said the website didn't work, as in www.users.bigpond.com. It
>doesn't=
> > seem to resolve (for a couple people.) I have no idea whether it's a 404
>or=
> > not.
>
>Yes, I know what you said.
>
>The name "www.users.bigpond.com" resolves to IP 139.134.5.123 here.
>What do you get when pinging?
>
Ping uses DNS, so...nothing. The DNS just doesn't work, so I can't ping
it (or ftp/http/etc.)
>You could also try "http://139.134.5.123/ddparnell/euphoria/input.ew"
>etc...
>
This works, thanks.
>--
>Derek Parnell
>Melbourne, Australia
>
~[ WingZone ]~
http://wingzone.tripod.com/
16. Re: Win32 askLine(), getLine(), getInput(), . . .
<I wrote>
>>You could also try "http://139.134.5.123/ddparnell/euphoria/input.ew"
>>etc...
>>
>
>This works, thanks.
>
Now that I've tried it, the input window is a bit too small (I'm using XP
Styles.) It should be about 9 pixels bigger to accomodate the Status Bar
(Happens with some other demos that use that new-fangled control creation
system, too.) The label/input boxes could be a little bit spread out too.
They seem to be juust touching.
~[ WingZone ]~
http://wingzone.tripod.com/
17. Re: Win32 askLine(), getLine(), getInput(), . . .
Elliott S. de Andrade wrote:
>
>
> <I wrote>
> >>You could also try "<a
> >>href="http://139.134.5.123/ddparnell/euphoria/input.ew">http://139.134.5.123/ddparnell/euphoria/input.ew</a>"
> >>
> >>etc...
> >>
> >
> >This works, thanks.
> >
>
> Now that I've tried it, the input window is a bit too small (I'm using XP
> Styles.) It should be about 9 pixels bigger to accomodate the Status Bar
> (Happens with some other demos that use that new-fangled control creation
> system, too.) The label/input boxes could be a little bit spread out too.
> They seem to be juust touching.
Yes, I noticed that too. I've adjusted the default gaps between controls
and margins now. In addition, the coder can micro-manage this aspect by
specifying values that override the defaults, and even move stuff around
in the Activate event when using a callback routine.
--
Derek Parnell
Melbourne, Australia
18. Re: Win32 askLine(), getLine(), getInput(), . . .
>From: Robert Craig <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Win32 askLine(), getLine(), getInput(), . . .
>Date: Sun, 26 Sep 2004 16:23:40 -0700
>
>posted by: Robert Craig <rds at RapidEuphoria.com>
>
>Elliott S. de Andrade wrote:
> > PS. To Rob... Is there any way I could have my e-mail sent without
> > the =20 stuff and not have to explicitly type Enters into it?
>
>OK, I added a couple of lines of code that should
>strip out most (but not all) of the "equals 20" things.
>Your messages seem to be the most affected.
>
Thanks. Whatever you did, it seems to make everything a whole lot better.=
And, the Hotmail ads are caught too.
>Regards,
> Rob Craig
> Rapid Deployment Software
> http://www.RapidEuphoria.com
>
~[ WingZone ]~
http://wingzone.tripod.com/
s
to offer.=20
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=10=
34&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines=20
Start enjoying all the benefits of MSN=AE Premium right now and get the=
first two months FREE*.