Re: maths
Re: maths
- Subject: Re: maths
- From: Alex Zavatone <email@hidden>
- Date: Wed, 18 Apr 2012 16:37:19 -0400
As "integer" is legit.
Both "as integer" and "as number" should work.
Don't know why "as integer" didn't work. set myVal to "32445" as number log myVal
On Apr 18, 2012, at 4:29 PM, Javi Pérez wrote:
Well, it worked in this way:
set topReport to do shell script "top -n1 -l1" set topCpuUsage to get paragraph 4 of topReport set userUsage to get word 3 of topCpuUsage set sysUsage to get word 5 of topCpuUsage set totalUsage to get word 7 of topCpuUsage as integer set totalUsage2 to 100 - totalUsage
integer instead number
Enviado con El miércoles 18 de abril de 2012 a las 22:19, Alex Zavatone escribió:
It's a string. You got the "word" of a string of text. That is a string operation.
You now have to tell it to be a number or AS will børk when trying to subtract a string from a number.
And for those who don't know what "bork" means: From:
On Apr 18, 2012, at 3:26 PM, Javi Pérez wrote:
Enviado con
El miércoles 18 de abril de 2012 a las 21:26, Alex Zavatone escribió:
set totalUsage to get word 29 of topReport as number
On Apr 18, 2012, at 3:23 PM, Javi Pérez wrote:
Hello I have this
set topReport to do shell script "top -n1 -l1" set totalUsage to get word 29 of topReport
set totalUsage2 to 100 - totalUsage
and I see this error "No es posible convertir \"50.0\" en tipo number." number -1700 from "50.0" to number
not possible to convert 50.0 in type number
but it's already a number, I also tried to suffix "as number" in the set totalUsage line, but won't work. If I try manually set totalUsage2 to 100 - 50.2 it works
why?
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >maths (From: Javi Pérez <email@hidden>) |
| >Re: maths (From: Alex Zavatone <email@hidden>) |
| >RE: maths (From: Javi Pérez <email@hidden>) |
| >Re: maths (From: Alex Zavatone <email@hidden>) |
| >RE: maths (From: Javi Pérez <email@hidden>) |