Hello all, I have been working on this progressive find for the database I am working on, using the AlphaSports example as a guide. I've searched the forums too and it helped a little.
I initially started using ActionScript, but ended up converting it into xBasic because I wanted to change something. Now I realize I can't go back, and am stuck trying to do this in xBasic :O
My button on a form, when clicked plays this 'progressive find' script. When I click the "Go To Record" button or double click one of the entries, it should go to that particular record on the form. At the moment, when I click on the Go To Record button, I get an error saying:
Any thoughts on how I can make my Go To Record button actually go to the corresponding record? (I would like it to do the same thing when double-clicking the entry too). I'm not sure why my function is not recognized.
Any help appreciated!
Here is the code:
I initially started using ActionScript, but ended up converting it into xBasic because I wanted to change something. Now I realize I can't go back, and am stuck trying to do this in xBasic :O
My button on a form, when clicked plays this 'progressive find' script. When I click the "Go To Record" button or double click one of the entries, it should go to that particular record on the form. At the moment, when I click on the Go To Record button, I get an error saying:
"Script:UI_DLG_BOX:Lookup Work Order line:44 t.fetch_goto(FindRecNoForIssue_Count(vIssue_Count)) Function is not recognized"
Any thoughts on how I can make my Go To Record button actually go to the corresponding record? (I would like it to do the same thing when double-clicking the entry too). I'm not sure why my function is not recognized.
Any help appreciated!
Here is the code:
Code:
'Create an XDialog dialog box to prompt for work order number DIM SHARED Issue_Count as C DIM SHARED varC_result as C DIM Listbox_FuncCode AS C = <<%CodeFunctions% FUNCTION DoSort AS C (byref CurrentSortField AS C , byref CurrentSortDirection AS C, NewSortField AS C, pTableDef AS P, arrContents 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 arrContents.sort(SortDirection, stritran(SortField, "->", "__")) cResult = DumpContents(pTableDef, arrContents) DoSort = cResult END FUNCTION FUNCTION GetContents AS C ( pTableDef AS P, arrContents AS P, lv AS P ) DIM cResult AS C arrContents.Clear() DIM FieldList AS C DIM Content_Expression AS C DIM t AS P DIM Filter AS C DIM arrTemp[1] AS P IF .NOT. file.exists(table.filename_get(pTableDef.TableName)) EXIT FUNCTION END IF t = table.open(pTableDef.TableName, FILE_RO_SHARED) arrContents.resize(t.records_get()) arrTemp.resize(arrContents.size()) t.close() Filter = pTableDef.Filter Filter = GetArguments(pTableDef, lv) Filter = convert_expression( Filter, "VC","",lv) ' arrContents.initialize_from_Table(pTableDef.TableName, Filter, pTableDef.Order) arrTemp.initialize_from_Table(pTableDef.TableName, Filter, pTableDef.Order) arrContents.resize(arrTemp.size()) arrContents.copy_from(arrTemp) cResult = DumpContents(pTableDef, arrContents) GetContents = cResult END FUNCTION FUNCTION DumpContents AS C ( pTableDef AS P, arrContents AS P ) DIM cResult AS C DIM cEval AS C pTableDef.FieldList = alltrim(pTableDef.FieldList) IF pTableDef.FieldList = "" EXIT FUNCTION END IF cEval = *for_each(x, "TrimCRLFs(x." + stritran(table.name_normalize(x),"->", "__")+")", pTableDef.FieldList) cEval = alltrim(cEval) cEval = stritran(cEval, crlf(), "+"+quote("|")+ "+") IF pTableDef.ReturnValueExpression <> "" cEval = quote("{DATA=") + " + TrimCRLFs(x." + stritran(table.name_normalize(pTableDef.ReturnValueExpression),"->", "__") + ")+" + quote("}")+ "+" + cEval END IF cEval = "*for_each(x, " + cEval + ", arrContents)" cResult = eval(cEval) cResult = a5_owner_draw_list_fmt(cResult, pTableDef.pAdvFormatting, "listview") DumpContents = cResult END FUNCTION FUNCTION TrimCRLFs AS A ( data AS A ) IF typeof(data) = "C" TrimCRLFs = stritran(data, crlf(), " ") ELSE TrimCRLFs = data END IF 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 Listbox_Funcs AS P = compile_template(Listbox_FuncCode) DIM Listbox_arrContents[1] AS P DIM SHARED Listbox AS C DIM Listbox_CurrentSortField AS C = "Issue_Count" DIM Listbox_CurrentSortDirection AS C = "A" DIM Listbox_pTableDef AS P DIM Listbox_pTableDef.ReturnValueExpression AS C = "Issue_count" DIM Listbox_pTableDef.FieldList AS C = <<%txt% Issue_count Time Completed Person_Calling Company Subject %txt% DIM Listbox_pTableDef.TitleRow AS C = "{AUTOSIZEHEAD}WO #|{AUTOSIZE}Time|{AUTOSIZE}Complete?|{AUTOSIZE}Person Calling|{AUTOSIZE}Company|{AUTOSIZE}Subject" DIM Listbox_pTableDef.Arguments AS C = <<%txt% <lastbutton="cancel"> <arrArgs<[1]<Name="argIssue_Count"> <DataType="Character"> <Source="Variable"> <SourceDisplay="Get value from variable"> <VariableScope="Session Variable"> <VariableName="Issue_Count"> <VariableWithScope="Issue_Count (Session Variable)"> <DefaultValue=""> <Prompt=.F.> <PromptText=""> <PromptControlType="Text Box"> <PromptChoices=""> <PromptDlgTitle="Missing Argument"> <PromptTextAbove=""> <PreviewValue=""> > > %txt% DIM Listbox_pTableDef.pArgs AS P property_from_string(Listbox_pTableDef.pArgs, Listbox_pTableDef.Arguments) DIM Listbox_pTableDef.TableName AS C = "hosted_downtown" DIM Listbox_pTableDef.Filter AS C = "left(issue_count, len(:argIssue_Count)) = :argIssue_Count .AND. (recno() > 0)" ' recno() > 0 is required in order to avoid showing deleted variables DIM Listbox_pTableDef.Order AS C = "Issue_Count" DIM Listbox_pTableDef.pAdvFormatting AS P DIM Listbox_pTableDef.pAdvFormatting.alternating_bands AS L = .t. DIM Listbox_pTableDef.pAdvFormatting.group_size AS N = 1 DIM Listbox_pTableDef.pAdvFormatting.odd_row_color AS C = "White" DIM Listbox_pTableDef.pAdvFormatting.even_row_color AS C = "#240+255+234" DIM Listbox_pTableDef.pAdvFormatting.odd_selected_color AS C = "Dark Blue" DIM Listbox_pTableDef.pAdvFormatting.even_selected_color AS C = "Dark Blue" DIM Listbox_pTableDef.pAdvFormatting.font AS C = "Arial,8" DIM Listbox_pTableDef.pAdvFormatting.font_color_unselected AS C = "Black" DIM Listbox_pTableDef.pAdvFormatting.font_color_selected AS C = "White" DIM Listbox_pTableDef.pAdvFormatting.number_rows AS L = .f. DIM Listbox_pTableDef.pAdvFormatting.tab_stops AS C = "" Listbox_pLV.titlerow = Listbox_pTableDef.titlerow Listbox_pLV.titleevents = "Listbox_Sort_Issue_count|Listbox_Sort_Time|Listbox_Sort_Completed|Listbox_Sort_Person_Calling|Listbox_Sort_Company|Listbox_Sort_Subject" Listbox_pLV.style = "report,singlesel,showselalways,fullrowselect" Listbox_pLV.dragbehaviour = "" Listbox_pLV.dropbehaviour = "" Listbox_pLV.contents = Listbox_Funcs.GetContents(Listbox_pTableDef, Listbox_arrContents, local_variables()) Listbox_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 Listbox = listView.GetRowValue(args.GetClickRow()) 'ui_msg_box("On Double Click",Listbox) 'COMMENT OUT IF NO-GO t = topparent.table_get() dim recno_for_issue_count as c recno_for_issue_count = ui_dlg_eval(dlg_title,"FindRecNoForIssue_Count(vIssue_Count)") t.fetch_goto(recno_for_issue_count) topparent.resynch() if flagCloseAfterFind then ui_dlg_event(dlg_title,"Close") end if 'END EDITED CODE END WITH end function 'new code FUNCTION FindRecNoForIssue_Count AS C (vIssue_Count AS C ) DIM t AS P DIM nResult AS N t = table.open("hosted_downtown", FILE_RO_SHARED) t.order("Issue_Count") nResult = t.fetch_find(vIssue_Count) t.close() FindRecNoForIssue_Count() = nResult ?nresult END FUNCTION FUNCTION OnSelectionChanged AS V (lv AS P, listView as p ) WITH lv Listbox = listView.Selection ' ui_msg_box("OnSelectionChanged",Listbox) 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% ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Lookup Work Order",<<%dlg% {region} Work Order #:| [.40Issue_Count]; | {listviewcustom=125,30Listbox^=Listbox_pLV}; {watch=Issue_Count!Listbox_refresh} {watch=Listbox!foo}; <*%T= Bubble help for button;%Go To Record!GoToRecord_button_click> {endregion}; {line=1,0}; {region} <15=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% IF left(a_dlg_button, len("Listbox_Sort_")) = "Listbox_Sort_" DIM NewSortField AS C NewSortField = substr(a_dlg_button, len("Listbox_Sort_")+1) Listbox_pLV.Contents = Listbox_Funcs.DoSort(Listbox_CurrentSortField, Listbox_CurrentSortDirection, NewSortField, Listbox_pTableDef, Listbox_arrContents) a_dlg_button = "" END IF IF a_Dlg_button = "Listbox_refresh" a_dlg_button = "" Listbox_pLV.contents = Listbox_Funcs.GetContents(Listbox_pTableDef, Listbox_arrContents, local_variables()) END IF IF a_dlg_button = "foo" a_dlg_button = "" ' do nothing END IF 'IF a_dlg_button = "goto_record" ' a_dlg_button = "" ' t = topparent.Table_Get() ' t.fetch_goto(FindRecNoForIssue_Count(vIssue_Count)) ' topparent.resynch() ' if flagCloseAfterFind then ' ui_modeless_dlg_close(dlg_title) ' end if 'end if if a_dlg_button = "GoToRecord_button_click" then a_dlg_button = "" t = topparent.Table_Get() t.fetch_goto(FindRecNoForIssue_Count(vIssue_Count)) topparent.resynch() if flagCloseAfterFind then ui_modeless_dlg_close(dlg_title) end if end if %code%)
Comment