I have studied the progressive find in Alphasports and in the Learning Xdialog samples but can't figure out how to make the first row populate my search variable (vName). If I don't click on the first row it doesn't populate the variable. Can someone help me with this?
Code:
'Date Created: 04-Dec-2007 12:28:46 AM 'Last Updated: 12-May-2009 12:22:07 AM 'Created By : David 'Updated By : David 'Inline-Xbasic. Converted from: Create an XDialog dialog box to prompt for parameters. 'Create an XDialog dialog box to prompt for parameters. CountRecords() OPTION break DIM SHARED vLastname as C DIM SHARED vName as C DIM SHARED vFirstname as C DIM SHARED vSpouse as C DIM SHARED vSSN as C DIM SHARED vClientid as C DIM SHARED vAddress as C DIM SHARED vCity as C DIM SHARED vState as C DIM SHARED vZipCode as C DIM SHARED vHomephone as C DIM SHARED vWorkphone as C DIM SHARED vCellphone as C DIM SHARED vFaxphone as C DIM SHARED vE_Mail as C DIM SHARED vE_Mail1 as C DIM SHARED vEmployer as C DIM SHARED vProspects as L DIM SHARED vReferrals as L DIM SHARED varC_result as C vProspects = .f. vReferrals = .f. vName = "" '--------------- restart: '--------------- DIM vName_FuncCode as C = <<%CodeFunctions% 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 DIM pv AS P FOR EACH x IN pTableDef.pArgs.arrArgs IF (":"+x.Name) $ pTableDef.Filter pv = A5_ArgGetValue(x, lv) x.value = pv.value END IF NEXT cResult = a5_ArgumentsReplace(pTableDef.filter, pTableDef.pArgs.arrArgs) GetArguments = cResult END FUNCTION %CodeFunctions% DIM vName_Funcs as P = compile_template(vName_FuncCode) DIM SHARED vName as C DIM vName_CurrentSortField as C = "lastname" DIM vName_CurrentSortDirection as C = "A" DIM vName_Filter as C DIM vName_pTableDef as P DIM vName_pTableDef.ReturnValueExpression as C = "Client_id" DIM vName_pTableDef.FieldList as C = <<%txt% Client_id Lastname Firstname Suffix Soc_sec_no Spouse Sp_ss_no trim(Address1) + " " + trim(Address2) City State Zip_code %txt% DIM vName_pTableDef.TitleRow as C = "{WIDTH=0.5}Id|{WIDTH=1.5}Lastname|{WIDTH=1.2}Firstname|{WIDTH=.3}S|{WIDTH=1}Soc_sec_no|{WIDTH=1.2}Spouse|{WIDTH=1}Sp_ss_no|{WIDTH=1.5}Address|{WIDTH=1.2}City|{WIDTH=0.4}St|{WIDTH=.7}Zip_code" DIM vName_pTableDef.Arguments as C = <<%txt% <lastbutton="ok"> <arrArgs<[1]<Name="argLastname"> <DataType="Character"> <Source="Variable"> <SourceType="Local Variable"> <DefaultValue=""> <Prompt=.F.> <PromptText=""> <PromptControlType="Text Box"> <PromptChoices=""> <PromptDlgTitle="Missing Argument"> <PromptTextAbove=""> <SourceDisplay="Get value from variable"> <VariableScope="Session Variable"> <VariableName="vLastname"> <VariableWithScope="vLastname (Session Variable)"> <PreviewValue=""> %txt% DIM vName_pTableDef.pArgs as P property_from_string(vName_pTableDef.pArgs, vName_pTableDef.Arguments) DIM vName_pTableDef.TableName as C = "all_clients" DIM vName_pTableDef.Filter as C = "left(trim(lastname) + \" \" + trim(Firstname) + \" \" + trim(Suffix), len(:argLastname)) = :argLastname .AND. (recno() > 0)" ' recno() > 0 is required in order to avoid showing deleted variables DIM vName_pTableDef.Order as C = "Lastname+Firstname+Suffix" DIM vName_pTableDef.pAdvFormatting as P DIM vName_pTableDef.pAdvFormatting.alternating_bands as L = .t. DIM vName_pTableDef.pAdvFormatting.group_size as N = 2 DIM vName_pTableDef.pAdvFormatting.odd_row_color as C = "White" DIM vName_pTableDef.pAdvFormatting.even_row_color as C = "#214+214+255" DIM vName_pTableDef.pAdvFormatting.odd_selected_color as C = "Dark Blue" DIM vName_pTableDef.pAdvFormatting.even_selected_color as C = "Dark Blue" DIM vName_pTableDef.pAdvFormatting.font as C = "Arial,8" DIM vName_pTableDef.pAdvFormatting.font_color_unselected as C = "Dark Blue" DIM vName_pTableDef.pAdvFormatting.font_color_selected as C = "White" DIM vName_pTableDef.pAdvFormatting.number_rows as L = .f. DIM vName_pTableDef.pAdvFormatting.tab_stops as C = "" vName_pLV.titlerow = vName_pTableDef.titlerow vName_pLV.titleevents = "vName_Sort_Client_id|vName_Sort_Lastname|vName_Sort_Suffix|vName_Sort_Firstname|vName_Sort_Soc_sec_no|vName_Sort_Spouse|vName_Sort_Sp_ss_no|vName_Sort_Address1|vName_Sort_City|vName_Sort_State|vName_Sort_Zip_code" vName_pLV.style = "report,singlesel,gridlines,fullrowselect" vName_pLV.dragbehaviour = "" vName_pLV.dropbehaviour = "" DIM vName_t as P DIM vName_rr as Alpha5::RowRelation DIM vName_rs as P IF .NOT. file.exists(table.filename_get(vName_pTableDef.TableName)) END' END IF vName_t = table.open(vName_pTableDef.TableName, FILE_RO_SHARED) vName_t.persist() vName_rs = vName_rr.TableToRowSource(vName_t) vName_Filter = vName_Funcs.GetArguments(vName_pTableDef, local_variables()) vName_pLV.rowview = vName_rs.OpenView(1, vName_pTableDef.Order, vName_Filter) vName_pLV.RowSeparator = crlf() vName_pLV.ColumnSeparator = "|" vName_pLV.Key = vName_pTableDef.ReturnValueExpression vName_pLV.Columns = a5_owner_draw_list_fmt(vName_pTableDef.FieldList, vName_pTableDef.pAdvFormatting, "listviewvirtual") vName_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) END WITH END FUNCTION FUNCTION OnDoubleClick as C(lv as P, listView as P, args as P) WITH lv vName = listView.GetRowValue(args.GetClickRow()) END WITH END FUNCTION FUNCTION OnSelectionChanged AS V (lv as P, listView as P) WITH lv vName = 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 END FUNCTION %code% ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Search by Last Name", <<%dlg% {background=Blue White}{font= tahoma, 10} {region} | [.40vLastname]; | {listviewvirtual=205,25vName^=vName_pLV}; {watch=vLastname!vName_refresh} {watch=vName!foo}; {endregion}; {line=1,0}; {region} <%B=M%15Last Name!last> |<%B=M%15First Name!first> |<%B=M%15Client SSN!c_ssn> | <%B=M%15Address!address> |<%B=M%15State!state> |<%B=M%15Home Phone!hphone> | <%B=M%15Cell Phone!cphone> | <%B=M%15EMail!email> |<%B=M%15Employer!employer>; <%B=M%15Client Id!c_id> |<%B=M%15Spouse!spouse> |<%B=M%15Spouse SSN!s_ssn> | <%B=M%15City!city> |<%B=M%15Zip Code!zip> |<%B=M%15Work Phone!wphone> | <%B=M%15Fax Phone!fphone> | <%B=M%15EMail_1!email1>; {endregion}; {line=1,0}; {region} <*15=ok_button_label!OK?vName<\>""> <15=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% IF left(a_dlg_button, len("vName_Sort_")) = "vName_Sort_" DIM NewSortField as C NewSortField = substr(a_dlg_button, len("vName_Sort_") + 1) vName_Funcs.DoSort(vName_CurrentSortField, vName_CurrentSortDirection, NewSortField, vName_Filter, vName_pLV, vName_rs) a_dlg_button = "" END IF IF a_Dlg_button = "vName_refresh" a_dlg_button = "" vName_Filter = vName_Funcs.GetArguments(vName_pTableDef, local_variables()) vName_pLV.RowView.Close() vName_pLV.RowView = vName_rs.OpenView(1, vName_CurrentSortField, vName_Filter) END IF IF a_dlg_button = "foo" a_dlg_button = "" ' do nothing END IF %code%) vName_t.close() IF vname = "" .and. varC_result = "OK" GOTO restart END IF IF varC_result = "Cancel" END' END IF script_play("Search_Finish") END'
Comment