Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8175eb3

Browse files
committed
Update Pgaccess to 0.83
1 parent c24ed70 commit 8175eb3

File tree

6 files changed

+494
-175
lines changed

6 files changed

+494
-175
lines changed

src/bin/pgaccess/README.pga

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
2424

2525

2626

27-
PGACCESS 0.82 1 March 1998
27+
PGACCESS 0.83 11 March 1998
2828
================================
2929
I dedicate this program to my little 4 year daughter Ana-Maria and my wife
3030
for their understanding. I hope they will forgive me for spending so many
@@ -128,7 +128,7 @@ Reports
128128
Forms
129129
- open user defined forms
130130
- form design module available
131-
- query widget qlowing access to a recordset
131+
- query widget allowing access to a recordset
132132

133133
Scripts
134134
- define, modify and call user defined scripts

src/bin/pgaccess/formdemo.sql

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
CREATE TABLE pga_queries (queryname varchar(64), querytype char(1), querycommand text);
2+
CREATE TABLE pga_forms (formname varchar(64), formsource text);
3+
CREATE TABLE pga_scripts (scriptname varchar(64), scriptsource text);
4+
CREATE TABLE pga_reports (reportname varchar(64), reportsource text, reportbody text, reportprocs text, reportoptions text);
5+
CREATE TABLE phonebook (name varchar(32), phone_nr varchar(16), city varchar(32), company bool, continent char16);
6+
CREATE TABLE pga_layout (tablename varchar(64), nrcols int2, colnames text, colwidth text);
7+
COPY pga_queries FROM stdin;
8+
\.
9+
COPY pga_forms FROM stdin;
10+
Phone book pb 26 {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26} 444x310+284+246 {label label1 {33 12 63 30} {} Name {}} {entry name_entry {87 9 217 30} {} entry2 pbqs(name)} {label label3 {33 39 73 54} {} Phone {}} {entry entry4 {87 36 195 57} {} entry4 pbqs(phone_nr)} {label label5 {33 66 78 84} {} City {}} {entry entry6 {87 63 195 84} {} entry6 pbqs(city)} {query qs {3 6 33 33} {} query7 {}} {button button8 {126 177 198 203} {.pb.qs:setsql "select oid,* from phonebook where name ~* '$what' order by name"\
11+
.pb.qs:open\
12+
set nrecs [.pb.qs:nrecords]\
13+
.pb.qs:updatecontrols\
14+
.pb.qs:fill .pb.allnames name} Find {}} {button button9 {159 276 229 302} {.pb.qs:close\
15+
.pb.qs:clearcontrols\
16+
set nrecs {}\
17+
set what {}\
18+
destroy .pb\
19+
} Exit {}} {button button10 {102 249 124 269} {.pb.qs:movefirst\
20+
.pb.qs:updatecontrols\
21+
} |< {}} {button button11 {129 249 151 269} {.pb.qs:moveprevious\
22+
.pb.qs:updatecontrols\
23+
} << {}} {button button12 {156 249 178 269} {.pb.qs:movenext\
24+
.pb.qs:updatecontrols} >> {}} {button button13 {183 249 205 269} {.pb.qs:movelast\
25+
.pb.qs:updatecontrols\
26+
} >| {}} {checkbox checkbox14 {33 87 126 105} {} {Is it a company ?} pbqs(company)} {radio usa {63 108 201 120} {} U.S.A. pbqs(continent)} {radio europe {63 126 204 141} {} Europe pbqs(continent)} {radio africa {63 144 210 159} {} Africa pbqs(continent)} {entry entry18 {30 180 117 198} {} entry18 what} {label label19 {108 219 188 234} {} {records found} {}} {label label20 {90 219 105 234} {} { } nrecs} {label label21 {3 252 33 267} {} OID= {}} {label label22 {39 252 87 267} {} { } pbqs(oid)} {button button23 {9 276 79 302} {set oid {}\
27+
catch {set oid $pbqs(oid)}\
28+
if {[string trim $oid]!=""} {\
29+
sql_exec noquiet "update phonebook set name='$pbqs(name)', phone_nr='$pbqs(phone_nr)',city='$pbqs(city)',company='$pbqs(company)',continent='$pbqs(continent)' where oid=$oid"\
30+
} else {\
31+
tk_messageBox -title Error -message "No record is displayed!"\
32+
}\
33+
\
34+
} Update {}} {button button24 {84 276 154 302} {set thisname {}\
35+
catch {set thisname $pbqs(name)}\
36+
if {[string trim $thisname]!=""} {\
37+
sql_exec noquiet "insert into phonebook values ('$pbqs(name)','$pbqs(phone_nr)','$pbqs(city)','$pbqs(company)','$pbqs(continent)')"\
38+
tk_messageBox -title Information -message "A new record has been added!"\
39+
} else {\
40+
tk_messageBox -title Error -message "This one doesn't have a name ?\
41+
}\
42+
\
43+
} {Add new} {}} {button button25 {168 111 231 135} {.pb.qs:clearcontrols\
44+
# clearcontrols stillinitialise\
45+
# incorectly booleans controls to {}\
46+
# so I force it to 'f' (false)\
47+
set pbqs(company) f\
48+
focus .pb.name_entry} New {}} {listbox allnames {246 12 432 240} {} listbox26 {}}
49+
A simple demo form asdf 14 {1 2 3 4 5 6 7 8 9 10 11 12 13 14} 377x315+170+155 {label label1 {15 36 99 57} {} {Selected color} {}} {entry entry2 {111 36 225 54} {} entry2 color} {radio red {249 21 342 36} {} {Red as cherry} color} {radio green {249 45 342 60} {} {Green as a melon} color} {radio blue {249 69 342 84} {} {Blue as the sky} color} {button button6 {45 69 198 99} {set color spooky} {Set a weird color} {}} {label label7 {24 129 138 147} {} {The checkbox's value} {}} {entry entry8 {162 129 172 147} {} entry8 cbvalue} {checkbox checkbox9 {180 126 279 150} {} {Check me :-)} cbvalue} {button button10 {219 273 366 303} {destroy .asdf} {Close that simple form} {}} {button button11 {219 237 366 267} {open_form "Phone book"} {Open my phone book} {}} {listbox lb {12 192 162 267} {} listbox12 {}} {button button13 {12 156 162 186} {.asdf.lb insert end red green blue cyan white navy black purple maroon violet} {Add some information} {}} {button button14 {12 273 162 303} {.asdf.lb delete 0 end} {Clear this listbox} {}}
50+
\.
51+
COPY pga_scripts FROM stdin;
52+
How are forms keeped inside ? open_table pga_forms\
53+
\
54+
55+
\.
56+
COPY pga_reports FROM stdin;
57+
\.
58+
COPY phonebook FROM stdin;
59+
IBM 623346234 \N t usa
60+
John Doe +44 35 2993825 Washington f usa
61+
Bill Clinton +44 35 9283845 New York f usa
62+
Monica Levintchi +44 38 5234526 Dallas f usa
63+
Bill Gates +42 64 4523454 Los Angeles f usa
64+
COMPAQ 623462345 \N t usa
65+
SUN 784563253 \N t usa
66+
DIGITAL 922644516 \N t usa
67+
FIAT 623463445 \N t europe
68+
MUGADUMBU +92 534662634 \N t africa
69+
Frank Zappa 6734567 Montreal f usa
70+
Jimmy Page 66323452 f europe
71+
Constantin Teodorescu +40 39 611820 Braila f europe
72+
NGBENDU Wazabanga 34577345 \N f africa
73+
\.
74+
COPY pga_layout FROM stdin;
75+
pga_forms 2 formname formsource 82 713
76+
phonebook 5 name phone_nr city company continent 150 105 80 66 85
77+
\.

src/bin/pgaccess/forms.html

Lines changed: 189 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,224 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
12
<HTML>
23
<HEAD>
4+
<TITLE></TITLE>
35
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
4-
<META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i586) [Netscape]">
6+
<META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.32 i586) [Netscape]">
57
</HEAD>
68
<BODY TEXT="#000000" BGCOLOR="#FFEBCD" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
79

