If you type ProgressiveFind into the help files you get nothing on this.
I made a copy of the ProgressiveFind script and called it ProgressiveFindtwo
This is from the Alpha sports V8 customer form.
I placed the button over onto another form i want to use the ProgressiveFind on but i have no clue how to set up the ProgressiveFind script to work for this form and a table called eventvendors.
I looked for a action script hoping that the ProgressiveFind can be added to any button using action script asking what form and everything to set up a new ProgressiveFind just for this form but i did not see one.
Here is the current ProgressiveFind
How can i change this to work with the eventvendors table? In place of the customer table. all i need it to search for is A field called COMPNAME
Thanks
-----------------------------------------
'Date Created: 07-Jul-2005 09:28:14 AM
'Last Updated: 26-Nov-2006 12:29:42 PM
'Created By : Aaron
'Updated By : Selwyn
'This script is called from the 'Find Customer' button on the
'Customer Information form.
dim flagCloseAfterFind as l
dim p as p
p.closeAfterFind = .f.
a5_load_settings("ProgressiveFind",p)
flagCloseAfterFind = p.closeAfterFind
DIM vLastname as C = ""
DIM vCustomerID AS C
DIM CurrentSortField AS C = "Lastname"
DIM CurrentSortDirection AS C = "A"
DIM Filter AS C
DIM pTableDef AS P
DIM pTableDef.ReturnValueExpression AS C = "Customer_id"
DIM pTableDef.FieldList AS C = <<%txt%
Firstname
Lastname
Company
%txt%
DIM pTableDef.TitleRow AS C = "{WIDTH=1.65}Firstname|{WIDTH=1.65}Lastname|{WIDTH=1.7}Company"
DIM pTableDef.Arguments AS C = <<%txt%
<arrArgs<[1]<Name="argLastname">
<DataType="Character">
<Source="vLastname">
<SourceType="Local Variable">
<DefaultValue="">
<Prompt=.F.>
<PromptText="">
<PromptControlType="Text Box">
<PromptChoices="">
<PromptDlgTitle="Missing Argument">
<PromptTextAbove="">
>
>
<lastbutton="ok">
%txt%
DIM pTableDef.pArgs AS P
property_from_string(pTableDef.pArgs, pTableDef.Arguments)
DIM pTableDef.TableName AS C = "customer"
DIM pTableDef.Filter AS C = "iif(current(len(:argLastname))=0,.t., left(lastname, current(len(:argLastname)))= :argLastname)"
DIM pTableDef.Order AS C = "Lastname"
DIM t AS P
dim rr as alpha5::RowRelation
dim rs as p
pLV.titlerow = pTableDef.titlerow
pLV.titleevents = "Sort_Firstname|Sort_Lastname|Sort_Company"
pLV.style = "report,singlesel,showselalways,fullrowselect"
pLV.dragbehaviour = ""
pLV.dropbehaviour = ""
IF .NOT. file.exists(table.filename_get(pTableDef.TableName))
END
END IF
t = table.open(pTableDef.TableName, FILE_RO_SHARED)
t.persist()
rs = rr.TableToRowSource(t)
Filter = GetArguments(pTableDef, local_variables())
pLV.rowview = rs.OpenView(1,pTableDef.Order,Filter)
pLV.RowSeparator = crlf()
pLV.ColumnSeparator = "|"
pLV.Columns = pTableDef.FieldList
pLV.Key = pTableDef.ReturnValueExpression
pLV.events = <<%code%
function OnRightClick as c(lv as p,listView as p,args as p)
WITH lv
listView.Selection = listView.GetRowValue(args.GetClickRow())
OnSelectionChanged(lv, listView )
'to call a function outside the events code, you must use the ui_dlg_eval() function
'menu = ui_dlg_eval(dlg_title,"a5wcb_PublishRclick(selectedFilename)")
' ui_msg_box("OnRightClick",listview.selection)
END WITH
end function
function OnDoubleClick as c(lv as p,listView as p,args as p)
WITH lv
vCustomerID = listView.GetRowValue(args.GetClickRow())
' ui_msg_box("OnDoubleClick",vCustomerID)
t = topparent.table_get()
dim recno_for_custid as n
'The event handler for the ListView cannot see the local functions in the script.
'The ui_dlg_eval() function evaluates a function in the context of the named UI_DLG_BOX().
'Since the Xdialog referenced by 'dlg_title' CAN see the local FindRecNoForCustomerID() function,
'we are able to evaulate the expression and get the record number for the selected CustomerId.
recno_for_custid = ui_dlg_eval(dlg_title,"FindRecNoForCustomerID(vCustomerID)")
t.fetch_goto(recno_for_custid)
topparent.resynch()
if flagCloseAfterFind then
ui_dlg_event(dlg_title,"Close")
end if
END WITH
end function
FUNCTION OnSelectionChanged AS V (lv AS P, listView as p )
WITH lv
vCustomerID = listView.Selection
END WITH
END FUNCTION
FUNCTION OnKeyDown as v(vars as p,listView as p,args as p)
DIM key AS C
Dim KeyName as c
key = args.GetKeyName()
KeyName = key
IF key = "{Delete}" .OR. key = "{Num Del}"
KeyName = "{Delete}"
ELSE IF args.keycode = 13 ' enter
KeyName = "{Enter}"
ELSE IF args.keycode = 8 ' backspace
KeyName = "{Backspace}"
END IF
'ui_msg_box("OnKeyDown", KeyName)
END FUNCTION
%code%
IF is_object(topparent.this)
dlg_title = topparent.name(16)+"@:Find Customer: Progressive Lookup"
ELSE
dlg_title = "Find Customer: Progessive Lookup"
END IF
ui_modeless_dlg_box(dlg_title,<<%dlg%
{watch=vLastname!refresh}
{auto_external_refresh}
{can_exit=close}
{wrap=100}
To find a customer, begin typing the customer's last name into the 'Enter last name' textbox below. As you type the last name, the list will change to show the closest matches. For example, typing 'Ba' will bring up John Baker and Tom Barber.;
{lf};
{region}
{region}
Enter last name:| [.40vLastname];
{endregion};
{lf};
Select Customer:;
{listviewvirtual=100,15vCustomerID^=pLV};;
{endregion};
{endregion};;;
{line=1,0};
{region}
<*15Goto Record!goto_record?vCustomerID<\>""> <15&Close!close> {sp=10}(flagCloseAfterFind!closeSettingChanged) Automatically close after find;
{endregion};
%dlg%,<<%code%
IF left(a_dlg_button, 5) = "Sort_"
DIM NewSortField AS C
NewSortField = substr(a_dlg_button, 6)
DoSort(CurrentSortField, CurrentSortDirection, NewSortField, Filter, pLV, rs)
a_dlg_button = ""
END IF
if a_dlg_button = "closeSettingChanged" then
a_dlg_button = ""
p.closeAfterFind = flagCloseAfterFind
a5_save_settings("ProgressiveFind",p)
end if
IF a_Dlg_button = "refresh"
a_dlg_button = ""
Filter = GetArguments(pTableDef, local_variables())
pLV.RowView.Close()
pLV.RowView = rs.OpenView(1, CurrentSortField, Filter)
END IF
IF a_Dlg_button = "goto_record"
a_dlg_button = ""
t = topparent.table_get()
t.fetch_goto(FindRecNoForCustomerID(vCustomerID))
topparent.resynch()
if flagCloseAfterFind then
ui_modeless_dlg_close(dlg_title)
end if
END IF
IF a_dlg_Button = "Close"
ui_modeless_dlg_close(dlg_title)
END IF
%code%)
FUNCTION FindRecNoForCustomerID AS N ( vCustomerID AS C )
DIM t AS P
DIM nResult AS N
t = table.open("customer", FILE_RO_SHARED)
t.order("Customer_ID")
nResult = t.fetch_find(vCustomerID)
t.close()
FindRecNoForCustomerID = nResult
END FUNCTION
FUNCTION DoSort AS V (byref CurrentSortField AS C , byref CurrentSortDirection AS C, NewSortField AS C, Filter AS C, pLV AS P, rs AS P )
DIM cResult AS C
DIM SortDirection AS C
DIM SortField AS C
IF NewSortField = CurrentSortField
' clicked on same field, reverse sort
IF CurrentSortDirection = "D"
CurrentSortDirection = "A"
ELSE
CurrentSortDirection = "D"
END IF
ELSE
CurrentSortField = NewSortField
CurrentSortDirection = "A"
END IF
SortDirection = CurrentSortDirection
SortField = CurrentSortField
IF SortDirection = "D"
SortField = "invert(" + SortField + ")"
END IF
' actual sorting code goes here
pLV.RowView.Close()
pLV.RowView = rs.OpenView(1, SortField, Filter)
DoSort = cResult
END FUNCTION
FUNCTION GetArguments AS C ( pTableDef AS P, lv AS P )
DIM cResult AS C
FOR EACH x IN pTableDef.pArgs.arrArgs
IF (":"+x.Name) $ pTableDef.Filter
x.value = GetValue(x, lv)
END IF
NEXT
cResult = a5_ArgumentsReplace(pTableDef.filter, pTableDef.pArgs.arrArgs)
GetArguments = cResult
END FUNCTION
FUNCTION GetValue AS A ( pArg AS P , lv AS P)
DIM aResult AS A
DIM var AS C
var = pArg.Source
IF eval_valid("lv." + var)
aResult = eval("lv."+var)
ELSE IF eval_valid(var)
aResult = eval(var)
ELSE
DIM pArgDlg AS P
IF pArg.Prompt .AND. pArg.DefaultValue = ""
pArgDlg = a5_ArgPromptDialog(pArg)
IF pArgDlg.lastbutton = "cancel"
EXIT FUNCTION
END IF
aResult = pArgDlg.value
ELSE
aResult = convert_type(pArg.DefaultValue, left(pArg.DataType,1))
END IF
END IF
GetValue = aResult
END FUNCTION
------------------------------------------------------------
I made a copy of the ProgressiveFind script and called it ProgressiveFindtwo
This is from the Alpha sports V8 customer form.
I placed the button over onto another form i want to use the ProgressiveFind on but i have no clue how to set up the ProgressiveFind script to work for this form and a table called eventvendors.
I looked for a action script hoping that the ProgressiveFind can be added to any button using action script asking what form and everything to set up a new ProgressiveFind just for this form but i did not see one.
Here is the current ProgressiveFind
How can i change this to work with the eventvendors table? In place of the customer table. all i need it to search for is A field called COMPNAME
Thanks
-----------------------------------------
'Date Created: 07-Jul-2005 09:28:14 AM
'Last Updated: 26-Nov-2006 12:29:42 PM
'Created By : Aaron
'Updated By : Selwyn
'This script is called from the 'Find Customer' button on the
'Customer Information form.
dim flagCloseAfterFind as l
dim p as p
p.closeAfterFind = .f.
a5_load_settings("ProgressiveFind",p)
flagCloseAfterFind = p.closeAfterFind
DIM vLastname as C = ""
DIM vCustomerID AS C
DIM CurrentSortField AS C = "Lastname"
DIM CurrentSortDirection AS C = "A"
DIM Filter AS C
DIM pTableDef AS P
DIM pTableDef.ReturnValueExpression AS C = "Customer_id"
DIM pTableDef.FieldList AS C = <<%txt%
Firstname
Lastname
Company
%txt%
DIM pTableDef.TitleRow AS C = "{WIDTH=1.65}Firstname|{WIDTH=1.65}Lastname|{WIDTH=1.7}Company"
DIM pTableDef.Arguments AS C = <<%txt%
<arrArgs<[1]<Name="argLastname">
<DataType="Character">
<Source="vLastname">
<SourceType="Local Variable">
<DefaultValue="">
<Prompt=.F.>
<PromptText="">
<PromptControlType="Text Box">
<PromptChoices="">
<PromptDlgTitle="Missing Argument">
<PromptTextAbove="">
>
>
<lastbutton="ok">
%txt%
DIM pTableDef.pArgs AS P
property_from_string(pTableDef.pArgs, pTableDef.Arguments)
DIM pTableDef.TableName AS C = "customer"
DIM pTableDef.Filter AS C = "iif(current(len(:argLastname))=0,.t., left(lastname, current(len(:argLastname)))= :argLastname)"
DIM pTableDef.Order AS C = "Lastname"
DIM t AS P
dim rr as alpha5::RowRelation
dim rs as p
pLV.titlerow = pTableDef.titlerow
pLV.titleevents = "Sort_Firstname|Sort_Lastname|Sort_Company"
pLV.style = "report,singlesel,showselalways,fullrowselect"
pLV.dragbehaviour = ""
pLV.dropbehaviour = ""
IF .NOT. file.exists(table.filename_get(pTableDef.TableName))
END
END IF
t = table.open(pTableDef.TableName, FILE_RO_SHARED)
t.persist()
rs = rr.TableToRowSource(t)
Filter = GetArguments(pTableDef, local_variables())
pLV.rowview = rs.OpenView(1,pTableDef.Order,Filter)
pLV.RowSeparator = crlf()
pLV.ColumnSeparator = "|"
pLV.Columns = pTableDef.FieldList
pLV.Key = pTableDef.ReturnValueExpression
pLV.events = <<%code%
function OnRightClick as c(lv as p,listView as p,args as p)
WITH lv
listView.Selection = listView.GetRowValue(args.GetClickRow())
OnSelectionChanged(lv, listView )
'to call a function outside the events code, you must use the ui_dlg_eval() function
'menu = ui_dlg_eval(dlg_title,"a5wcb_PublishRclick(selectedFilename)")
' ui_msg_box("OnRightClick",listview.selection)
END WITH
end function
function OnDoubleClick as c(lv as p,listView as p,args as p)
WITH lv
vCustomerID = listView.GetRowValue(args.GetClickRow())
' ui_msg_box("OnDoubleClick",vCustomerID)
t = topparent.table_get()
dim recno_for_custid as n
'The event handler for the ListView cannot see the local functions in the script.
'The ui_dlg_eval() function evaluates a function in the context of the named UI_DLG_BOX().
'Since the Xdialog referenced by 'dlg_title' CAN see the local FindRecNoForCustomerID() function,
'we are able to evaulate the expression and get the record number for the selected CustomerId.
recno_for_custid = ui_dlg_eval(dlg_title,"FindRecNoForCustomerID(vCustomerID)")
t.fetch_goto(recno_for_custid)
topparent.resynch()
if flagCloseAfterFind then
ui_dlg_event(dlg_title,"Close")
end if
END WITH
end function
FUNCTION OnSelectionChanged AS V (lv AS P, listView as p )
WITH lv
vCustomerID = listView.Selection
END WITH
END FUNCTION
FUNCTION OnKeyDown as v(vars as p,listView as p,args as p)
DIM key AS C
Dim KeyName as c
key = args.GetKeyName()
KeyName = key
IF key = "{Delete}" .OR. key = "{Num Del}"
KeyName = "{Delete}"
ELSE IF args.keycode = 13 ' enter
KeyName = "{Enter}"
ELSE IF args.keycode = 8 ' backspace
KeyName = "{Backspace}"
END IF
'ui_msg_box("OnKeyDown", KeyName)
END FUNCTION
%code%
IF is_object(topparent.this)
dlg_title = topparent.name(16)+"@:Find Customer: Progressive Lookup"
ELSE
dlg_title = "Find Customer: Progessive Lookup"
END IF
ui_modeless_dlg_box(dlg_title,<<%dlg%
{watch=vLastname!refresh}
{auto_external_refresh}
{can_exit=close}
{wrap=100}
To find a customer, begin typing the customer's last name into the 'Enter last name' textbox below. As you type the last name, the list will change to show the closest matches. For example, typing 'Ba' will bring up John Baker and Tom Barber.;
{lf};
{region}
{region}
Enter last name:| [.40vLastname];
{endregion};
{lf};
Select Customer:;
{listviewvirtual=100,15vCustomerID^=pLV};;
{endregion};
{endregion};;;
{line=1,0};
{region}
<*15Goto Record!goto_record?vCustomerID<\>""> <15&Close!close> {sp=10}(flagCloseAfterFind!closeSettingChanged) Automatically close after find;
{endregion};
%dlg%,<<%code%
IF left(a_dlg_button, 5) = "Sort_"
DIM NewSortField AS C
NewSortField = substr(a_dlg_button, 6)
DoSort(CurrentSortField, CurrentSortDirection, NewSortField, Filter, pLV, rs)
a_dlg_button = ""
END IF
if a_dlg_button = "closeSettingChanged" then
a_dlg_button = ""
p.closeAfterFind = flagCloseAfterFind
a5_save_settings("ProgressiveFind",p)
end if
IF a_Dlg_button = "refresh"
a_dlg_button = ""
Filter = GetArguments(pTableDef, local_variables())
pLV.RowView.Close()
pLV.RowView = rs.OpenView(1, CurrentSortField, Filter)
END IF
IF a_Dlg_button = "goto_record"
a_dlg_button = ""
t = topparent.table_get()
t.fetch_goto(FindRecNoForCustomerID(vCustomerID))
topparent.resynch()
if flagCloseAfterFind then
ui_modeless_dlg_close(dlg_title)
end if
END IF
IF a_dlg_Button = "Close"
ui_modeless_dlg_close(dlg_title)
END IF
%code%)
FUNCTION FindRecNoForCustomerID AS N ( vCustomerID AS C )
DIM t AS P
DIM nResult AS N
t = table.open("customer", FILE_RO_SHARED)
t.order("Customer_ID")
nResult = t.fetch_find(vCustomerID)
t.close()
FindRecNoForCustomerID = nResult
END FUNCTION
FUNCTION DoSort AS V (byref CurrentSortField AS C , byref CurrentSortDirection AS C, NewSortField AS C, Filter AS C, pLV AS P, rs AS P )
DIM cResult AS C
DIM SortDirection AS C
DIM SortField AS C
IF NewSortField = CurrentSortField
' clicked on same field, reverse sort
IF CurrentSortDirection = "D"
CurrentSortDirection = "A"
ELSE
CurrentSortDirection = "D"
END IF
ELSE
CurrentSortField = NewSortField
CurrentSortDirection = "A"
END IF
SortDirection = CurrentSortDirection
SortField = CurrentSortField
IF SortDirection = "D"
SortField = "invert(" + SortField + ")"
END IF
' actual sorting code goes here
pLV.RowView.Close()
pLV.RowView = rs.OpenView(1, SortField, Filter)
DoSort = cResult
END FUNCTION
FUNCTION GetArguments AS C ( pTableDef AS P, lv AS P )
DIM cResult AS C
FOR EACH x IN pTableDef.pArgs.arrArgs
IF (":"+x.Name) $ pTableDef.Filter
x.value = GetValue(x, lv)
END IF
NEXT
cResult = a5_ArgumentsReplace(pTableDef.filter, pTableDef.pArgs.arrArgs)
GetArguments = cResult
END FUNCTION
FUNCTION GetValue AS A ( pArg AS P , lv AS P)
DIM aResult AS A
DIM var AS C
var = pArg.Source
IF eval_valid("lv." + var)
aResult = eval("lv."+var)
ELSE IF eval_valid(var)
aResult = eval(var)
ELSE
DIM pArgDlg AS P
IF pArg.Prompt .AND. pArg.DefaultValue = ""
pArgDlg = a5_ArgPromptDialog(pArg)
IF pArgDlg.lastbutton = "cancel"
EXIT FUNCTION
END IF
aResult = pArgDlg.value
ELSE
aResult = convert_type(pArg.DefaultValue, left(pArg.DataType,1))
END IF
END IF
GetValue = aResult
END FUNCTION
------------------------------------------------------------
Comment