Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sat Mar 02, 2002 11:31 pm   

DB Skeleton
 
I got this nasty mental block and databases. I either fry conceptually or bloat
what I'm doing beyond a reasonable doubt. Would someone mind giving me a skeleton
for:

Fields:
ShortName - %x kind of field
LongName - sentence with %x words
AmountDue - %d
AmountCollected - %d
AmountPastDue - %d
AmountCredit - %d

Alias to be able to find the database record given either the unique ShortName or
unique LongName.

Process the collected money alias:
Apply the number of [AmountCredit+AmountCollected] to AmountPastDue then
if there is any left apply it to AmountDue then
if there is any left add it to AmountCredit.

A simple database exercise but I've been spinning for the past 2 hours.
Either not enough coffee or not enough sleep

TonDiening
Beta Upgrading to 6.26
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Sun Mar 03, 2002 8:35 am   
 
If I understand your algorithm correctly, this should do the job:



#AL doAccounts {
#DBLOAD Ac
#QUERY ((&ShortName = "%-1")|(&LongName = "%-1")) All 1
#MATH temp (&AmountCredit + &AmountCollected - &AmountPastDue)
&AmountPastDue = %max(0, %eval(&AmountPastDue - &AmountCredit - &AmountCollected))
#IF (@temp > 0) {
#MATH temp2 (@temp - &AmountDue)
&AmountDue = %max(0, %eval(&AmountDue - @temp))
#IF (@temp2 > 0) {&AmountCredit = %eval(&AmountCredit + @temp2)}
}
}


Troubadour
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sun Mar 03, 2002 12:01 pm   
 
Heh 4 hours later and still bloat/fry :)

Off to read the zMud help files, I have a conceptual error in my head.

To process all rents, I'm using #LOOPVIEW {} and that seems to yield
odd results.

TonDiening
Beta Upgrading to 6.26
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sun Mar 03, 2002 12:51 pm   
 
#LOOPVIEW {..process..} didn't let me "process" the rent.

But this worked:
#DBFIRST;#WHILE (!%null(%rec)) {..process..;#DBNEXT}

TonDiening
Beta Upgrading to 6.26
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sun Mar 10, 2002 4:57 am   
 
Any reason why:
#DBFIRST;#WHILE (!%null(%rec)) {..process..;#DBNEXT}

Would jump about? Checking through my logs
has it going through 1-10 then back to 3-10.

Other times it has jumped about.

I have no filters and I #DBRESET before doing
the #LOOPVIEW

TonDiening
Beta Upgrading to 6.26
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Mon Apr 15, 2002 8:39 am   
 
Today was another day that the rent processed
in a weird way:

#DBRESET;#DBFIRST;#WHILE (!%null(%rec)) {..process..;#DBNEXT}

Do_daily_rent Monday April 15, 2002 3:00:00 am, Last: 15 Apr 2002 03 00 am
-----------------
1
11

12
101
184
187
188
194
209
211
212
213
214
215
218
221
222
226
10
11
12
101
184
187
188
194
209
211
212
213
214
215
218
221
222
226

The only thing I noticed is that person record
number 10 gave me money before I did rent
so record 10 showed up last when viewing
the database records.

Sounds like it hit 10 then went on to 11.
This sounds like a bug or function of filters
which I use none. What is the easiest way
to put all the records in order before I
go through them and process the rent?

Ton Diening
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net