1. How to create random @ put in field using winlib
- Posted by Tony Steward <figjam at NLC.NET.AU>
Oct 31, 2000
-
Last edited Nov 01, 2000
------=_NextPart_000_0013_01C0436F.7D3C2B60
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all,
This is probably elementary to most of you but I want to create a random =
number between 1 and 100 and then place it in a field as below. Please =
help.
-- code generated by Win32Lib IDE v0.9
include Win32Lib.ew
without warning
-------------------------------------------------------------------------=
-------
-- Window SafeWindow
global constant SafeWindow =3D create( Window, "Random Safe Codes", 0, =
90, 148, 680, 696, 0 )
global constant OneNumber =3D create( EditText, "", SafeWindow, 48, 68, =
36, 20, 0 )
global constant TwoNumber =3D create( EditText, "", SafeWindow, 108, 68, =
36, 20, 0 )
global constant ThreeNumber =3D create( EditText, "", SafeWindow, 164, =
68, 36, 20, 0 )
global constant CreateButton =3D create( PushButton, "Create Code", =
SafeWindow, 80, 104, 90, 30, 0 )
-------------------------------------------------------------------------=
-------
procedure CreateButton_onClick ()
object temp =20
temp =3D 1
while temp < 48 do
temp =3D rand(99) =20
end while =20
setText(OneNumber,{temp})=20
end procedure
onClick[CreateButton] =3D routine_id("CreateButton_onClick")
WinMain( SafeWindow, Normal )
------=_NextPart_000_0013_01C0436F.7D3C2B60
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This is probably elementary to most of =
you but I=20
want to create a random number between 1 and 100 and then place it in a =
field as=20
below. Please help.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>-- code generated by Win32Lib IDE =
v0.9</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>include Win32Lib.ew<BR>without =
warning</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial=20
----------------<BR>-- =20
Window SafeWindow<BR>global constant SafeWindow =3D create( Window, =
"Random Safe=20
Codes", 0, 90, 148, 680, 696, 0 )<BR>global constant OneNumber =3D =
create(=20
EditText, "", SafeWindow, 48, 68, 36, 20, 0 )<BR>global constant =
TwoNumber =3D=20
create( EditText, "", SafeWindow, 108, 68, 36, 20, 0 )<BR>global =
constant=20
ThreeNumber =3D create( EditText, "", SafeWindow, 164, 68, 36, 20, 0 =
)<BR>global=20
constant CreateButton =3D create( PushButton, "Create Code", SafeWindow, =
80, 104,=20
90, 30, 0=20
------------<BR>procedure=20
CreateButton_onClick ()<BR>object temp <BR>temp =
=3D=20
1<BR>while temp < 48 do<BR>temp =3D rand(99) <BR>end =
while =20
<BR>setText(OneNumber,{temp}) <BR>end procedure<BR>onClick[CreateButton] =
=3D=20
routine_id("CreateButton_onClick")</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>WinMain( SafeWindow, Normal=20
------=_NextPart_000_0013_01C0436F.7D3C2B60--
2. Re: How to create random @ put in field using winlib
- Posted by Ray & Debbie Smith <smithr at IX.NET.AU>
Oct 31, 2000
-
Last edited Nov 01, 2000
------=_NextPart_000_0006_01C04373.84AE7660
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Tony,
Try slotting this in :
procedure CreateButton_onClick ()
integer temp =20
temp =3D rand(100) =20
setText(OneNumber,sprintf("%d", temp))=20
end procedure
A few notes:
* rand(x) returns an integer between 1 and x.
* I don't really know what you where trying to achieve with your while =
loop.
* setText expects to see a sequence if i'm not mistaken, where rand(99) =
was returning
an integer, that's what sprintf("%d", temp) does, converts an integer to =
a=20
sequence.
Hope that helps,
Ray Smith
----- Original Message -----=20
From: Tony Steward=20
To: EUPHORIA at LISTSERV.MUOHIO.EDU=20
Sent: Tuesday, October 31, 2000 7:19 PM
Subject: How to create random @ put in field using winlib
Hi all,
This is probably elementary to most of you but I want to create a =
random number between 1 and 100 and then place it in a field as below. =
Please help.
-- code generated by Win32Lib IDE v0.9
include Win32Lib.ew
without warning
=
-------------------------------------------------------------------------=
-------
-- Window SafeWindow
global constant SafeWindow =3D create( Window, "Random Safe Codes", 0, =
90, 148, 680, 696, 0 )
global constant OneNumber =3D create( EditText, "", SafeWindow, 48, =
68, 36, 20, 0 )
global constant TwoNumber =3D create( EditText, "", SafeWindow, 108, =
68, 36, 20, 0 )
global constant ThreeNumber =3D create( EditText, "", SafeWindow, 164, =
68, 36, 20, 0 )
global constant CreateButton =3D create( PushButton, "Create Code", =
SafeWindow, 80, 104, 90, 30, 0 )
=
-------------------------------------------------------------------------=
-------
procedure CreateButton_onClick ()
object temp =20
temp =3D 1
while temp < 48 do
temp =3D rand(99) =20
end while =20
setText(OneNumber,{temp})=20
end procedure
onClick[CreateButton] =3D routine_id("CreateButton_onClick")
=20
WinMain( SafeWindow, Normal )
------=_NextPart_000_0006_01C04373.84AE7660
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Tony,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial>Try slotting this in :</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>procedure CreateButton_onClick =
()</FONT></DIV>
<DIV><FONT face=3DArial>integer temp <BR>temp =3D=20
rand(100) <BR>setText(OneNumber,sprintf("%d", temp)) =
<BR><FONT=20
size=3D2>end procedure<BR></FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>A few notes:</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>* rand(x) returns an integer =
between 1 and=20
x.</FONT></FONT></DIV>
<DIV><FONT face=3DArial>* I don't really know what you where trying to =
achieve=20
with your while loop.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>* setText expects to see a sequence if =
i'm not=20
mistaken, where rand(99) was returning</FONT></DIV>
<DIV><FONT face=3DArial>an integer, that's what sprintf("%d", temp) =
does, converts=20
an integer to a </FONT></DIV>
<DIV><FONT face=3DArial>sequence.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial>Hope that helps,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial>Ray Smith</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A href=3D"mailto:figjam at NLC.NET.AU" title=3Dfigjam at NLC.NET.AU>Tony =
Steward</A>=20
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20
href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20
title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> =
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, October 31, 2000 =
7:19=20
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> How to create random @ =
put in=20
field using winlib</DIV>
<DIV><BR></DIV>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This is probably elementary to most =
of you but I=20
want to create a random number between 1 and 100 and then place it in =
a field=20
as below. Please help.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>-- code generated by Win32Lib =
IDE=20
v0.9</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>include Win32Lib.ew<BR>without=20
warning</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial=20
=
----------------<BR>-- =20
Window SafeWindow<BR>global constant SafeWindow =3D create( Window, =
"Random Safe=20
Codes", 0, 90, 148, 680, 696, 0 )<BR>global constant OneNumber =3D =
create(=20
EditText, "", SafeWindow, 48, 68, 36, 20, 0 )<BR>global constant =
TwoNumber =3D=20
create( EditText, "", SafeWindow, 108, 68, 36, 20, 0 )<BR>global =
constant=20
ThreeNumber =3D create( EditText, "", SafeWindow, 164, 68, 36, 20, 0 =
)<BR>global=20
constant CreateButton =3D create( PushButton, "Create Code", =
SafeWindow, 80,=20
104, 90, 30, 0=20
=
------------<BR>procedure=20
CreateButton_onClick ()<BR>object temp =
<BR>temp =3D=20
1<BR>while temp < 48 do<BR>temp =3D rand(99) <BR>end =
while =20
<BR>setText(OneNumber,{temp}) <BR>end =
procedure<BR>onClick[CreateButton] =3D=20
routine_id("CreateButton_onClick")</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>WinMain( SafeWindow, Normal=20
------=_NextPart_000_0006_01C04373.84AE7660--