8-
<H1>
9-
FORMS</H1>
10+
<H1>FORMS</H1>
1011

11-
<HR WIDTH="100%">
12+
<P>
13+
<HR WIDTH="100%"></P>
1214

13-
<P>This version (0.82) of PgAccess introduce the visual form builder.
15+
<P>This version (0.83) of PgAccess has changed a little the visual form
16+
builder introduced since 0.82 version : variable handling, query-results
17+
interface and control bindings naming convention. Please read it carefully,
18+
download the database demo and practice a while before trying to design
19+
your own forms.</P>
1420

1521
<P>For the moment, it has only some basic widgets : labels, entries, buttons
16-
, listboxes , checkboxes and radiobuttons.
22+
, listboxes , checkboxes and radiobuttons.</P>
23+
24+
<P>Also there is a pseudo query widget that allows you yo have access to
25+
a query results. </P>
26+
27+
<P><B>How do you generate widgets :</B></P>
28+
29+
<OL>
30+
<LI>select a widget from the toolbox by clicking the appropriate radiobutton</LI>
31+
32+
<LI>move to the canvas , point with the mouse at the desired location and
33+
click the mouse button to begin</LI>
34+
35+
<LI>keeping the mouse-button pressed move the mouse in order to draw a
36+
rectangle that will hold the widget</LI>
1737

