1. Win getText of an integer
- Posted by sixs at ida.net Oct 09, 2003
- 416 views
This is a multi-part message in MIME format. ------=_NextPart_000_00F8_01C38DE7.A9D49930 charset="iso-8859-1" I want to enter a number into a windows program , Is there a "getInteger" in Euphoria? Windows JVandal ------=_NextPart_000_00F8_01C38DE7.A9D49930 charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2800.1264" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I want to enter a number into a windows = program=20 ,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Is there a "getInteger" in = Euphoria?=20 Windows</FONT></DIV> ------=_NextPart_000_00F8_01C38DE7.A9D49930--
2. Re: Win getText of an integer
- Posted by "C. K. Lester" <euphoric at cklester.com> Oct 09, 2003
- 403 views
sixs at ida.net wrote: > > > I want to enter a number into a windows program , > Is there a "getInteger" in Euphoria? Windows > JVandal Well, if you have a textbox (or edittext) control, you can get its value seq = getText(MyEditBox) and then use sprintf() or value() (?) to get its value. num = sprintf("%d",{seq}) Or somethin' like that.
3. Re: Win getText of an integer
- Posted by francis at gmx.co.uk Oct 09, 2003
- 403 views
To clarify: This question has nothing to do with Win32Lib, so long as you can getText() or whatever function this library uses to retrieve the string of text. You are talking about converting a text string to a number; this is usually done with a language specific function and not through the Win32 API. Do not use sprintf(). This function is designed for converting *variables and constants* to strings. The user has entered a string, so your task is in fact to do the complete opposite - which is value(). This converts a string to a euphoria object. For example, the string "083210" would convert to the integer value of 83210. I suggest you experiment around with value() a lot. Check it has been parsed correctly (the first element of the returned sequence identifies this). If you wish to parse for an integer only, then: -------------------------------- sequence s s = value(text_to_parse) if (text_to_parse[1] = GET_SUCCESS and integer(text_to_parse[2])) then -- do something end if -------------------------------- Help File Examples: Example 1: s = value("12345"} -- s is {GET_SUCCESS, 12345} Example 2: s = value("{0, 1, -99.9}") -- s is {GET_SUCCESS, {0, 1, -99.9}} Example 3: s = value("+++") -- s is {GET_FAIL, 0} It is a generic function, to > sixs at ida.net wrote: > >> >> I want to enter a number into a windows program , >> Is there a "getInteger" in Euphoria? Windows >> JVandal > > Well, if you have a textbox (or edittext) control, you can get its value > > seq = getText(MyEditBox) > > and then use sprintf() or value() (?) to get its value. > > num = sprintf("%d",{seq}) > > Or somethin' like that. > > --^---------------------------------------------------------------- > This email was sent to: francis at gmx.co.uk > > > TOPICA - Start your own email discussion group. FREE! > >
4. Re: Win getText of an integer
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 09, 2003
- 404 views
----- Original Message ----- From: "C. K. Lester" <euphoric at cklester.com> To: "EUforum" <EUforum at topica.com> Subject: Re: Win getText of an integer > > > sixs at ida.net wrote: > > > > > I want to enter a number into a windows program , > > Is there a "getInteger" in Euphoria? Windows > > JVandal > > Well, if you have a textbox (or edittext) control, you can get its value > > seq = getText(MyEditBox) > > and then use sprintf() or value() (?) to get its value. > > num = sprintf("%d",{seq}) > > Or somethin' like that. Actually that would NOT work because sprintf() converts a number to a text format and not the other way round. With win32lib you can simply do: num = getNumber(MyEditBox)
5. Re: Win getText of an integer
- Posted by Louis at cwshop.com Oct 09, 2003
- 412 views
--=====_106571978526111=_ I'm not sure that value() does what you want. This is how I solved it for= myself: Louis. ----------------------------------------------------------------- -- s2n -- Convert a numeric text string to an integer -- Note: This only works for positive integers ----------------------------------------------------------------- global function s2n(sequence s) atom n s -=3D '0' -- Convert ASCII to BCD n =3D s[1] -- First digit for i =3D 2 to length(s) do n =3D n*10 + s[i] -- The rest of the digits end for return n -- Return the number end function *********** REPLY SEPARATOR *********** On 10/8/2003 at 10:01 PM sixs at ida.net wrote: I want to enter a number into a windows program , Is there a "getInteger" in Euphoria? Windows JVandal --=====_106571978526111=_ Content-Type: text/html; charset="us-ascii" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1226" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV>I'm not sure that value() does what you want. This is how I solved it for myself:</DIV> <DIV> </DIV> <DIV>Louis.</DIV> <DIV> </DIV> <DIV>-----------------------------------------------------------------<BR>-- s2n -- Convert a numeric text string to an integer<BR>-- Note: This only works for positive integers<BR>-----------------------------------------------------------------<BR>global function s2n(sequence s)<BR> atom n<BR> s -= '0' -- Convert ASCII to BCD<BR> n = s[1] -- First digit<BR> for i = 2 to length(s) do<BR> n = n*10 + s[i] -- The rest of the digits<BR> end for<BR> return n -- Return the number<BR>end function</DIV> <DIV><BR><FONT face=Arial size=2>*********** REPLY SEPARATOR ***********<BR><BR>On 10/8/2003 at 10:01 PM sixs at ida.net wrote:</FONT></DIV> <BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid"><PRE>============ The Euphoria Mailing List ============ </PRE> <DIV><FONT face=Arial size=2>I want to enter a number into a windows program ,</FONT></DIV> <DIV><FONT face=Arial size=2>Is there a "getInteger" in Euphoria? Windows</FONT></DIV> --=====_106571978526111=_--