Re: Convert a string to a number

"John R. Dennison" <[email protected]>
Newsgroups gmane.comp.windows.autoit.user
Message-ID <[email protected]>
On Tue, Nov 21, 2006 at 06:06:43PM +0100, [email protected] wrote:
> Hey Gang,
> 
>   I have a script that is manipulating a list of IP addresses.  I am
> trying to get the last octet and determine what the next one would be.
> I can get my list into an array.  I can trim off what I don't want (the
> xx.xx.xx. piece) but the remaining piece is a string.  I tried using
> Number but it returns zero.  So how can I convert it back into a number?

	Variables in AutoIT are variants; they are both strings and
	numbers depending upon usage.

	... code ...
	$last_octet = $last_octet + 1

	should numerically add 1 to the extracted last octet value your
	code extracted from the IP address.

	As a simple exercise:

	Global $val
	$val = "123.4"
	$val = $val + 1
	MsgBox (0, "debug output", "val now contains: " & $val)

	should result in a message box titled "debug" containing the
	text "val now contains 124.4".

	Numerical tests against your variable will work as expected.




							John

-- 
"I'm sorry but our engineers do not have phones."
As stated by a Network Solutions Customer Service representative when asked to
be put through to an engineer.

"My other computer is your windows box."
                                     Ralf Hildebrandt


[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.