18-
<P>Also there is a query widget that allows you yo have access to a query
19-
results.
38+
<LI>release the mouse-button </LI>
39+
</OL>
2040

21-
<P>In a manner very similar with Visual Tcl or Visual Basic, the user must
22-
select a widget from the toolbar and drags on the canvas the rectangle
23-
that would define the widget. It can also specify some attributes in a
24-
separate window. Renaming, resizing items are possible modifying parameters
25-
in attribute window. Do not forget to press Enter in the edit field after
26-
changing a value in order to be accepted.
41+
<P>In the rectangle that you have designed it will appear the selected
42+
object.<BR>
43+
Move now to the attribute window to change some of its properties.</P>
44+
45+
<P>Renaming, resizing items are possible (for the moment) only by modifying
46+
appropriate parameters in attribute window. You <B>must </B>press Enter
47+
in the edit field after changing a value in order to be accepted. </P>
2748

2849
<P>You can also move items by dragging them or delete them by pressing
29-
Del key.
50+
Del key after selecting them.</P>
3051

3152
<P>In attribute window, there are some fields named <B><TT><FONT SIZE=+1>Command
32-
</FONT></TT></B>and <B><TT><FONT SIZE=+1>Variable</FONT></TT></B>.
53+
</FONT></TT></B>and <B><TT><FONT SIZE=+1>Variable</FONT></TT></B>. </P>
3354

