Community discussions

MikroTik App
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Script issue, 0 value turns to be false value?

Sat Jan 28, 2023 4:58 pm

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
You do not have the required permissions to view the files attached to this post.
Last edited by akira463 on Sat Jan 28, 2023 5:44 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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

Sat Jan 28, 2023 5:18 pm

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?
Last edited by rextended on Sat Jan 28, 2023 5:21 pm, edited 1 time in total.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

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

Sat Jan 28, 2023 5:21 pm

Thankyou sir , for your quick reply.! im gonna analyze again my code, thankyou,
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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

Sat Jan 28, 2023 5:24 pm

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"
Last edited by rextended on Sat Jan 28, 2023 5:25 pm, edited 1 time in total.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

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

Sat Jan 28, 2023 5:25 pm

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
Last edited by akira463 on Sat Jan 28, 2023 5:33 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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

Sat Jan 28, 2023 5:26 pm

read previous post, and please remove quote on your previous post, and do not quote all block when is useless.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

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

Sat Jan 28, 2023 5:45 pm

It works now sir!!! Thankyou for your help! I hope someday i can repay you, God Bless you !

Who is online

Users browsing this forum: No registered users and 21 guests