Subject |
Re: how to cripple a dbf |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Wed, 13 Aug 2014 17:33:53 +0200 |
Newsgroups |
dbase.getting-started |
On Wed, 13 Aug 2014 00:31:38 +0200, David <carney50@mchsi.com> wrote:
> What if I wanted to sell 2 versions of a program?
> One regular & one upgraded?
> Looking at limiting number of records - to perhaps 50?
> Is there a better way?
>
In the example below I've used # preprocessor commands to limit records in
the trial version but you could use a value saved in, say, a .ini file to
do the same thing.
Mervyn
******** Start of limited_recs.wfm *************
if file('limited.dbf')
drop table limited
endif
if not file('limited.dbf')
create table limited (data1 character(15))
endif
#define TRIAL //comment out for full version
** END HEADER -- do not remove this line
//
// Generated on 2014/08/13
//
parameter bModal
local f
f = new limited_recsForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class limited_recsForm of FORM
with (this)
height = 19.6364
left = 53.8571
top = 5.1818
width = 45.7143
text = ""
endwith
this.LIMITED1 = new QUERY()
this.LIMITED1.parent = this
with (this.LIMITED1)
left = 2.1429
top = 0.3636
sql = 'select * from "limited.DBF"'
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.limited1.rowset
height = 10.4091
left = 9.0
top = 0.8182
width = 27.5714
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 1.0909
left = 13.0
top = 12.3182
width = 19.1429
text = "Append 50 records"
endwith
this.PUSHBUTTON2 = new PUSHBUTTON(this)
with (this.PUSHBUTTON2)
onClick = class::PUSHBUTTON2_ONCLICK
enabled = false
height = 1.0909
left = 13.0
top = 14.0
width = 19.1429
text = "Append 1 record"
endwith
this.PUSHBUTTON3 = new PUSHBUTTON(this)
with (this.PUSHBUTTON3)
onClick = class::PUSHBUTTON3_ONCLICK
height = 1.0909
left = 13.0
top = 15.6818
width = 19.1429
text = "Delete a record"
endwith
this.rowset = this.limited1.rowset
function PUSHBUTTON1_onClick
for n = 1 to 50
form.limited1.rowset.beginAppend()
form.limited1.rowset.fields["data1"].value = "Record "+n
form.limited1.rowset.save()
next
this.enabled = false
form.pushbutton2.enabled = true
return
function PUSHBUTTON2_onClick
#ifdef TRIAL
if class::countRows() >= 50
msgbox("Trial version limited to 50 records.")
return
endif
#endif
form.limited1.rowset.beginAppend()
form.limited1.rowset.fields["data1"].value = "New Record "
form.limited1.rowset.save()
return
function PUSHBUTTON3_onClick
form.limited1.rowset.delete()
return
function countRows
q = new query()
q.sql = 'select count(*) from limited'
q.active = true
nRows = q.rowset.fields[1].value
q.active = false
q = null
return nRows
endclass
*********** End of example code ********
|
|