3455
<P>The field <B><TT><FONT SIZE=+1>Command </FONT></TT></B>have meaning
3556
only for Button widgets and holds the command that will be invoked when
36-
the button is pressed.
37-
38-
<P>The field <B><TT><FONT SIZE=+1>Variable </FONT></TT></B>have meaning
39-
only for EditField , Label widgets and checkboxes and it is the name of
40-
the global variable that will hold the value for that widget. For checkboxes
41-
the values are 1 or 0.
42-
43-
<P>In order to make a simple test, put an entry field and set it's variable
44-
to <B>v1</B> and a button who's command is "set v1 whisky". Press the button
45-
"Test form" and click on the button. In that entry should appear whisky.
46-
<BR>Another test is defining in Script module a script called "My first
47-
script" having the following commands:
48-
<BR><TT><FONT SIZE=+1>tk_messageBox -title Warning -message "This is my
49-
first message!"</FONT></TT>
50-
<BR>and then define a button who's command is <B><TT><FONT SIZE=+1>execute_script
51-
"My first script"</FONT></TT></B>.
52-
<H2>
53-
Database manipulation</H2>
54-
Let's presume that our form have the internal name <B><TT>mf </TT></B>(my
55-
form). He wil be referred inside the Tcl/Tk source as <B><TT>.mf</TT></B>
56-
<BR>If you want to close the form in run-time you have to issue the command
57-
<B><TT>destroy .mf</TT></B>
57+
the button is pressed. </P>
58+
59+
<P>&nbsp;&nbsp;&nbsp;&nbsp;The field <B><TT><FONT SIZE=+1>Variable </FONT></TT></B>have
60+
meaning only for EditField , Label widgets , checkboxes and radiobuttons
61+
and it is the name of the global variable that will hold the value for
62+
that widget. For checkboxes the values are <B>t</B> and <B>f</B> (from
63+
true and false) in order to simplify binding to logical data fields (PgAccess
64+
0.82 used 0 and 1).</P>
65+
66+
<P>&nbsp;&nbsp;&nbsp;&nbsp;For radiobuttons, it is usual to assign the
67+
same variable to the same radiobuttons within the same group. That variable
68+
will contain the name of the widget of the radiobutton that has been pressed.
69+
Let's presume that you have entered 3 radiobuttons named red, green and
70+
blue, all of them having the same variable named color. If you will press
71+
them, they will assign their names to global variable.</P>
72+
73+
<P>&nbsp;&nbsp;&nbsp;&nbsp;In order to make a simple test, put an entry
74+
field and set it's variable to <B>v1</B> and a button who's command is
75+
&quot;set v1 whisky&quot;. Press the button &quot;Test form&quot; and click
76+
on the button. In that entry should appear whisky. <BR>
77+
Another test is defining in Script module a script called &quot;My first
78+
script&quot; having the following commands: <BR>
79+
<TT><FONT SIZE=+1>tk_messageBox -title Warning -message &quot;This is my
80+
first message!&quot;</FONT></TT> <BR>
81+
and then define a button who's command is <B><TT><FONT SIZE=+1>execute_script
82+
&quot;My first script&quot;</FONT></TT></B>. </P>
83+
84+
<H2>Database manipulation</H2>
85+
86+
<P>Let's presume that our form have the internal name <B><TT>mf </TT></B>(my
87+
form). He will be referred inside the Tcl/Tk source as <B><TT>.mf</TT></B>
88+
<BR>
89+
If you want to close the form in run-time you have to issue the command
90+
<B><TT>destroy .mf</TT></B> </P>
5891

5992
<P>Also, any widget will have the name prefixed by <B><TT>.mf&nbsp;</TT></B>&nbsp;&nbsp;&nbsp;&nbsp;
6093
We will have <B><TT>.mf.button1</TT></B> or <B><TT>.mf.listbox1</TT></B>
61-
.
94+
. </P>
6295

