I have a dialog that queries records and displays them amongst other things. I now want to add the facility to display which entries are not found (to be processed later on).
Dim SV[12] as c
fmt = "{B=#0+255+255}{C=Red}"
DIM shared rc as n
DIM Filter[14] as c
DIM SHARED SearchOption as C = "Reg"
DELETE a_Search
dim temp_list as c
ShowError = .f.
messageText = fmt+" "
temp_list = <<%list%
All
Reg
Code
Line No
Msn
Mode S
Old_Id
Operator
When
Where
%list%
lc = *count(temp_list)
Dim a_search[lc] as c
a_Search.initialize(temp_list)
reg_search_dialog_title = "Multiple Search"
ui_modeless_dlg_box(reg_search_dialog_title,<<%dlg%
{Background=#0+255+255}
{startup=reset}
{region1}
1:| [.16SV1]{sp} 2:| [.16SV2]{sp} 3:| [.16SV3]{sp} 4:| [.16SV4];
5:| [.16SV5]{sp} 6:| [.16SV6]{sp} 7:| [.16SV7]{sp} 8:| [.16SV8];
9:| [.16SV9]{sp} 10:| [.16SV10]{sp} 11:| [.16SV11]{sp} 12:| [.16SV12];
{endregion1}
{region}
[.12,5SearchOption^#a_Search];
{endregion};
{line=1,0};
{region}
{sp=2}
<%T=Run Search;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Gold}Search%10,1!SEARCH>{sp=2}
<%T=Reset Variables;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Gold}Reset%10,1!RESET>{sp=2}
<%T=Close Dialog;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Gold}Close%10,1!CLOSE>{sp=2}
<%T=Log Queried Records;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Green}Log%10,1!LogRecords>{sp3}
{condition=(ShowError=.t.)}
{text=%O={@@}%42,1:Messagetext};
{endregion}
%dlg%,<<%code%
if a_dlg_button = "CLOSE" then
a_dlg_button = ""
ui_modeless_dlg_close(reg_search_dialog_title)
end if
if a_dlg_button = "SEARCH" then
svlist = sv1+"|"+sv2+"|"+sv3+"|"+sv4+"|"+sv5+"|"+sv6+"|"+sv7+"|"+sv8+"|"+sv9+"|"+sv10+"|"+sv11+"|"+sv12
trace.writeln(svlist)
Filter[1] = if(isblank("var->SV1"),"",setFilter(SearchOption,SV1))
Filter[2] = if(isblank("var->SV2"),"",setFilter(SearchOption,SV2))
Filter[3] = if(isblank("var->SV3"),"",setFilter(SearchOption,SV3))
Filter[4] = if(isblank("var->SV4"),"",setFilter(SearchOption,SV4))
Filter[5] = if(isblank("var->SV5"),"",setFilter(SearchOption,SV5))
Filter[6] = if(isblank("var->SV6"),"",setFilter(SearchOption,SV6))
Filter[7] = if(isblank("var->SV7"),"",setFilter(SearchOption,SV7))
Filter[8] = if(isblank("var->SV8"),"",setFilter(SearchOption,SV8))
Filter[9] = if(isblank("var->SV9"),"",setFilter(SearchOption,SV9))
Filter[10] = if(isblank("var->SV10"),"",setFilter(SearchOption,SV10))
Filter[11] = if(isblank("var->SV11"),"",setFilter(SearchOption,SV11))
Filter[12] = if(isblank("var->SV12"),"",setFilter(SearchOption,SV12))
fc = Filter.first_empty()-1
query.filter = Filter[1]
for x = 2 to fc
query.filter = query.filter + ".or." +filter[x]
next X
query.order = "reg"
t = table.current()
qry = t.query_create()
rc = qry.records_get()
if rc > 0 then
MessageText = fmt+" "
showError = .f.
topparent.refresh_layout()
else
showError = .t.
MessageText = fmt+"Nothing Found in "+quote(upper(SearchOption),"'")+" Field"
end if
end if
if a_dlg_button = "RESET" then
a_dlg_button = ""
SV1 = ""
SV2 = ""
SV3 = ""
SV4 = ""
SV5 = ""
SV6 = ""
SV7 = ""
SV8 = ""
SV9 = ""
SV10 = ""
SV11 = ""
SV12 = ""
showError = .f.
messageText = ""
SearchOption = "Reg"
filter.clear()
end if
if a_dlg_button = "LogRecords" then
topparent.fetch_first()
x = 1
while x <= rc
if rtrim(topparent:as.value) = "" then
topparent.change_mode()
topparent:As.value = topparent:reg.value
topparent:when.value = date()
topparent:where.value = "PAGANHILL-OTT"
topparent:h.value = "01"
topparent.commit()
topparent.refresh_layout()
end if
if x < rc then
topparent.fetch_next()
end if
x = x + 1
end while
a_dlg_button = ""
end if
%code%)
FUNCTION SetFilter AS C (Search as C, SV AS C )
select
case Search = "All"
SetFilter = quote(var->SV)+" $ alltext()"
case search = "Code"
SetFilter = "Code="+quote(var->SV)+".and.left(c2,2)='GL'"
case search = "Line No"
SetFilter = "Line_no="+quote(var->SV)
case search = "msn"
SetFilter = "Msn="+quote(var->SV)
case search = "Reg"
SetFilter = "reg="+quote(var->SV)
case Search = "Mode S"
SetFilter = "ModeS="+quote(var->SV)
case Search = "Old_Id"
SetFilter = quote(var->SV)+" $ Old_Id"
case Search = "Where"
SetFilter = "Where="+quote(var->SV)
case Search = "When"
if SV = "Today" then
SetFilter = "when={"+date()+"}"
else
SetFilter = "when={"+ctod(var->SV)+"}"
end if
case Search = "Operator"
opuniq = lookupc("f",SV,"operator_unique","Operator_names","operator_name")
SetFilter = "op_unique="+quote(opuniq)
end select
END FUNCTION
fmt = "{B=#0+255+255}{C=Red}"
DIM shared rc as n
DIM Filter[14] as c
DIM SHARED SearchOption as C = "Reg"
DELETE a_Search
dim temp_list as c
ShowError = .f.
messageText = fmt+" "
temp_list = <<%list%
All
Reg
Code
Line No
Msn
Mode S
Old_Id
Operator
When
Where
%list%
lc = *count(temp_list)
Dim a_search[lc] as c
a_Search.initialize(temp_list)
reg_search_dialog_title = "Multiple Search"
ui_modeless_dlg_box(reg_search_dialog_title,<<%dlg%
{Background=#0+255+255}
{startup=reset}
{region1}
1:| [.16SV1]{sp} 2:| [.16SV2]{sp} 3:| [.16SV3]{sp} 4:| [.16SV4];
5:| [.16SV5]{sp} 6:| [.16SV6]{sp} 7:| [.16SV7]{sp} 8:| [.16SV8];
9:| [.16SV9]{sp} 10:| [.16SV10]{sp} 11:| [.16SV11]{sp} 12:| [.16SV12];
{endregion1}
{region}
[.12,5SearchOption^#a_Search];
{endregion};
{line=1,0};
{region}
{sp=2}
<%T=Run Search;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Gold}Search%10,1!SEARCH>{sp=2}
<%T=Reset Variables;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Gold}Reset%10,1!RESET>{sp=2}
<%T=Close Dialog;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Gold}Close%10,1!CLOSE>{sp=2}
<%T=Log Queried Records;O={J=C,C}{C=Brown}{F=Bahnschrift,10,B}{B=Green}Log%10,1!LogRecords>{sp3}
{condition=(ShowError=.t.)}
{text=%O={@@}%42,1:Messagetext};
{endregion}
%dlg%,<<%code%
if a_dlg_button = "CLOSE" then
a_dlg_button = ""
ui_modeless_dlg_close(reg_search_dialog_title)
end if
if a_dlg_button = "SEARCH" then
svlist = sv1+"|"+sv2+"|"+sv3+"|"+sv4+"|"+sv5+"|"+sv6+"|"+sv7+"|"+sv8+"|"+sv9+"|"+sv10+"|"+sv11+"|"+sv12
trace.writeln(svlist)
Filter[1] = if(isblank("var->SV1"),"",setFilter(SearchOption,SV1))
Filter[2] = if(isblank("var->SV2"),"",setFilter(SearchOption,SV2))
Filter[3] = if(isblank("var->SV3"),"",setFilter(SearchOption,SV3))
Filter[4] = if(isblank("var->SV4"),"",setFilter(SearchOption,SV4))
Filter[5] = if(isblank("var->SV5"),"",setFilter(SearchOption,SV5))
Filter[6] = if(isblank("var->SV6"),"",setFilter(SearchOption,SV6))
Filter[7] = if(isblank("var->SV7"),"",setFilter(SearchOption,SV7))
Filter[8] = if(isblank("var->SV8"),"",setFilter(SearchOption,SV8))
Filter[9] = if(isblank("var->SV9"),"",setFilter(SearchOption,SV9))
Filter[10] = if(isblank("var->SV10"),"",setFilter(SearchOption,SV10))
Filter[11] = if(isblank("var->SV11"),"",setFilter(SearchOption,SV11))
Filter[12] = if(isblank("var->SV12"),"",setFilter(SearchOption,SV12))
fc = Filter.first_empty()-1
query.filter = Filter[1]
for x = 2 to fc
query.filter = query.filter + ".or." +filter[x]
next X
query.order = "reg"
t = table.current()
qry = t.query_create()
rc = qry.records_get()
if rc > 0 then
MessageText = fmt+" "
showError = .f.
topparent.refresh_layout()
else
showError = .t.
MessageText = fmt+"Nothing Found in "+quote(upper(SearchOption),"'")+" Field"
end if
end if
if a_dlg_button = "RESET" then
a_dlg_button = ""
SV1 = ""
SV2 = ""
SV3 = ""
SV4 = ""
SV5 = ""
SV6 = ""
SV7 = ""
SV8 = ""
SV9 = ""
SV10 = ""
SV11 = ""
SV12 = ""
showError = .f.
messageText = ""
SearchOption = "Reg"
filter.clear()
end if
if a_dlg_button = "LogRecords" then
topparent.fetch_first()
x = 1
while x <= rc
if rtrim(topparent:as.value) = "" then
topparent.change_mode()
topparent:As.value = topparent:reg.value
topparent:when.value = date()
topparent:where.value = "PAGANHILL-OTT"
topparent:h.value = "01"
topparent.commit()
topparent.refresh_layout()
end if
if x < rc then
topparent.fetch_next()
end if
x = x + 1
end while
a_dlg_button = ""
end if
%code%)
FUNCTION SetFilter AS C (Search as C, SV AS C )
select
case Search = "All"
SetFilter = quote(var->SV)+" $ alltext()"
case search = "Code"
SetFilter = "Code="+quote(var->SV)+".and.left(c2,2)='GL'"
case search = "Line No"
SetFilter = "Line_no="+quote(var->SV)
case search = "msn"
SetFilter = "Msn="+quote(var->SV)
case search = "Reg"
SetFilter = "reg="+quote(var->SV)
case Search = "Mode S"
SetFilter = "ModeS="+quote(var->SV)
case Search = "Old_Id"
SetFilter = quote(var->SV)+" $ Old_Id"
case Search = "Where"
SetFilter = "Where="+quote(var->SV)
case Search = "When"
if SV = "Today" then
SetFilter = "when={"+date()+"}"
else
SetFilter = "when={"+ctod(var->SV)+"}"
end if
case Search = "Operator"
opuniq = lookupc("f",SV,"operator_unique","Operator_names","operator_name")
SetFilter = "op_unique="+quote(opuniq)
end select
END FUNCTION
Comment