Page 1 of 1

Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 4:58 pm
by akira463
Hello again sir, Im having a hard time working on this project. my problem is, even the comment "Counter" is equal to 0 "Zero" the log shows that it has to be paid, and also if you paid not equal to the "Counter" it displays as balance and also needs to be paid, what could be wrong in my code? please do help, thankyou!
:local newMess   "You have received PHP 1600.00 of GCash from JO*MSG: 2021001. Your new balance is PHP 1649.00. Ref. No. 3007882128690."
:local amount [:pick $newMess ([:find $newMess "PHP "] + 4) [:find $newMess ".00 of GCash"]]
:local sender [:pick $newMess ([:find $newMess ". "] + 2) [:find $newMess  " w/"]]

[/ppp secret set "annexOffice" comment=$newComm]

:if ($cost <= 0) do={
	
	:log warning "We receive your payment amounting of $amount.00 Pesos, your credit is $total.00 Pesos your account will be now re-activated"
	[/sys scr run [find name="annexOffice"]]


} else={
	
	[/ppp secret set "annexOffice" comment=$newComm]
	:log warning "Please settle your balances amounting of $total.00 Pesos"
	
}
mik error.png

Re: Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 5:18 pm
by rextended
It's time to do some math...

debug code

{
:local newMess "You have received PHP 1600.00 of GCash from JO**E J* P. 09360442315 w/ MSG: 2021001. Your new balance is PHP 1649.00. Ref. No. 3007882128690."
:local amount [:pick $newMess ([:find $newMess "PHP "] + 4) [:find $newMess ".00 of GCash"]]
:local sender [:pick $newMess ([:find $newMess ". "] + 2) [:find $newMess  " w/"]]
:local accMsg [:pick $newMess ([:find $newMess "MSG: "] + 5) [:find $newMess ". Your new"]]
:local ref [:pick $newMess ([:find $newMess "Ref. No. "] + 9) ([:len $newMess] - 1)]
:put $newMess
:put $amount 
:put $sender 
:put $accMsg 
:put $ref 

:local comm "Acc Number: 2021001 Plan: 35mbps Cost: -1601"
:local accNum [:pick $comm ([:find $comm "Number: "] + 8 ) [:find $comm " Plan:"]]
:local cost [:pick $comm ([:find $comm "Cost: "] + 6) ([:len $comm])]
:local total ([$cost] - [$amount])
:put $comm
:put $accNum
:put $cost 
:put $total
:put "\$cost ($cost) - \$amount ($amount) = \$total ($total)"
}

terminal results code

You have received PHP 1600.00 of GCash from JO**E J* P. 09360442315 w/ MSG: 2021001. Your new balance is PHP 1649.00. Ref. No. 3007882128690.
1600
09360442315
2021001
3007882128690
Acc Number: 2021001 Plan: 35mbps Cost: -1601
2021001
-1601
-3201
$cost (-1601) - $amount (1600) = $total (-3201)

Is wanted -3201 ???
Or probably $total must be $cost + $amunt, because cost is already negative?

Re: Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 5:21 pm
by akira463
Thankyou sir , for your quick reply.! im gonna analyze again my code, thankyou,

Re: Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 5:24 pm
by rextended
Thankyou sir , for your quick reply.! im gonna analyze again my code, thankyou,
Probably this two points:

:local total ([$cost] - [$amount])
must be
:local total ([$cost] + [$amount])

and
:if ($cost <= 0) do={
probably must be the ckeck of the total, the balance, not the cost...
:if ($total >= 0) do={

and
:log warning "Please settle your balances amounting of $total.00 Pesos"
become
:log warning "Please settle your balances amounting of $($total * -1).00 Pesos"

Re: Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 5:25 pm
by akira463
My problem is, when "Cost" counter hit zero or negative amount , it logs that i have remaining balance of 0.00 Pesos. i do want to log it as "Payment receive your account is now activated" it balance is = equal to zero or -negative amount

Re: Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 5:26 pm
by rextended
read previous post, and please remove quote on your previous post, and do not quote all block when is useless.

Re: Script issue, 0 value turns to be false value?

Posted: Sat Jan 28, 2023 5:45 pm
by akira463
It works now sir!!! Thankyou for your help! I hope someday i can repay you, God Bless you !