PDA

View Full Version : Dialog Variables


ABC123

Keith Hubert
10-10-2004, 03:03 AM
How do you add a new record to a Table from a Variable when using a Dialog Grid?

Regards

Keith Hubert

Guild Member
London.

JerryBrightbill
10-10-2004, 07:23 AM
Keith

I am not sure I completely understand the question. If you are trying to use a variable to set the intial value for a field, you can override the initial value when the component is added to a page. For example, if the first "object" in the dialog is a text box named "name", looking at the generated xbasic for the component shows the following

with tmpl.Variable_Info[1]
fieldname = "name"
Scope = "Local"
DisplayFormat = ""
DisplayUnFormat = ""
Type = "C"
controltype = "TextBox"
'...and so on

One of the parameters in the dot variable is

tmpl.Variable_Info[1].InitialValue

When the component is added to a page, you can set a value for this dot variable after the component is loaded, but before it runs. For example, if the component is named "people", when it is added to a page you should see something like this

tmpl_people = a5w_load_component("people")

Now, before the component runs, you can set all of the field values with something like this

tmpl_people.Variable_Info[1].InitialValue = value1
tmpl_people.Variable_Info[2].InitialValue = value2
tmpl_people.Variable_Info[3].InitialValue = value3
tmpl_people.Variable_Info[4].InitialValue = value4

Then you can pass all of the dot variable values to the component and run it. You can override almost any component value using this method

x_people = a5w_run_Component(tmpl_people)

You have to look at the original generated xbasic for the component to verify the name of each dot variable to be sure you are assigning the correct value. The assigned value (value1, etc) can be obtained from code in the page xbasic, from a session variable, or a value passed to the page in the url.

Jerry

Selwyn Rabins
10-10-2004, 09:35 AM
in the Dialog component's After validate event:

(assuming the table you want to add records to is c:\data\customers.dbf, and that the Dialog compoenent prompted for these variables: id, firstname, lastname)

t = table.open("customers")
t.enter_begin()
t.customer_id = id
t.lastname = lastname
t.firstname = firstname
t.enter_end(.t.)

you would probably also then want to redirect to another page. otherwise the data entry page will be redisplayed in the user's browser. so your last line would be something like this:

currentform.redirectTarget = "thankspage.a5w"

Of course, you will have a different page - not 'thankspage.a5w' - but you get the idea.

Selwyn Rabins
10-10-2004, 09:36 AM
ooops.

forgot to add the

t.close()

you need this after the t.enter_end(.t.)

Peter McConnon
09-14-2005, 04:29 PM
I have used the technique described to add a record to a table based on controls within a dialog. Everything works fine on my Local Webroot, but when published to the ISP, the aftervalidate of the dialog fails - cannot find file.
I have
t = table.open("application")
...
and the error reports that it cannot find application.dbf

I have checked the data directory on the server and application.dbf (etc) are present.

Thank you for any available assistance

JerryBrightbill
09-14-2005, 05:57 PM
Peter,

If no path is supplied, Alpha uses the path of the current open database. If the ISP doesn't have your database open, and it shouldn't, the path can't be determined. You are going to have to get the full path used by the ISP and supply it in a path alias. You can look in the publishing setup to learn more about path aliases. The grid builder allows you to select an alias that is defined by the publish configuration. The help file has a whole section on path aliases, "Path and Connection String Aliases"

Jerry

Dan Blank
09-14-2005, 08:47 PM
Hi Keith,

Does this demo help?

Dialog Component Demo

Dan

Dan Blank Databases, Inc.

Peter McConnon
09-14-2005, 09:10 PM
Thanks Jerry

All is working fine now.

I'm actually a bit disappointed that I didn't realise the need for the Path alias myself!

Thanks again

JerryBrightbill
09-15-2005, 04:34 AM
Peter

That catches all of us from time to time since working in a desktop app rarely requires paths. In fact, in a desktop application, every effect is made to eliminate path information as much as possible. If you want a real mess, try converting a dektop application to the web where data is in multiple, unrelated paths.

Jerry