NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: rupertvz on November 13, 2011, 01:25:36 PM
-
Hi Guys,
I have a NetWebForm calling a NetWebBrowse.
On the tab after the browse in the NetWebForm I'd like to "handle" and check the records being added by the user and give totals or warning upon their input.
I have added code in the "NextTab, Start" embed to loop through the records in the table, but for some reason my loop and record handling doesn't want to work.
Here is my code: * This code is only suppose to count the records according to the key-value ...
CASE lower(p_web.PageName)
OF lower('fWizard_nexttab_' & 8)
ACCESS:TABLE.OPEN()
ACCESS:TABLE.USEFILE()
RESET(TABLE,1) !Reset the record pointer
TABLE:REC_ID = GLO:REC_ID !GLO:RecID stored in previous instance
SET(REC_ID_KEY,REC_ID_KEY)
LOOP UNTIL ACCESS:TABLE.Next() <> LEVEL:Benign
IF TABLE:REC_ID = GLO:REC_ID
TOT:Cnt += 1
ELSE
BREAK
END
END
ACCESS:TABLE.Close()
-
For starters I would change GLO:REC_ID to a SSV otherwise it could create other problems down the track.
Secondly I would also set your TOT:Cnt as a SSV at the end of your loop. BTW is this a local variable or a table field?
-
Rupert,
Hi there.
The first question that comes to me is "What do you mean by - doesn't want to work -?"
That is, does your code error out? Or are you getting the right information from your code BUT it's not getting to where it should go?
Which leads me to the more important thing (Kevin points at it), Nettalk runs a lot on Session vars.
If you are wanting the information to display on the next tab, are the fields you are displaying being set by your code? Usually this would be done through p_web.SSV().
Also, are they (the display fields in the 2nd tab) being refreshed on a tab change or after the browse has been operated on?
-
Hi Kevin, Stu,
Thanks for your repies;
I did a few tests and the problem is arising when I include the following line (bold below):
TABLE:REC_ID = GLO:REC_ID !GLO:RecID stored in previous instance
SET(REC_ID_KEY,REC_ID_KEY)
LOOP UNTIL ACCESS:TABLE.Next() <> LEVEL:Benign
IF TABLE:REC_ID = GLO:REC_ID
TOT:Cnt += 1
ELSE
BREAK
END
END
When I remove this line out, the loop handles all records (CORRECT)
As soon as I put this line back, the loop doesn't handle ANY records ...
It is not making any sense, as with the line: TABLE:REC_ID = GLO:REC_ID
I am only starting the record processing at the record with the set-value ... correct?
I have even tried setting TABLE:REC_ID = 4 .... (constant)
There is a record with ID (4), but when I add this line, the loop doesn't process any records.
It's not making any sense ...
Any help please?
-
Hi Rupert,
where ever you are setting GLO:RecID change it to p_web.SSV('Glo:Rec_ID',the record id here, no quotes) !you should substitute globals to SSV's - read the docs why...
Then change TABLE:REC_ID = GLO:REC_ID to TABLE:REC_ID = p_web.gsv('GLO:REC_ID')
+ change IF TABLE:REC_ID = GLO:REC_ID to IF TABLE:REC_ID = p_web.gsv('GLO:REC_ID')
You then need to store TOT:Cnt to a SSV at the end of the loop if you want to use it elsewhere or update that value in your table.
-
Rupert,
Just wondering, when you have TABLE:REC_ID, you mean TABLEPREFIX:REC_ID right?
-
Rupert,
two things
a) what is the line
RESET(TABLE,1)
for ? I don't think I've seen that since DOS days
b) delete your global variable completely. I mean don't just "not use it" literally delete it. It has no place in a WebServer app.
then re-write the code correctly using Session values instead of global variables.
cheers
Bruce
-
Hi rupert
The Reset(Table,1) is what is making it work when you remove the TABLE:REC_ID = GLO:REC_ID line since the table is set to the beginning and would therefore traverse the file from the beginning.
That said do what Bruce said :)
-
Thanks Guys!
I incorporated all these changes and seems to be working now :-)
Regards
Rupert