NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Devan on October 27, 2011, 06:11:05 AM
-
Powering along with some NT development lately...You can tell by the number of questions I am suddenly posting! ;D
Ok, a frustrating problem at the moment:
I have a file with two fields, FIL:Field1 and FIL:Field2.
I also have a WebForm with a couple of local variables LOC:MyVar1 and LOC:MyVar2
In the form, I have a drop down which pulls the value of FIL:Field1 and populates LOC:MyVar1 with it - works a treat.
Now, I whenever the user changes the drop down, I also want it to pull down the value of FIL:Field2 and populate LOC:MyVar2 with it. Cannot make it work.
I have gone to the ValidateValue::LOC:MyVar1 and entered the following code:
LOC:MyVar2 = p_web.GSV('FIL:Field2')
p_web.SSV('LOC:MyVar2') = p_web.GSV('FIL:Field2')
I have tried setting FIL:Field2 as a Hot Field, removed it. Tried p_web.GV() and SV() instead of GSV() and SSV() and nothing.
LOC:MyVar1 always works, LOC:MyVar2 is always blank...
-
Hi Devan,
I think it should be:
LOC:MyVar2 = p_web.GSV('FIL:Field2')
p_web.SSV('LOC:MyVar2',p_web.GSV('FIL:Field2'))
I might be wrong.
Regards
Johan de Klerk
-
Haa! You are correct Johan... I typed in the code snippet wrong in my tiredness very late last night...
The second line indeed should be:
p_web.SSV('LOC:MyVar2',p_web.GSV('FIL:Field2'))
Notwithstanding the introduced bug in my code, FIL:Field2 and LOC:MyVar2 are always blank at this point in the code when I inspect them in DebugView and I cannot understand why it is so... ???
-
Ok - I sorted it out... Basically an ID-10-T error on my part...
Decades of programming with Clarion Win32 has lulled be into a false sense of security that the record buffer will always be there and waiting, and that including 'Hot Fields' in a Browse or Drop will usually make those fields readily available in memory.
In the web environment - NO!
I ended up making the Drop list give me the ID of the record and place that in LOC:MyID, then going to the 'Client-Side' tab of the field and checking the 'Send new value to server' checkbox and clicking the 'Server Code' button to embed a short code snippet which would get the record for me:
! Fetch other related report data
p_web._OpenFile(mytable)
lsreportlist{PROP:SQL} = 'SELECT * FROM mytable WHERE ID=' & LOC:MyID
Next(mytable)
If ~Error()
p_web.SetSessionValue('LOC:MyVar1', FIL:Field1)
p_web.SetSessionValue('LOC:MyVar2', FIL:Field2)
Else
p_web.DeleteSessionValue('LOC:MyVar1')
p_web.DeleteSessionValue('LOC:MyVar2')
End
p_web._CloseFile(mytable)
Oh yeah - I had to remember that the files are not Open() at this point either, so had to manually Open() and Close() them as above...
Hope this helps another wandering soul on the NetTalk road... ;)
-
Devan,
Reading your last post reminded me about _Open and _Close file from p_web. My brain has tracked in Access:<filename>.UseFile() .. Need to standardise to use proper Nettalk etiquette.
Thanks!
-
Hi Stu,
Access:FileName.Open is just fine. It's what I use in my code.
The other is really just there so the "same code" works in Legacy and ABC - ie it's there for the benefit of Legacy programmers.
cheers
Bruce
-
Oh, okay. Awesome. Good to know.
Actually, I heard your voice saying your reply .. So you have probably already told me that before.
Memory is my strong point.