Alpha Video Training
Results 1 to 10 of 10

Thread: Is it Possible to display results of xdialog query in same xdialog?

  1. #1
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Is it Possible to display results of xdialog query in same xdialog?

    is it possilbe to show the results of a query by xdialog in the same dialog box or can it only be displayed in another one?

    i.e. in the above example, after setting the query parameters (operator, ICAO or IATA) can I then display the results of this query in the the red coloured area in original xdialog?

    see attachment.
    Attached Images Attached Images
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  2. #2
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,682

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    You can create a browse to display the records and use the advanced menu to create an xdialog to copy into your script.
    Have a look at this thread HERE
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  3. #3
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    Thanks Robin, will have a look.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  4. #4
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    this is way, way above my level of understanding of Alpha 5 (been using Alpha 5 in its various editions for 25 years, but only at the hobby level to keep my aviation database up to date), is there a simpler way of doing this?
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  5. #5
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,682

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    Do you have a sample table you can upload here?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  6. #6
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    ignore
    Last edited by Graham Wickens; 10-05-2019 at 05:01 PM.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  7. #7
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    Ive stripped out as much as I can.
    Attached Files Attached Files
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  8. #8
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    Eventually come up with my own solution:


    Code:
    on error goto error_routine
    DIM form_name as C
    if is_object(topparent.this) then
    	form_name = topparent.name()+".this"
    else
    	form_name = ""
    end if
    DIM SHARED FmtSearchMsg as c = "{C=Red}{B=Tan}"
    DIM SHARED index as n
    DIM SHARED vAircraftType as C 
    DIM SHARED vBaseName as C 
    DIM SHARED vClass as C 
    DIM SHARED vCode as C 
    DIM SHARED vDLsize as n = 6000
    DIM SHARED vDisplayLookup[vDLsize] as p
    DIM SHARED vEndDate as D
    DIM SHARED vField as c 
    DIM SHARED vFilter as c 
    DIM SHARED vFragOption as C 
    DIM SHARED vFragment as C 
    DIM SHARED vOperatorUniq as c 
    DIM SHARED vOption as C 
    DIM SHARED vOrder as c 
    DIM SHARED vPrCountry as C 
    DIM SHARED vPrCountryOpt as C 
    DIM SHARED vPrOpt as C 
    DIM SHARED vProdAcUniq as C 
    DIM SHARED vProdTypeCode as C
    DIM SHARED vReg as C 
    DIM SHARED vSearchMsg as C
    DIM SHARED vStartDate as D
    DIM SHARED vStatus as C 
    DIM SHARED vTable as C = "Logging"
    DIM SHARED vUsage as C 
    DIM SHARED varC_result as C 
    DIM SHARED showArray as l = .f.
    DELETE expression_result
    expression_result = eval("date()",form_name)
    vStartDate = convert_type(expression_result,"D")
    DELETE expression_result
    expression_result = eval("date()",form_name)
    vEndDate = convert_type(expression_result,"D")
    DIM vOperatorUniqDef as C =  "k=appendix_c,{keylist_build(\"H=.05,1:48,2:6.2,3:17\",''+unique,left(''+operator,48),left(''+icao,6.2),left(''+country,17))}{c3 <> \"X\"}"
    DIM vAircraftTypeDef as C = "k=aircraft_type,{keylist_build(\"H=.05,1:40\",''+ac_unique,left(''+aircraft_type,40))}{}"
    DIM vBaseNameDef as C = "k=base_details,{keylist_build(\"H=.05,1:32,2:8,3:16\",''+unique,left(''+base,32),left(''+icao_code,8),left(''+country,16))}{}"
    DIM vClassDef as C = "k=c1,{keylist_build(\"H=.05,1:8,2:25\",''+c1,left(''+c1,8),left(''+description,25))}{}"
    DIM vStatusDef as C = "k=status,{keylist_build(\"H=.05,1:8,2:25\",''+c3,left(''+c3,8),left(''+desc,25))}{}"
    DIM vUsageDef as C = "k=c2,{keylist_build(\"H=.05,1:8,2:25\",''+c2,left(''+c2,8),left(''+description,25))}{}"
    DIM vProdTypeCodeDef as C = "k=aircraft_type,{keylist_build(\"H=.05,1:42\",''+type_code,left(''+aircraft_type,42))}{generic = .t.}"
    DIM vPrCountryDef as C  = "k=prefix,{keylist_build(\"H=.05,1:32\",''+name12,left(''+country,32))}{usage_c = .t.}"
    varC_result = ui_dlg_box("Query Selection",<<%dlg%
    {Background=#234+234+255}
    {xmargin=1,1}
    {removecomments}
    {xmargin=1,1}
    {removecomments}
    {font=Arial,10}
    {region1}
    (vOption:Aircraft Class);
    (vOption:Aircraft Type);
    (vOption:Aircraft Usage);
    (vOption:Base List);
    (vOption:Code);
    (vOption:Dates);
    (vOption:Operator Name);
    (vOption:Production List);
    (vOption:Reg);
    {Line=1,0};
    {condition=(vOption="Aircraft Usage")}
    	{start_pos}{region}
    Usage: [%@vUsageDef%8vUsage!UsageEvent_*];
    {endregion}	
    {condition=(vOption="Aircraft Type")}
    	{start_pos}{region}
    Type: [%@vAircraftTypeDef%.30vAircraftType!AcTypeEvent_*];
    	{endregion}
    {condition=(vOption="Base List")}
    	{start_pos}{region}
    Name: [%@vBaseNameDef%.40vBaseNameUniq!BaseNameEvent_*];
    	{endregion}
    {condition=(vOption="Aircraft Class")}
    	{start_pos}{region}
    Class: [%@vClassDef%.6vClass!ClassEvent_*];
    	{endregion}
    {condition=(vOption="Code")}
    	{start_pos}
    	{region}
    (vCodeOpt:All)(vCodeOpt:Civ)(vCodeOpt:Mil);
    {endregion}
    {region}
    Code: [.8vCode!CodeEvent_*];
    	{endregion}
    {condition=(vOption="Dates")}
    	{start_pos}{region}
    (vDateOpt:Day)(vDateOpt:Month);
    (vDateOpt:Period)(vDateOpt:Week);
    (vDateOpt:Year)(vDateOpt:Location);
    Start: [%DATE;P=popup.calendar(dtoc(vStartDate));I=popup.calendar%.18vStartDate!vStartDate_*];
    {condition=(vOption="Dates".and.vDateOpt="period")}
    End:  [%DATE;P=popup.calendar(dtoc(vEndDate));I=popup.calendar%.18vEndDate!vEndDate_*];
    	{endregion}
    {condition=(vOption="Operator Name")}
    	{start_pos}{region}
    Operator: [%@vOperatorUniqDef%.42vOperatorUniq!OperEvent_*];
    	{endregion}
    {condition=(vOption="Production List")}
    	{start_pos}{region}
    (vPrOpt:MSN)(vPrOpt:Line No);
    (vPrOpt:Assembly no)(vPrOpt:Plane set);
    (vPrOpt:Variant no)(vPrOpt:Centre Fuselage);
    (vPrOpt:Front Fuselage);
    {region}
    (vPrCountryOpt:All) 
    (vPrCountryOpt:Country)
    {condition=(vOption="Production List".and.vPrCountryOpt="Country")}
    [%@vPrCountryDef%.20vPrCountry];
    {condition=(vOption="Production List".and.vPrCountryOpt<>"")}
    Type: [%@vProdTypeCodeDef%.40vProdTypeCode!ProdEvent_*]
    {endregion}
    {condition=(vOption="Status")}
    	{start_pos}{region}
    Status: [%@vStatusDef%.20vStatus!StatusEvent_*];
    	{endRegion}
    {endregion}
    {condition=(vOption="Reg")}
    {condition=(vOption="Reg")}
    	{start_pos}{region}
    Reg/Serial:| [.16vReg!RegEvent_*]
    	{endregion};
    {condition=.t.}
    <%T=Run Query;O={J=C,C}{C=Red}{F=Bookman Old Style,10}{B=Tan}Go%8,1.5!Go>
    <%T=Close Dialog;O={J=C,C}{C=Red}{F=Bookman Old Style,10}{B=Tan}Close%8,1.5!Close>
    {sp=2}{text=30vSearchMsg};
    {endregion1}
    {region3}		
    {region}
    {font=Arial Narrow,8}
    {condition=(showArray=.t.)}
    {sp=1}[%O==FmtCurrLogg(eval(value))%.130,26index^#vdisplayLookup];
    {sp=1}{text=100:vFilter+"~"+vorder+"~"+vOption}
    {font=Arial,10}
    {endregion};
    {endregion3};
    ;{endregion1}
    %dlg%,<<%code%
    trace.writeln(a_dlg_button)
    if left(a_dlg_button,11) = "vStartDate_" then
    	if a_dlg_button = "vStartDate_killfocus" then
    		vStartDate = ctod(dtoc(vStartDate))
    		select
    			case vDateOpt = "Day"
    				vEndDate = vStartDate
    			case vDateOpt = "Month"
    				vEndDate = vStartDate-31
    			case vDateOpt = "Week"
    				vEndDate = vStartDate-8
    			case vDateOpt = "Year"
    				vEnddate = vstartdate-365
    		end select
    		vFilter = "(when >= Var->vStartDate  )  .and. (when <= Var->vEndDate  )"
    		vOrder = "cdate(when)+h+where+reg"
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,9) = "vEndDate_" then
    	if a_dlg_button = "vEndDate_killfocus" then
    		vEndDate = ctod(dtoc(vEndDate))
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,12) = "AcTypeEvent_" then
    	if a_dlg_button = "AcTypeEvent_selok" then
    		vFilter = "ac_unique="-quote(rtrim(vAircraftType))
    		vOrder = "REG"
    	end if
    	a_dlg_button= ""
    end if
    
    if left(a_dlg_button,14) = "BaseNameEvent_" then
    	if a_dlg_button = "BaseNameEvent_killfocus" then
    		vFilter = "base_unique="-quote(rtrim(vBaseNameUniq))
    		vOrder = "REG"
    
    	end if
    	a_dlg_button= ""
    end if
    
    if left(a_dlg_button,9) = "RegEvent_" then
    	if a_dlg_button = "RegEvent_killfocus" then
    		vFilter = "(reg="-quote(rtrim(vReg))-".or.as="-quote(rtrim(vReg))-").and.rtrim(Reg)<>'-CANX-'"
    		vOrder = "REG"
    	end if
    	a_dlg_button= ""
    end if
    
    if left(a_dlg_button,12) = "StatusEvent_" then
    	if a_dlg_button = "StatusEvent_killfocus" then
    		vFilter = "status="-quote(vStatus)
    		vOrder = "status+reg"
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,10) = "CodeEvent_" then
    	if a_dlg_button = "CodeEvent_killfocus" then
    		select
    			case vCodeOpt = "all"
    				vFilter = "status='C'.and.Code="-quote(vCode)-".and.rtrim(Reg)<>'-CANX-'"
    			case vCodeOpt = "civ"
    				vFilter = "status='C'.and.Code="-quote(vCode)-".and.rtrim(Reg)<>'-CANX-'.and. C1<>'M'"
    			case vCodeOpt = "mil"
    				vFilter = "(( '"-vCode-"' $ code ) )  .and. (reg <> '-CANX-'  ) .and. (status = 'C'  ) .and. (c1='M')"
    		end select
    		vCodeOpt = ""
    		vOrder = "Code+reg"
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,11) = "ClassEvent_" then
    	if a_dlg_button = "ClassEvent_selok" then
    		vFilter = "C1="-quote(vClass)+".and.rtrim(Reg)<>'-CANX-'"
    		vOrder = "C1+REG"
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,10) = "OperEvent_" then
    	if a_dlg_button = "OperEvent_selok" then
    		vFilter = "op_unique="-quote(vOperatorUniq)+".and.c1='c'"
    		vOrder = "op_unique+reg"
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,11) = "UsageEvent_" then
    	if a_dlg_button = "UsageEvent_selok" then
    		vFilter = "c2='"-vUsage-"'"
    		vOrder = "c2+reg"
    	end if
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,10) = "ProdEvent_" then
    	if a_dlg_button = "ProdEvent_selok" then
    		if vPrCountryOpt = "all" then
    			vFilter = "Type_code="-quote(rtrim(vProdTypeCode))
    		else
    			vFilter = "Type_code="-quote(rtrim(vProdTypeCode))+".and.Country="-quote(rtrim(vPrCountry))
    		end if
    		select
    			case vPrOpt = "MSN"
    				vOrder = "SortMsn"
    			case 	vPrOpt = "Assembly No"
    				vOrder = "Assembly_No"
    			case vPrOpt = "Plane Set"
    				vOrder = "Plane_set"
    			case vPrOpt = "Variant No"
    				vOrder = "Variant_no"
    			case vPrOpt = "Line No"
    				vOrder = "LineNoSort"
    			case vPrOpt = "Centre Fuselage"
    				vOrder = "C_fuselage"
    			case vPrOpt = "Front Fuselage"
    				vOrder = "F_Fuselage"
    		end select
    		vOrder = vOrder+"+REG"
    		vPrCountry = ""
    		a_dlg_button = ""
    	end if
    end if
    if a_dlg_button = "Go" then
    	trace.writeln("vOption="-vOption)
    	trace.writeln("vOrder="-vOrder)
    	trace.writeln("vFilter="-vFilter)
    	if  rtrim(vOrder) = "" .or. rtrim(vFilter) = "" then
    		vSearchMsg = "Invalid Search"
    	else
    		dlCount = tablecount(vTable,vFilter)
    		vDisplayLookup.resize(vdlSize)
    		select
    			case dlCount > 0 .and. dlCount <= vdlsize
    				vdisplayLookup.initialize_from_table(vTable,vFilter,vOrder)
    				nCount = *count(vDisplayLookup.matching("as=''"))
    				vSearchMsg = nCount+" needed from "+dlCount
    				vDisplayLookup.resize(vDisplayLookup.first_empty()-1)
    				showArray = .t.
    			case dlcount > vDlsize 
    				vSearchMsg = "Search Too Large"
    				showarray = .f.
    			case else
    				vSearchMsg = "Search Value Not Found"
    				showArray = .f.
    		end select
    		
    	end if
    	vFilter = ""
    	vOrder= ""
    	vOption=""
    	
    a_dlg_button = ""
    end if
    
    if  a_dlg_button <> "Close" then
    	a_dlg_button = ""
    end if
    %code%)
    end
    error_routine:
    err_msg = error_text_get(error_code_get())
    script = error_script_get()
    line = error_line_number_get()
    ui_msg_box("Error",err_msg+" error occured at line "+alltrim(str(line,4,0))+" in Script "+alltrim(script))
    end
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,682

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    I copied your table to a new adb - does this script need a form to run? All I get is a dialog with the radio buttons and 'invalid search' when GO is clicked.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  10. #10
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    785

    Default Re: Is it Possible to display results of xdialog query in same xdialog?

    This is example code, you wont be able to just run the script as it does possible lookups from seven of my tables to create the resulting array.
    Basically there are two Regions, Region1 sets parameters for the query and Region3 displays the result when "Go" is clicked. (region2 was removed during development, I forgot to change region3 to region2). The important bit is the "Go" button, which is processed within the %code% section of the xdialog.
    clicking "GO" initializes the array and sets the show array button.
    It is far from perfect code, but I am still on a very steep learning curve with xdialog, but does show one solution.

    Code:
    if a_dlg_button = "Go" then
    		dlCount = tablecount(vTable,vFilter)
    		vDisplayLookup.resize("2000")
    		if dlCount > 0 then
    			vdisplayLookup.initialize_from_table(vTable,vFilter,vOrder)
    			nCount = *count(vDisplayLookup.matching("as=''"))
    			vSearchMsg = FmtSearchMsg+nCount+" needed"
    			vDisplayLookup.resize(vDisplayLookup.first_empty()-1)
    			showArray = .t.
    		else
    			vSearchMsg = FmtSearchMsg+"Search Value Not Found"
    			showArray = .f.
    		end if
    	end if
    	a_dlg_button = ""
    end if
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

Similar Threads

  1. Execute Crosstab Query in Xbasic - How Do I Display Results?
    By kingcarol in forum Application Server Version 11 - Web/Browser Applications
    Replies: 14
    Last Post: 03-02-2012, 09:25 AM
  2. Unexpected list processing results in Xdialog
    By Bill Murray in forum Alpha Five Version 10 - Desktop Applications
    Replies: 5
    Last Post: 02-08-2010, 03:26 PM
  3. Xdialog variable results question
    By grayfox5 in forum Alpha Five Version 9 - Desktop Applications
    Replies: 1
    Last Post: 11-18-2009, 05:56 PM
  4. How to display query results in a browse on form?
    By brett s in forum Alpha Five Version 7
    Replies: 0
    Last Post: 11-24-2006, 10:15 PM
  5. Xdialog results to a variable
    By crimmelcp in forum Alpha Five Version 5
    Replies: 1
    Last Post: 05-22-2004, 08:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •