Tripoz Posted August 1, 2015 Posted August 1, 2015 (edited) i have code :--edite--i want to detect if $Spotakhir is between ($Spotawal + $barrierpositif) or ($Spotawal + $barriernegatif) can anyone help me? thx Edited August 11, 2015 by Tripoz edit
water Posted August 1, 2015 Posted August 1, 2015 You were incorrectly mixing arithmetic and boolean operations.Try this two lines:$cek1 = $spotakhir < ($spotawal + $barrierpositif) $cek2 = $spotakhir > ($spotawal + $barriernegatif) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Tripoz Posted August 1, 2015 Author Posted August 1, 2015 You were incorrectly mixing arithmetic and boolean operations.Try this two lines:$cek1 = $spotakhir < ($spotawal + $barrierpositif) $cek2 = $spotakhir > ($spotawal + $barriernegatif) still not correct..how to detect if $Spotakhir in between ($spotawal+$barrierpositif / $barriernegatif)?
water Posted August 1, 2015 Posted August 1, 2015 Another problem of your script is that you are comparing strings.This works for me:$iCompareValue = 1003 $iCurrentValue = 1006.99 $iPlus = "4" $iMinus = "-4" ; Valid Range is 1003-4 to 1003+4 = 999 to 1007 If $iCurrentValue < ($iCompareValue + $iPlus) And $iCurrentValue > ($iCompareValue + $iMinus) Then ConsoleWrite("Within Bounds!" & @CRLF) Else ConsoleWrite("Out of Bounds!" & @CRLF) EndIf My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Bowmore Posted August 1, 2015 Posted August 1, 2015 I don't know if I'm understanding the question correctly, but I think this will workhitung() func hitung() $spotawal = "1003.5209" $spotakhir = "1001.6473" $barrierpositif = "4" $barriernegatif = "-4" $cek1 = ($spotakhir) < ($spotawal + $barrierpositif) $cek2 = ($spotakhir) > ($spotawal + $barriernegatif) if $cek1 = true AND $cek2 = true then ;<===== Changed OR to AND consolewrite("SPOTAKHIR must be betweeN"&@CRLF) consolewrite("Hasilnya adalah TRUE"&@CRLF) consolewrite("======================================================================================================="&@CRLF) Else consolewrite("Hasilnya adalah FALSE"&@CRLF) consolewrite("======================================================================================================="&@CRLF) EndIf EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now