|
At 17:29 22.10.2002 -0600, you wrote:
From: "Anton Gombkötö" <gombkoetoe@ASSOFT.COM> http://www.avenum.com/Net.Data/Aktivbereich/Members/abo.html/start Anton, On further thought, your example looks more like a standard HTML form, than a subfile.
Sometimes things ARE NOT what they look like... ;-)
A subfile normally contains repeating records - spanning multiple rows.
Agreed.
But your example contains different fields on every row (the field names are unique).
Aren't they unique, too, when they are called line1, line2, line3? ;-)
It appears that each field, though placed on separate rows, actually corresponds to distinct fields in a single database record.
It appears, yes. But it isn't. I swear! ;-)
The "subfile" - OK, let's stop this nonsense - i call it "table" from now
on - is built up from this file:
A UNIQUE
A R R_EMLSRV
A ESSRVSEQ 3P 0 COLHDG('Sequenz')
A ESSRVNAM 20 COLHDG('Name des Dienstes')
A ESSRVMKT 20 COLHDG('Mailkonto (User-Id)')
A ESSRVHTM 1024 COLHDG('HTML für Blickfang')
A VARLEN(128)
A ESSRVTXT 2048 COLHDG('Kurztext')
A VARLEN(128)
A ESSRVPUB 1 COLHDG('Öffentlich' '0=Nein,1=Ja')
A VALUES('0' '1')
A K ESSRVSEQ
These are the available newsletters. And then i have a file
A UNIQUE
A R R_EMLADRSR
A EASUSRID 10 COLHDG('Benutzer-Id')
A EASSRVNAM 20 COLHDG('Name des Dienstes')
A K EASUSRID
A K EASSRVNAM
that is used to determine whether a user is subscribed (record exists =
subsrcibed).
And the essential part of the Net.Data macro looks like this:
%{************************************************************%}
%FUNCTION(DTW_SQL) ListEMLSRV ( IN USERID) {
SELECT ESSRVSEQ, ESSRVNAM, ESSRVHTM, ESSRVTXT
FROM $(File_EMLSRV) ORDER BY ESSRVSEQ
%REPORT{
<form action="START" method="POST">
<input type="hidden" name="language" value="$(language)">
<table style="line-height:1em;margin:0" border="1" width="100%"
cellpadding="3">
<tr><th colspan="4" align="left">$(Newsletter_$(language)):</th></tr>
<tr>
<th align="center">$(Abo_$(language))</td>
<th align="left">Name</td>
<th colspan="2" align="left">$(Desc_$(language))</td>
</tr>
<input name="USERID" type="hidden" value="$(USERID)">
%ROW{
@LeseEMLADRSRV(USERID, V_ESSRVNAM, Abonniert)
@DTW_ASSIGN(Status, "")
%IF ("$($(V_ESSRVNAM))" != "$(Old_$(V_ESSRVNAM))")
%IF ("$($(V_ESSRVNAM))" == "on")
%IF (ON != Abonniert)
@SchreibeEMLADRSRV(USERID,V_ESSRVNAM)
@DTW_ASSIGN(Status,
"$(justAbo_$(language))")
@DTW_ASSIGN(Abonniert, ON)
%ELSE
@DTW_ASSIGN(Status,
"$(subY_$(language))")
%ENDIF
%ELSE
@LoescheEMLADRSRV(USERID,V_ESSRVNAM)
@DTW_ASSIGN(Status, "$(justQ_$(language))")
@DTW_ASSIGN(Abonniert, OFF)
%ENDIF
%ELSE
%IF (Abonniert == ON)
@DTW_ASSIGN(Status, "$(subY_$(language))")
%ELSE
@DTW_ASSIGN(Status, "$(subN_$(language))")
%ENDIF
%ENDIF
<tr><td width="25px" align="center">
<table width="100%"><tr><td><input name="$(V_ESSRVNAM)"
type="checkbox" %IF (ON == Abonniert) checked %ENDIF ></td>
<td>$(Status)</td></tr></table>
</td>
%IF (ON == Abonniert)
@DTW_ASSIGN(OldValue,"on")
%ELSE
@DTW_ASSIGN(OldValue,"")
%ENDIF
<input name="Old_$(V_ESSRVNAM)" type="hidden" value="$(OldValue)">
<td width="10%">$(V_ESSRVNAM)</td>
<td width="*">$(V_ESSRVHTM)</td>
<td width="75%">$(V_ESSRVTXT)</td></tr>
%}
<tr><td colspan="4"><input type="submit" class="nicebutton"
value="$(Speichern_$(language))"></td></tr>
</table>
</form>
%}
%MESSAGE {
0100 : "$(NoServ_$(language))" : continue
%}
%}
This SQL function lists the rows and does the updates.
The called functions look like this:
%{************************************************************%}
%FUNCTION(DTW_SQL) LeseEMLADRSRV (IN USERID,
IN SRVNAM,
OUT EXISTS) {
SELECT EASUSRID
FROM $(File_EMLUSRSRV)
WHERE EASUSRID = '$(USERID)' AND EASSRVNAM = '$(SRVNAM)'
%REPORT{ %ROW{ @DTW_ASSIGN(EXISTS, ON) %} %}
%MESSAGE {
0100 : "@DTW_ASSIGN(EXISTS, OFF)" : continue
%}
%}
%{************************************************************%}
%FUNCTION(DTW_SQL) SchreibeEMLADRSRV ( IN USERID,
IN SRVNAM) {
INSERT INTO $(File_EMLUSRSRV)
(EASUSRID, EASSRVNAM)
VALUES('@DTW_rADDQUOTE(USERID)',
'@DTW_rADDQUOTE(SRVNAM)')
%}
%{************************************************************%}
%FUNCTION(DTW_SQL) LoescheEMLADRSRV (IN USERID,
IN SRVNAM) {
DELETE FROM $(File_EMLUSRSRV)
WHERE EASUSRID = '$(USERID)' AND EASSRVNAM = '$(SRVNAM)'
%MESSAGE {
0100 : "" : continue
%}
%}
I'm trying to understand this.
I wasn't expecting someone to examine the source code that deeply... ;-) Well, i wouldn't make everything exactly like i did then. For example, i wouldn't use the name of the newsletter as key, i'd generate some sort of id. I hope it's halfways clear. best regards / Mit freundlichen Grüssen Anton Gombkötö Avenum Technologie GmbH http://www.avenum.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.