6396
<P>We can name the query widget <B><TT>qry</TT></B> for example. The complete
64-
name will be <B><TT>.mf.qry</TT></B> then.
65-
<BR>The <B><TT>Command </TT></B>property of the query widget must contain
66-
the SQL command that will be executed.
67-
<BR>When the form will be in run-time, automatically you will have acces
68-
to the following methods :
69-
70-
<P><TT>.mf.qry:execute</TT> - opens the connection and execute the query
71-
(returns nothing)
72-
<BR><TT>.mf.qry:nrecords</TT> - returns the number of records in the selected
73-
query
74-
<BR><TT>.mf.qry:fields</TT> - returns a list of the fields in the result
75-
set
76-
<BR><TT>.mf.qry:movefirst</TT> - move the cursor to the first record in
77-
the recordset
78-
<BR><TT>.mf.qry:movelast , .mf.qry:movenext , .mf.qry:moveprevious </TT>-
79-
moves the cursor
80-
<BR><TT>.mf.qry:updatecontrols</TT> - update the variables inside the designed
81-
form that have a particular name (I'll explain later)
82-
<BR><TT>.mf.qry:close</TT> - close the connection (<B><FONT COLOR="#FF0000">if
83-
you don't close the query result, you will loose memory</FONT></B>)
97+
name will be <B><TT>.mf.qry</TT></B> then. <BR>
98+
The <B><TT>Command </TT></B>property of the query widget must contain the
99+
SQL command that will be executed. <BR>
100+
When the form will be in run-time, automatically you will have acces to
101+
the following procedures and functions : </P>
102+
103+
<P><B><TT>.mf.qry:open</TT></B> - opens the connection and execute the
104+
query (returns nothing) <BR>
105+
<B><TT>.mf.qry:setsql newsql</TT></B> - set the command query that will
106+
be executed at the next <B><TT>.mf.qry:open<BR>
107+
.mf.qry:nrecords</TT></B> - returns the number of records in the selected
108+
query <BR>
109+
<B><TT>.mf.qry:crtrecord </TT></B>- returns the current record number inside
110+
the query result<BR>
111+
<B><TT>.mf.qry:fields</TT></B> - returns a list of the fields in the result
112+
set <BR>
113+
<B><TT>.mf.qry:movefirst</TT></B> - move the cursor to the first record
114+
in the recordset <BR>
115+
<TT><B>.mf.qry:movelast</B> , <B>.mf.qry:movenext</B> , <B>.mf.qry:moveprevious</B>
116+
</TT>- moves the cursor there<BR>
117+
<B><TT>.mf.qry:moveto newrecno</TT></B> - move the cursor to that new record
118+
number (first is 0)<BR>
119+
<B><TT>.mf.qry:updatecontrols</TT></B> - update the variables inside the
120+
designed form that have a particular name (I'll explain later) <BR>
121+
<B><TT>.mf.qry:clearcontrols</TT></B> - clear the variables inside the
122+
designed form binded to a query result<BR>
123+
<TT><B>.mf.qry:fill listbox field</B> </TT>- fill the named listbox (whole
124+
widget name as <B><TT>.mf.listbox1</TT></B>) with the all the values of
125+
that field in the current queryresult<BR>
126+
<B><TT>.mf.qry:close</TT></B> - close the connection (<B><FONT COLOR="#FF0000">if
127+
you don't close the query result, you will loose some memory</FONT></B>)
128+
</P>
129+
130+
<P>It's no need to close a query-result if you want to assign it a new
131+
SQL command and open it again. That will be done automatically.</P>
84132

85133
<P>If you want to bound some controls to the fields of the recordset, you
86-
will have to name their associate variable like that :
87-
88-
<P><TT>.mf.qry.salary</TT> to get the "salary" field , or <TT>.mf.qry.name</TT>
89-
to get the "name" field.
90-
91-
<P>It's simple, isn't it ? It's just like a new widget that have some properties
92-
and methods that can be accesed.
93-
<BR>Also, the name convention is just like in Tcl/Tk.
134+
will have to name their associate variable like that : </P>
135+
136+
<P><B><TT>mfqry(salary)</TT></B> to get the &quot;salary&quot; field ,
137+
or <B><TT>mfqry(name)</TT></B> to get the &quot;name&quot; field. So, you
138+
take the internale name of the form (without the leading point) and merge
139+
it with the query-widget name and you will get a associative arrayname.
140+
The values are given using the field name as a key in this associative
141+
array.<BR>
142+
<B><FONT COLOR="#FF0000">* WARNING *</FONT></B> The naming style has been
143+
changed from 0.82 version of PgAccess and I cannot guarantee that it not
144+
be changed again in the future. I'm just trying to make it as simple it
145+
could be. The old style naming convention had some incompatibilities with
146+
Tcl/Tk syntax.</P>
147+
148+
<P><B><FONT SIZE=+1><FONT COLOR="#9400D3">QUESTION</FONT> : </FONT></B>Do
149+
you think that it would be more clear if the above functions and procedures
150+
regarding a query-widget would be named in a similar manner as binded variable
151+
controls ? That mean, <B><TT>mfqry:open</TT></B> and <B><TT>mfqry:updatecontrols</TT></B>
152+
instead of <B><TT>.mf.qry:open</TT></B> and <B><TT>.mf.qry:updatecontrols</TT></B>
153+
?</P>
154+
155+
<P>The only advantage of <B><TT>.mf.qry:open</TT></B> is that is much closer
156+
to the Tk method of referring objects within a window and it may give to
157+
the programmer the feeling that he is using a object-oriented widget. Since
158+
I cannot use further for naming binded variables a similar manner (<B><TT>.mf.qry.salary)</TT></B>
159+
it might be possible to abandon that naming convention .</P>
160+
161+
<P>Here it is a dumped <B><A HREF="formdemo.sql">sample database</A></B>
162+
that contains a demo database. What should you do ?<BR>
163+
Shift-click the above URL in order to download that tiny file (4 Kb). Create
164+
a empty database and <B><TT>psql yourdatabase &lt;formdemo.sql</TT></B></P>
165+
166+
<P>You should find a single table called &quot;phonebook&quot; a form called
167+
&quot;Phone book&quot; and another &quot;A simple demo form&quot;.</P>
168+
169+
<P>First of all enter and view the phonebook table in table view. Note
170+
the fields and their values.<BR>
171+
Open the &quot;Phone book&quot; form and enter a letter (a, e or i) in
172+
the field to the left of &quot;Find&quot; button then press Find. It's
173+
fine to enter one letter in order to get more records in query result.
174+
You will get information about the number of records selected, in the listbox
175+
you will see all the values of field &quot;name&quot; from the current
176+
data set. Use buttons to move to first, next, previous or last record within
177+
the record set.</P>
178+
179+
<P>In order to add a new record, press the &quot;New&quot; button in order
180+
to get new, clean entries. Fill them with your data and press &quot;Add
181+
new&quot; button. A new phonebook record will be added. Also, if you want
182+
to update a record, change it's values in the displayed fields after finding
183+
it and press &quot;Update&quot; button. The values will be updated in the
184+
database BUT NOT IN THE CURRENT QUERY RESULT . If you want to see them
185+
modified, make a new query trying to find it again.</P>
186+
187+
<P><FONT COLOR="#000080">Before using the results from a query you should
188+
know that the information that has been retrieved could be found only in
189+
your computer client memory. It has <B>no live connection</B> to the data
190+
from the database. That's why it isn't possible to develop a simple update
191+
function as interface to that query-result widget. More than that : a query
192+
result could be obtained from a SQL command that return a non-updatable
193+
data set !!! For example fields gathered from multiple tables or summary
194+
fields. It isn't just simple to make an automatic update procedure. The
195+
programmer must know how to make the update or the append procedure, sometimes
196+
using key fields to point to the desired record or an OID. There are examples
197+
in the demo database in &quot;Phone book&quot; form. It may be possible
198+
that in the future, I will develop another pseudo-widget describing a table.
199+
It would be more simple than to implement an update or append or even a
200+
delete procedure.</FONT></P>
201+
202+
<P>There is in the demo database also another simple form called &quot;A
203+
simple demo form&quot;. It will show you how to handle variables from checkboxes,
204+
radiobuttons, how to use listboxes, open another forms and so on. I think
205+
they will help you.</P>
94206

95207
<P>In order to avoid naming user defined forms with&nbsp; a particular
96208
name of another PgAccess form, I would recommend naming them as udf0, udf1
97-
(user defined form 0 , 1 )
209+
(user defined form 0 , 1 ) </P>
98210

99211
<P>
100-
<HR WIDTH="25%">
212+
<HR WIDTH="25%"></P>
101213

102214
<P>Please feel free to send me your oppinion at <B>teo@flex.ro</B> on forms
103-
designing and usage.
215+
designing and usage. </P>
216+
217+
<P><B><FONT SIZE=+1>KEEP IN MIND ! &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THE
218+
FORM API WILL CHANGE IN ORDER TO BE MORE SIMPLE AND BETTER!&nbsp;&nbsp;&nbsp;&nbsp;SEND
219+
ME YOUR WISHES, YOUR IDEAS, YOUR OPINIONS !<BR>
220+
ALSO ... DON'T BLAME ME IF YOU WILL HAVE TO RE-DESIGN YOUR OLD FORMS DUE
221+
TO SOME INCOMPATIBILITIES WITH NEWER PGACCESS VERSIONS.</FONT></B></P>
222+
104223
</BODY>
105224
</HTML>

0 commit comments

Comments
 (0)