I have been practising writing some code.
This is the code I have written...
What I want it to do is go through the contact table records from top to bottom and then enter values into a transaction table for each contact. It checks to see a type of contact .. whether its a supplier or a client.
If its a client then it writes subscription in the description field and 50 in the flddebit field
If its a supplier then it writes invoice in the description field and 100 in the flddebit field.
What I have noticed is that when it makes its evaluation. . .it will write the first record fine.
If the type of the contact next record is different....then it stops.
ie contact 1 = supplier the script will run onto the next record (completing the action in the transaction table)
contact 2 = supplier the script will add that to the transaction table..
contact 3 = client....the script will not add this record in at all and the script stops.
I have attached the database for those that are interested to have a look. I would be most grateful.....and also..in the field that reads contactid in the code...how do I get that to have the contactid at the record the script is at...at the time?
Your help is most appreciated.
And thanks to Tom Cone Jr who has spent the time with me .... I have just started to grasp how the structure and flow of Xbasic works and eager to get my hands dirty.
training database.zip
This is the code I have written...
Code:
'Date Created: 06-Aug-2011 11:04:27 PM 'Last Updated: 07-Aug-2011 01:17:42 AM 'Created By : weiyentan 'Updated By : weiyentan 'This script goes thru all the contacts and enters the contact id to the transaction table. dim contacttbl as p dim transtbl as p contacttbl = table.open("contact") transtbl = table.open("transactions") contacttbl.fetch_first() WHILE .not. contacttbl.fetch_eof() SELECT CASE contacttbl.type = "Client" transtbl.enter_begin() transtbl.contactid = "contacttbl.contactid_field.value" transtbl.description = "Subscription Fee" transtbl.flddebit = 50 transtbl.enter_end(.T.) CASE contacttbl.type = "Supplier" transtbl.enter_begin() transtbl.contactid = "contacttbl.contactid_field.value" transtbl.fldcredit = 100 transtbl.description = "Invoice" transtbl.enter_end(.T.) END Case END SELECT contacttbl.fetch_next() END WHILE transtbl.close() contacttbl.close()
If its a client then it writes subscription in the description field and 50 in the flddebit field
If its a supplier then it writes invoice in the description field and 100 in the flddebit field.
What I have noticed is that when it makes its evaluation. . .it will write the first record fine.
If the type of the contact next record is different....then it stops.
ie contact 1 = supplier the script will run onto the next record (completing the action in the transaction table)
contact 2 = supplier the script will add that to the transaction table..
contact 3 = client....the script will not add this record in at all and the script stops.
I have attached the database for those that are interested to have a look. I would be most grateful.....and also..in the field that reads contactid in the code...how do I get that to have the contactid at the record the script is at...at the time?
Your help is most appreciated.
And thanks to Tom Cone Jr who has spent the time with me .... I have just started to grasp how the structure and flow of Xbasic works and eager to get my hands dirty.
training database.zip
Comment