I am writing a script to accomplish the following:
1. Prompt for a Property Number (based on records in the Properties table)
2. Open a form, fetch the Property record with the number selected in step 1 and capture
the value of 5 fields in that record.
3. Print a report for that one record.
To facilitate writing and checkout, I have designed a calling script which in turn calls the 4 scripts listed above. I�m currently working on the second step. I have written the script using genies. The problem segment (I think) contains the 5 commands in the area directly below the �Now capture the 5 principals into Vc_P1 thru Vc_p5. This was written with the Xbasic Script Genie | Variables | Set variable(s) to field value - fields on a form options. The script appears below:
----------------------------------------------------------------------------------------
'Date Created: 24-Oct-2008 02:22:24 PM
'Last Updated: 26-Oct-2008 05:14:09 PM
'Created By : Howard R. Elkes
'Updated By : Howard R. Elkes
'*******************************************************************************
' Open PROPERTIES table. *
'*******************************************************************************
prop=table.Open("PROPERTIES",FILE_RO_SHARED)
Vc_step = "Step FPR 1"
'*******************************************************************************
' Open PROPERTIES form. *
'*******************************************************************************
query.filter = "Propnumber = Var->Vc_Prop"
query.order = "recno()"
'replace variables in the filter with their actual values
query.filter = convert_expression(query.filter,"V")
'Open the layout_type showing just the records that satisfy the filter
DIM Shared varP_Properties as P
DIM layout_name as c
layout_name = "Properties"
dim tempP as p
'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
'Test if pointer is valid
if is_object(tempP) then
'Test if pointer refers to a form or browse
if tempP.class() = "form" .or. tempP.class() = "browse" then
dim flagIsBaseFilter as l
flagIsBaseQuery = .t.
if flagIsBaseFilter then
'Apply the query to the form or browse as the Base query. (this means that
'the user cannot turn the query off, only add to the query)
tempP.BaseQueryRun(query.filter,query.order)
else
tempP.QueryRun(query.filter,query.order)
end if
'then activate the already open window
tempP.activate()
else
'Window is not already open, so open it
varP_Properties = :Form.viewqueried(layout_name,query.filter, query.order )
end if
else
varP_Properties = :Form.viewqueried(layout_name,query.filter, query.order )
end if
Vc_step = "Step FPR 2"
'*******************************************************************************
' Now, capture the 5 Principals into Vc_P1 thru Vc_P5. *
'*******************************************************************************
Vc_P1 = parentform:Prin1.value
Vc_P2 = parentform:Prin2.value
Vc_P3 = parentform:Prin3.value
Vc_P4 = parentform:Prin4.value
Vc_P5 = parentform:Prin5.value
Vc_step = "Step FPR 3"
'*******************************************************************************
' When done, close the form. *
'*******************************************************************************
parentform.close(.f.)
Vc_step = "Step FPR 4"
END
------------------------------------------------------------------------------------------
However, when I attempt to run this script (FetchPropertiesRecord), I get a message which states:
Script:FetchPropertiesRecord line:60
Vc_P1 = parentform:Prin1.value
Not found
Parentform:Prin1 not found.
However, there IS a Properties form based on the Properties table which I have designed and which contains all the fields in that table - including Prin1 through Prin5.
Any ideas as to what�s wrong with the genie-created script?
1. Prompt for a Property Number (based on records in the Properties table)
2. Open a form, fetch the Property record with the number selected in step 1 and capture
the value of 5 fields in that record.
3. Print a report for that one record.
To facilitate writing and checkout, I have designed a calling script which in turn calls the 4 scripts listed above. I�m currently working on the second step. I have written the script using genies. The problem segment (I think) contains the 5 commands in the area directly below the �Now capture the 5 principals into Vc_P1 thru Vc_p5. This was written with the Xbasic Script Genie | Variables | Set variable(s) to field value - fields on a form options. The script appears below:
----------------------------------------------------------------------------------------
'Date Created: 24-Oct-2008 02:22:24 PM
'Last Updated: 26-Oct-2008 05:14:09 PM
'Created By : Howard R. Elkes
'Updated By : Howard R. Elkes
'*******************************************************************************
' Open PROPERTIES table. *
'*******************************************************************************
prop=table.Open("PROPERTIES",FILE_RO_SHARED)
Vc_step = "Step FPR 1"
'*******************************************************************************
' Open PROPERTIES form. *
'*******************************************************************************
query.filter = "Propnumber = Var->Vc_Prop"
query.order = "recno()"
'replace variables in the filter with their actual values
query.filter = convert_expression(query.filter,"V")
'Open the layout_type showing just the records that satisfy the filter
DIM Shared varP_Properties as P
DIM layout_name as c
layout_name = "Properties"
dim tempP as p
'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
'Test if pointer is valid
if is_object(tempP) then
'Test if pointer refers to a form or browse
if tempP.class() = "form" .or. tempP.class() = "browse" then
dim flagIsBaseFilter as l
flagIsBaseQuery = .t.
if flagIsBaseFilter then
'Apply the query to the form or browse as the Base query. (this means that
'the user cannot turn the query off, only add to the query)
tempP.BaseQueryRun(query.filter,query.order)
else
tempP.QueryRun(query.filter,query.order)
end if
'then activate the already open window
tempP.activate()
else
'Window is not already open, so open it
varP_Properties = :Form.viewqueried(layout_name,query.filter, query.order )
end if
else
varP_Properties = :Form.viewqueried(layout_name,query.filter, query.order )
end if
Vc_step = "Step FPR 2"
'*******************************************************************************
' Now, capture the 5 Principals into Vc_P1 thru Vc_P5. *
'*******************************************************************************
Vc_P1 = parentform:Prin1.value
Vc_P2 = parentform:Prin2.value
Vc_P3 = parentform:Prin3.value
Vc_P4 = parentform:Prin4.value
Vc_P5 = parentform:Prin5.value
Vc_step = "Step FPR 3"
'*******************************************************************************
' When done, close the form. *
'*******************************************************************************
parentform.close(.f.)
Vc_step = "Step FPR 4"
END
------------------------------------------------------------------------------------------
However, when I attempt to run this script (FetchPropertiesRecord), I get a message which states:
Script:FetchPropertiesRecord line:60
Vc_P1 = parentform:Prin1.value
Not found
Parentform:Prin1 not found.
However, there IS a Properties form based on the Properties table which I have designed and which contains all the fields in that table - including Prin1 through Prin5.
Any ideas as to what�s wrong with the genie-created script?
Comment