iCheck — File Browser
iCheckv1.0 / iCheckv1.0 / iCheck / iCheck.mrc
iCheck.mrc — 12.47 KB — Download this file
ON *:LOAD: { echo -a [ Thanks for using iCheck! View menubar > iCheck to get started! ] }
dialog icheck.add {
title "iCheck Add Entry"
size -1 -1 115 74
option dbu
box "", 1, 1 1 113 58
text "Check #:", 2, 4 8 35 8
edit "", 3, 42 6 70 10, autohs
text "Date:", 4, 4 18 35 8
edit "", 5, 42 16 70 10, autohs
text "Comments:", 6, 4 28 35 8
edit "", 7, 42 26 70 10, autohs
text "Type:", 8, 4 38 35 8
text "Amount:", 9, 4 49 35 8
edit "", 10, 42 47 70 10, autohs
button "Add", 11, 84 61 30 12
button "Reset", 12, 1 61 30 12
radio "Withdrawal", 13, 42 37 41 10
radio "Deposit", 14, 83 37 28 10
}
on *:dialog:icheck.add:init:0: { set %icheck.type + | did -c $dname 14 }
on *:dialog:icheck.add:close:*: { unset %icheck.type }
on *:dialog:icheck.add:sclick:*: {
if ($did == 13) { set %icheck.type - }
if ($did == 14) { set %icheck.type + }
if ($did == 11) {
var %check = $iif($did(3),$did(3),0)
var %date = $iif($did(5),$did(5),$adate)
var %comments = $iif($did(7),$did(7),None)
if ($did(10) isnum) { var %amount = $did(10) }
elseif ($did(10) !isnum) { var %error = $input(Incorrect field type: Amount) | return }
if (!$exists($+($scriptdiricheck_users\,%icheck.user,_book.txt))) {
var %before.amount = 0
var %balance = $calc(%before.amount %icheck.type %amount)
write $+(",$scriptdiricheck_users\,%icheck.user,_book.txt,") $+(%check,$chr(174),%date,$chr(174),%comments,$chr(174),%icheck.type,$chr(174),%amount,$chr(174),%balance)
load.book | dialog -x $dname $dname
}
else {
var %before.amount = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),$lines($+($scriptdiricheck_users\,%icheck.user,_book.txt))),6,174)
var %balance = $calc(%before.amount %icheck.type %amount)
write $+(",$scriptdiricheck_users\,%icheck.user,_book.txt,") $+(%check,$chr(174),%date,$chr(174),%comments,$chr(174),%icheck.type,$chr(174),%amount,$chr(174),%balance)
load.book | dialog -x $dname $dname
}
}
}
dialog icheck.main {
title "iCheck"
size -1 -1 250 122
option dbu
box "", 1, 1 1 248 102
list 2, 4 7 242 93, size extsel
box "", 3, 1 99 248 21
button "Add", 4, 4 105 30 12
button "Remove", 5, 36 105 30 12
button "Reset", 6, 68 105 30 12
button "Logout", 8, 216 105 30 12, ok
button "HTML", 9, 100 105 30 12
}
on *:dialog:icheck.main:sclick:*: {
if ($did == 4) { dialog -mdo icheck.add icheck.add }
if ($did == 8) { unset %icheck.user }
if ($did == 6) {
var %true = $?!="Are you sure you wish to delete all entries?"
if (%true == $true) {
var %true = $?="New balance?"
write -c $+(",$scriptdiricheck_users\,%icheck.user,_book.txt")
write $+(",$scriptdiricheck_users\,%icheck.user,_book.txt") $+(0,$chr(174),$adate,$chr(174),Reset,$chr(174),+,$chr(174),%true,$chr(174),%true)
load.book
}
}
if ($did == 5) {
var %line = $?="What line number do you want to remove?"
var %origin = %line
var %sign = $iif($gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),4,174) == +,-,+)
var %amount = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),5,174)
inc %line
while ($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line)) {
var %temp.check = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),1,174)
var %temp.date = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),2,174)
var %temp.why = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),3,174)
var %temp.sign = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),4,174)
var %temp.amount = $gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),5,174)
var %temp.balance = $calc($gettok($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%line),6,174) %sign %amount)
write -dl $+ %line $+(",$scriptdiricheck_users\,%icheck.user,_book.txt")
write -il $+ %line $+(",$scriptdiricheck_users\,%icheck.user,_book.txt") %temp.check $+ $chr(174) $+ %temp.date $+ $chr(174) $+ %temp.why $+ $chr(174) $+ %temp.sign $+ $chr(174) $+ %temp.amount $+ $chr(174) $+ %temp.balance
inc %line
}
.timer -m 1 1 load.book
write -dl $+ %origin $+(",$scriptdiricheck_users\,%icheck.user,_book.txt")
}
if ($did == 9) { icheck.html }
}
on *:dialog:icheck.main:close:*: { unset %icheck.user }
on *:dialog:icheck.main:init:0: {
_mdx.load
dll icheck\mdx.dll SetControlMDX 2 ListView report grid showsel > icheck\views.mdx
did -i $dname 2 1 headerdims 70:1 70:2 170:3 70:4 100:5
did -i $dname 2 1 headertext +c Check $+ $chr(9) $+ +c Date $+ $chr(9) $+ +c Comments $+ $chr(9) $+ +c Amount $+ $chr(9) $+ +c Balance
if (%icheck.user) {
load.book
}
if (!%icheck.user) { var %error = $input(No one is logged in!) | dialog -mdo icheck.login icheck.login }
}
dialog icheck.login {
title "iCheck Login"
size -1 -1 102 44
option dbu
box "", 1, 1 1 100 30
text "Username:", 2, 4 8 25 8
edit "", 3, 31 7 68 10, autohs
text "Password:", 4, 4 19 25 8
edit "", 5, 31 18 68 10, autohs pass
button "Login", 6, 71 33 30 10
button "New", 7, 1 33 30 10
button "List", 8, 32 33 30 10
}
on *:dialog:icheck.login:sclick:*: {
if ($did == 8) { dialog -mdo icheck.list icheck.list }
if ($did == 7) { dialog -mdo icheck.create icheck.create }
if ($did == 6) && ($did(3)) && ($did(5)) {
if (!%icheck.user) {
if ($userexist($did(3))) && ($password($did(3)) == $did(5)) {
set %icheck.user $replace($did(3),$chr(32),$chr(95))
echo -a *** [ Successfully logged $did(3) in! ] | dialog -md icheck.main icheck.main
}
elseif (!$userexist($did(3))) { var %error = $input(That username does not exist!) }
}
elseif (%icheck.user) { var %error = $input(Someone is already logged in!) }
}
}
dialog icheck.list {
title "User List"
size -1 -1 52 44
option dbu
list 1, 1 1 50 42, size
}
on *:dialog:icheck.list:init:0: {
var %i = 1
while ($read($scriptdiricheck_userlist.txt,%i)) {
did -a $dname 1 $gettok($read($scriptdiricheck_userlist.txt,%i),1,174)
inc %i
}
}
dialog icheck.create {
title "iCheck Create"
size -1 -1 102 44
option dbu
box "", 1, 1 1 100 30
text "Username:", 2, 4 8 25 8
edit "", 3, 31 7 68 10, autohs
text "Password:", 4, 4 19 25 8
edit "", 5, 31 18 68 10, pass autohs
button "Create", 6, 71 33 30 10
button "Reset", 7, 1 33 30 10
}
on *:dialog:icheck.create:sclick:*:{
if ($did == 7) { did -r $dname 3 | did -r $dname 5 }
if ($did == 6) && ($did(3)) && ($did(5)) {
if ($userexist($did(3))) { var %error = $input(That username is already in use!) }
elseif (!$userexist($did(3))) { write $+(",$scriptdiricheck_userlist.txt,") $did(3) $+ $chr(174) $+ $did(5) | dialog -x $dname $dname | var %success = $input(Creation successful!) }
}
elseif ($did == 6) && (!$did(3)) || (!$did(5)) { var %error = $input(Please fill in all fields!) }
}
; Alias
alias load.book {
did -r icheck.main 2
var %i = 1
while ($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%i)) {
var %read = $read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%i)
did -a icheck.main 2 + 0 0 0 $gettok(%read,1,174) $+ $chr(9) $+ + 0 0 0 $gettok(%read,2,174) $+ $chr(9) $+ + 0 0 0 $gettok(%read,3,174) $+ $chr(9) $+ + 0 0 0 $gettok(%read,4,174) $gettok(%read,5,174) $+ $chr(9) $+ + 0 0 0 $gettok(%read,6,174)
inc %i
}
}
alias password {
return $gettok($read($scriptdiricheck_userlist.txt,w,$+(*,$1-,*)),2,174)
}
alias userexist {
if ($1) {
var %i = 1
while ($read($scriptdiricheck_userlist.txt,%i)) {
if ($gettok($read($scriptdiricheck_userlist.txt,%i),1,174) != $1-) { inc %i }
elseif ($gettok($read($scriptdiricheck_userlist.txt,%i),1,174) == $1-) { return exists | inc %i }
}
}
}
alias _mdx.load { dll $+(",$scriptdirmdx.dll,") SetMircVersion $version | dll $+(",$scriptdirmdx.dll,") MarkDialog $dname }
alias icheck.html {
write -c $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html")
var %read = $read($+($scriptdiricheck_users\,%icheck.user,_book.txt),$lines($+($scriptdiricheck_users\,%icheck.user,_book.txt)))
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <html>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <head>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <title>iCheck - $replace(%icheck.user,_,$chr(32)) </title>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") </head>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <body>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <table width="80%" border="1" align="center" cellpadding="0" cellspacing="7" bordercolor="#FFFFFF">
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <tr bordercolor="#000000">
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td height="20" colspan="5" bgcolor="#000066"><div align="center"><font size="1" face="Verdana" color="#FFFFFF">Account: $replace(%icheck.user,_,$chr(32)) <br>Date: $adate $+ <br><br><strong>Current Balance: $ $+ $gettok(%read,6,174) $+ </strong><br><br></font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") </tr>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <tr>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="11%" height="20" bordercolor="#000000" bgcolor="#000099"><div align="center"><font size="1" face="Verdana" color="#FFFFFF">Check</font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="11%" height="20" bordercolor="#000000" bgcolor="#000099"><div align="center"><font size="1" face="Verdana" color="#FFFFFF">Date</font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="45%" height="20" bordercolor="#000000" bgcolor="#000099"><div align="center"><font size="1" face="Verdana" color="#FFFFFF">Comments</font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="16%" height="20" bordercolor="#000000" bgcolor="#000099"><div align="center"><font size="1" face="Verdana" color="#FFFFFF">Amount</font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="17%" height="20" bordercolor="#000000" bgcolor="#000099"><div align="center"><font size="1" face="Verdana" color="#FFFFFF">Balance</font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") </tr>
var %i = 1
while ($read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%i)) {
var %read = $read($+($scriptdiricheck_users\,%icheck.user,_book.txt),%i)
echo -s %read
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <tr>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="11%" height="20" bordercolor="#000000"><div align="center"><font size="1" face="Verdana"> $+ $gettok(%read,1,174) $+ </font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="11%" height="20" bordercolor="#000000"><div align="center"><font size="1" face="Verdana"> $+ $gettok(%read,2,174) $+ </font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="45%" height="20" bordercolor="#000000"><div align="center"><font size="1" face="Verdana"> $+ $gettok(%read,3,174) $+ </font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="16%" height="20" bordercolor="#000000"><div align="center"><font size="1" face="Verdana"> $+ $gettok(%read,4,174) $+ $gettok(%read,5,174) $+ </font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") <td width="17%" height="20" bordercolor="#000000"><div align="center"><font size="1" face="Verdana"> $+ $gettok(%read,6,174) $+ </font></div></td>
write $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html") </tr>
inc %i
}
run $+(",$scriptdiricheck_,%icheck.user,$date(_mm_dd_yy),.html")
}
; Menu
Menu status,channel,menubar {
iCheck
.Login: { dialog -mdo icheck.login icheck.login }
.Userlist: { dialog -mdo icheck.list icheck.list }
.Create New: { dialog -mdo icheck.create icheck.create }
.-
.Unload: {
remove $scriptdiricheck_userlist.txt
remove $scriptdirmdx.dll
remove $scriptdiriews.mdx
/unload -rs icheck.mrc
}
}