[solved]how to search for via routes when there are no direc

Get help with using AutoHotkey and its commands and hotkeys
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

[solved]how to search for via routes when there are no direc

07 Apr 2015, 20:09

How to make it work when there is no direct route, like from Mangalore (to Mumbai) to Vishakapatnam.

The required end result for simple direct routes is shown, eg put in from Agartala and Guwahati in to.Can i get the same kind of results if there is no direct route as shown in the first line above?
Yet bigger problem sometimes there is more than one via station. how to get that too.like to reach from A to B we have to go like A to c to D to B ( line separated, all routes shown and the lowest of HLTC+Airfuel out of those at the top )

Thanks a Ton in advance.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
var =
(
1	Agartala	Guwahati	4831	10140	1850
2	Agartala	Kolkata	3891	8506	1850
3	Agartala	Silchar	4401		1850
4	Agatti	Bengaluru	10691		1850
5	Agatti	Chennai	10646		2150
6	Agatti	Kochi	8571		1850
7	Agatti	Kozhikode	7471		1850
8	Agra	Delhi	5681	15327	1850
9	Agra	Khajuraho	3891	8506	1850
10	Agra	Varanasi	4946	12951	1850
11	Agra	Mumbai	8571		2950
12	Ahmedabad	Chennai	7426	26186	2950
13	Ahmedabad	Delhi	6000	15502	2150
14	Ahmedabad	Hyderabad	7076	19532	2150
15	Ahmedabad	Mumbai	4351	13425	1850
16	Aizawl	Guwahati	5351		1850
17	Aizawl	Imphal	4466	7337	1850
18	Aizawl	Kolkata	4626	11108	1850
19	Allahabad	Delhi	6541		1850
20	Allahabad	Kanpur	4751		1850
21	Allahabad	Mumbai	9401		2950
22	Amritsar	Delhi	4366	12436	1850
23	Aurangabad	Delhi	8801	21747	2150
24	Aurangabad	Mumbai	4451	10133	1850
25	Bagdogra	Delhi	9716	21024	2950
26	Bagdogra	Guwahati	4536	8398	1850
27	Bagdogra	Kolkata	5436	13188	1850
28	Bengaluru	Chennai	4701	10691	1850
29	Bengaluru	Delhi	9901	28985	3650
30	Bengaluru	Goa	5151	13297	1850
31	Bengaluru	Hyderabad	5451	14823	1850
32	Bengaluru	Kochi	4501	10907	1850
33	Bengaluru	Kolkata	9701	30799	3650
34	Bengaluru	Mangalore	4936		1850
35	Bengaluru	Mumbai	6851	16356	2150
36	Bengaluru	Pune	6184	16506	1850
37	Bengaluru	Tirupati	5221		1850
38	Bengaluru	Trivandrum	5451	12473	1850
39	Bhopal	Delhi	4801	14856	1850
40	Bhopal	Indore	4281	8625	1850
41	Bhopal	Mumbai	5356	15560	1850
42	Bhubaneshwar	Chennai	8291	17520	2950
43	Bhubaneshwar	Delhi	9001	27424	2950
44	Bhubaneshwar	Kolkata	5406	11764	1850
45	Bhubaneshwar	Mumbai	9401	29518	2950
46	Bhubaneshwar	Port Blair	11216		2950
47	Bhuj	Mumbai	6541		1850
48	Chandigarh	Delhi	4301	10534	1850
49	Chandigarh	Mumbai	8836	26295	2950
50	Chennai	Coimbatore	4251	12166	1850
51	Chennai	Delhi	8456	28474	3650
52	Chennai	Goa	6311	16217	1850
53	Chennai	Hyderabad	4451	13732	1850
54	Chennai	Kochi	5251	14630	1850
55	Chennai	Kolkata	8566	27543	2950
56	Chennai	Madurai	4251	11801	1850
57	Chennai	Mumbai	8571	18623	2950
58	Chennai	Pune	7851	21017	2150
59	Chennai	Portblair	9411	24229	2950
60	Chennai	Trivandrum	5601	14637	1850
61	Chennai	Vishakhapatnam	4801	14673	1850
62	Coimbatore	Delhi	9751	32763	3650
63	Coimbatore	Kozhikode	4451	6739	1850
64	Coimbatore	Mumbai	8001	18331	2950
65	Dehradun	Delhi	5221	13980	1850
66	Dehli	Dharamsala	4821		1850
67	Delhi	Gaya	6851	19532	2150
68	Delhi	Goa	8821	25860	3650
69	Delhi	Guwahati	9811	24988	3650
70	Delhi	Gwalior	5051	9977	1850
71	Delhi	Hyderabad	8401	25748	2950
72	Delhi	Imphal	9081	27248	3650
73	Delhi	Indore	4851	15867	1850
74	Delhi	Jabalpur	6401		1850
75	Delhi	Jaipur	3551	8815	1850
76	Delhi	Jammu	4401	13181	1850
77	Delhi	Jodhpur	5706	14290	1850
78	Delhi	Kanpur	5701		1850
79	Delhi	Khajuraho	5651	15108	1850
80	Delhi	Kochi	12351	37731	3650
81	Delhi	Kolkata	9061	24251	2950
82	Delhi	Kozhikode	10051	32763	3650
83	Delhi	Kullu	6301		1850
84	Delhi	Leh	5501	15141	1850
85	Delhi	Lucknow	4821	12505	1850
86	Delhi	Ludhiana	4351		1850
87	Delhi	Mangalore	9901	29248	3650
88	Delhi	Mumbai	8951	22740	2950
89	Delhi	Pantnagar	4301		1850
90	Delhi	Nagpur	7171	17336	2150
91	Delhi	Pathankot	5101		1850
92	Delhi	Patna	7151	17265	2150
93	Delhi	Port Blair	21516		3650
94	Delhi	Pune	9401	28208	2950
95	Delhi	Raipur	7851	22112	2150
96	Delhi	Rajkot	9101		2150
97	Delhi	Ranchi	8811	20732	2950
98	Delhi	Srinagar	6201	13370	1850
99	Delhi	Surat	9101	20819	2150
100	Delhi	Tirupati	9016	23756	3650
101	Delhi	Trivandrum	12156	37731	3650
102	Delhi	Udaipur	5786	15382	1850
103	Delhi	Vadodra	7051	19853	2150
104	Delhi	Varanasi	5681	15327	1850
105	Delhi	Vijayawada	8566	26202	2950
106	Delhi	Vishakhapatnam	10401	30218	2950
107	Dibrugarh	Dimapur	3251	5106	1850
108	Dibrugarh	Guwahati	4801		1850
109	Dibrugarh	Kolkata	7401	14776	2150
110	Dibrugarh	Lilabari	4051		1850
111	Dimapur	Guwahati	4701		1850
112	Dimapur	Imphal	4401		1850
113	Dimapur	Kolkata	6101	13822	1850
114	Dimapur	Shillong	4101		1850
115	Gaya	Kolkata	4501	11744	1850
116	Gaya	Varanasi	4851	9518	1850
117	Goa	Kochi	5001	15159	1850
118	Goa	Hyderabad	5251	13657	1850
119	Goa	Mumbai	5321	11232	1850
120	Goa	Pune	4536	8874	1850
121	Goa	Srinagar	12351	38431	3650
122	Guwahati	Imphal	4901	9498	1850
123	Guwahati	Jorhat	3736		1850
124	Guwahati	Kolkata	5076	11465	1850
125	Guwahati	Lilabari	5151		1850
126	Guwahati	Silchar	5251		1850
127	Guwahati	Tezpur	4436		1850
128	Gwalior	Mumbai	8401	19551	2150
129	Hyderabad	Kolkata	9696	24985	2950
130	Hyderabad	Mumbai	5251	14980	1850
131	Hyderabad	Pune	5231	14265	1850
132	Hyderabad	Tirupati	4656	12571	1850
133	Hyderabad	Varanasi	8811	21806	2950
134	Hyderabad	Vijayawada	5051	10655	1850
135	Hyderabad	Vishakhapatnam	4946	12951	1850
136	Imphal	Kolkata	4281	11680	1850
137	Imphal	Silchar	4601		1850
138	Indore	Mumbai	4481	12637	1850
139	Jaipur	Mumbai	7851	18794	2150
140	Jammu	Leh	4886	9069	1850
141	Jammu	Srinagar	4403	6998	1850
142	Jamnagar	Mumbai	5181	12400	1850
143	Jodhpur	Mumbai	7686	18670	2150
144	Jodhpur	Udaipur	4231	8724	1850
145	Jorhat	Kolkata	4976		1850
146	Jorhat	Tezpur	4136		1850
147	Kanpur	Kolkata	7401		2150
148	Khajuraho	Varanasi	4936	12681	1850
149	Kochi	Kozhikode	3501	7283	1850
150	Kochi	Madurai	4301		1850
151	Kochi	Mumbai	8401	21634	2950
152	Kochi	Trivandrum	4301	8326	1850
153	Kolkata	Kochi	10051		3650
154	Kolkata	Lilabari	7800		2150
155	Kolkata	Mumbai	8486	23558	3650
156	Kolkata	Patna	5706		1850
157	Kolkata	Port Blair	11071	26781	2950
158	Kolkata	Ranchi	4536		1850
159	Kolkata	Shillong	5481		1850
160	Kolkata	Silchar	5001	11085	1850
161	Kolkata	Tezpur	5151		1850
162	Kozhikode	Chennai	5151		1850
163	Kozhikode	Kolkata	8456		3650
164	Kozhikode	Mumbai	9100	16513	2150
165	Kozhikode	Trivandrum	4391		1850
166	Kullu	Pathankot	4001		1850
167	Leh	Srinagar	4603	8283	1850
168	Lilabari	Tezpur	3881		1850
169	Lucknow	Mumbai	8051	24985	2950
170	Lucknow	Varanasi	4626	9607	1850
171	Ludhiana	Pathankot	4201		1850
172	Madurai	Mumbai	7851	23657	2950
173	Mangalore	Mumbai	6086	15761	1850
174	Mumbai	Nagpur	5001	15159	1850
175	Mumbai	Raipur	9500	20692	2150
176	Mumbai	Rajkot	5281	12473	1850
177	Mumbai	Ranchi	9751	22813	2950
178	Mumbai	Srinagar	9016	23756	3650
179	Mumbai	Trivandrum	10201	23901	2950
180	Mumbai	Udaipur	4786	15407	1850
181	Mumbai	Varanasi	9696	24511	2950
182	Mumbai	Vishakhapatnam	9101	24872	2950
183	Patna	Ranchi	4603		1850
184	PortBlair	Vishakhapatnam	9696	24511	2950
185	Raipur	Bhubaneshwar	4281	9977	1850
186	Raipur	Nagpur	5181	12660	1850
187	Raipur	Vishakhapatnam	4251	11606	1850
188	Shillong	Jorhat	4551		1850
189	Silchar	Tezpur	4101		1850
190	Tirupati	Vijayawada	5406		1850
191	Vishakhapatnam	Bhubaneshwar	5321	10518	1850
)

complete_Array := strsplit(var, ["`n", "`t"])

loop, % complete_Array.MaxIndex()
{
	if ( complete_Array[A_index] = "" ) ; to store 0 where in DLTC  fare is not shown
		complete_Array[A_index] := 0
}


	



array_from_places_list := {}
array_to_places_list := {}

array := strsplit(var, ["`n"])

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 2 )
		from_places .= array_[A_index] . "`n"
}
sort from_places
loop, parse, from_places, "`n"
{
if ( array_from_places_list[A_loopfield] = "" )
{
	array_from_places_list[A_loopfield] := A_loopfield
	list_of_from_places .= A_loopfield . "|"
}
}

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 3 )
		to_places .= array_[A_index] . "`n"
}
sort to_places
loop, parse, to_places, "`n"
{
if ( array_to_places_list[A_loopfield] = "" )
{
	array_to_places_list[A_loopfield] := A_loopfield
	list_of_to_places .= A_loopfield . "|"
}
}



Gui, Add, Text,, From:
Gui, Add, ComboBox, vFrom ym gButtonOK, %list_of_from_places%  ; The ym option starts a new column of controls.

Gui, Add, Text, ym, To:
Gui, Add, ComboBox, vto ym gButtonOK, %list_of_to_places% 

Gui, Add, Text, gButtonOK xm vResult w1000  ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Simple Input Example
return  ; End of auto-execute section. The script is idle until the user does something.

GuiClose:
ButtonOK:
Gui, Submit, nohide  ; Save the input from the user to each control's associated variable.
loop, % complete_Array.MaxIndex()
{
if ( complete_Array[A_index] = from ) && ( complete_Array[A_index+1] = to )
{
	;~ MsgBox % complete_Array[A_index] . " " . complete_Array[A_index+1] . " " . complete_Array[A_index+2] . " " . complete_Array[A_index+4] . " " . complete_Array[A_index+5]
	test := "From: " . complete_Array[A_index] . "	To: " . complete_Array[A_index+1] . "	HLTC (Economy Class): " . complete_Array[A_index+2] . "	DLTC (Executive Class): " . complete_Array[A_index+3] . "	Airline Fuel Charge:" . complete_Array[A_index+4] . "		HLTC (Economy Class)+Airline Fuel Charge: " . complete_Array[A_index+2] + complete_Array[A_index+4]
GuiControl,, Result, % test
return	
}


if ( A_index = complete_Array.MaxIndex() )
{
	from_list := to_list := ""
	loop, % complete_Array.MaxIndex()
	{
		if ( complete_Array[( (A_index-1) * 6 + 2)] = from )
		{
			f_f := A_index
			;~ 2_from_place := complete_Array[( (f_f-1) * 6 + 2)]
			from_list .= complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "`n" 
		}
	}
	;~ MsgBox % from_list
		loop, % complete_Array.MaxIndex()
	{
		if ( complete_Array[( (A_index-1) * 6 + 3)] = to )
		{
			t_t := A_index
			;~ 2_from_place := complete_Array[( (t_t-1) * 6 + 2)]
			to_list .= complete_Array[( (t_t-1) * 6 + 2)] . " " . complete_Array[( (t_t-1) * 6 + 2+1)] . " " . complete_Array[( (t_t-1) * 6 + 2+2)] . " " . complete_Array[( (t_t-1) * 6 + 2+3)] . " " . complete_Array[( (t_t-1) * 6 + 2+4)] . "`n" 
		}
	}
	TrayTip, Result, % from_list . "`n`n" . to_list, 20, 17


	
}


}




GuiControl,, Result, result

return

esc::ExitApp

Last edited by smorgasbord on 19 Apr 2015, 00:50, edited 2 times in total.
John ... you working ?
User avatar
boiler
Posts: 2372
Joined: 21 Dec 2014, 02:44

Re: how to search for via routes when there are no direct ro

07 Apr 2015, 21:45

You have brackets around the optional parameters in your function calls. From the documentation:
Throughout the documentation, you will see these two symbols ([ and ]) surrounding code in the yellow syntax box at the top of almost all pages. Anything inside of these brackets are OPTIONAL. Meaning the stuff inside can be left out if you don't need them. When writing your code, it is very important to NOT type the []'s in your code.
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

07 Apr 2015, 22:43

@boiler, please tell the line no.s thanks.
BTW i reached to work with level 2 so far

till level 4 is required

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
var =
(
1	Agartala	Guwahati	4831	10140	1850
2	Agartala	Kolkata	3891	8506	1850
3	Agartala	Silchar	4401		1850
4	Agatti	Bengaluru	10691		1850
5	Agatti	Chennai	10646		2150
6	Agatti	Kochi	8571		1850
7	Agatti	Kozhikode	7471		1850
8	Agra	Delhi	5681	15327	1850
9	Agra	Khajuraho	3891	8506	1850
10	Agra	Varanasi	4946	12951	1850
11	Agra	Mumbai	8571		2950
12	Ahmedabad	Chennai	7426	26186	2950
13	Ahmedabad	Delhi	6000	15502	2150
14	Ahmedabad	Hyderabad	7076	19532	2150
15	Ahmedabad	Mumbai	4351	13425	1850
16	Aizawl	Guwahati	5351		1850
17	Aizawl	Imphal	4466	7337	1850
18	Aizawl	Kolkata	4626	11108	1850
19	Allahabad	Delhi	6541		1850
20	Allahabad	Kanpur	4751		1850
21	Allahabad	Mumbai	9401		2950
22	Amritsar	Delhi	4366	12436	1850
23	Aurangabad	Delhi	8801	21747	2150
24	Aurangabad	Mumbai	4451	10133	1850
25	Bagdogra	Delhi	9716	21024	2950
26	Bagdogra	Guwahati	4536	8398	1850
27	Bagdogra	Kolkata	5436	13188	1850
28	Bengaluru	Chennai	4701	10691	1850
29	Bengaluru	Delhi	9901	28985	3650
30	Bengaluru	Goa	5151	13297	1850
31	Bengaluru	Hyderabad	5451	14823	1850
32	Bengaluru	Kochi	4501	10907	1850
33	Bengaluru	Kolkata	9701	30799	3650
34	Bengaluru	Mangalore	4936		1850
35	Bengaluru	Mumbai	6851	16356	2150
36	Bengaluru	Pune	6184	16506	1850
37	Bengaluru	Tirupati	5221		1850
38	Bengaluru	Trivandrum	5451	12473	1850
39	Bhopal	Delhi	4801	14856	1850
40	Bhopal	Indore	4281	8625	1850
41	Bhopal	Mumbai	5356	15560	1850
42	Bhubaneshwar	Chennai	8291	17520	2950
43	Bhubaneshwar	Delhi	9001	27424	2950
44	Bhubaneshwar	Kolkata	5406	11764	1850
45	Bhubaneshwar	Mumbai	9401	29518	2950
46	Bhubaneshwar	Port Blair	11216		2950
47	Bhuj	Mumbai	6541		1850
48	Chandigarh	Delhi	4301	10534	1850
49	Chandigarh	Mumbai	8836	26295	2950
50	Chennai	Coimbatore	4251	12166	1850
51	Chennai	Delhi	8456	28474	3650
52	Chennai	Goa	6311	16217	1850
53	Chennai	Hyderabad	4451	13732	1850
54	Chennai	Kochi	5251	14630	1850
55	Chennai	Kolkata	8566	27543	2950
56	Chennai	Madurai	4251	11801	1850
57	Chennai	Mumbai	8571	18623	2950
58	Chennai	Pune	7851	21017	2150
59	Chennai	Portblair	9411	24229	2950
60	Chennai	Trivandrum	5601	14637	1850
61	Chennai	Vishakhapatnam	4801	14673	1850
62	Coimbatore	Delhi	9751	32763	3650
63	Coimbatore	Kozhikode	4451	6739	1850
64	Coimbatore	Mumbai	8001	18331	2950
65	Dehradun	Delhi	5221	13980	1850
66	Dehli	Dharamsala	4821		1850
67	Delhi	Gaya	6851	19532	2150
68	Delhi	Goa	8821	25860	3650
69	Delhi	Guwahati	9811	24988	3650
70	Delhi	Gwalior	5051	9977	1850
71	Delhi	Hyderabad	8401	25748	2950
72	Delhi	Imphal	9081	27248	3650
73	Delhi	Indore	4851	15867	1850
74	Delhi	Jabalpur	6401		1850
75	Delhi	Jaipur	3551	8815	1850
76	Delhi	Jammu	4401	13181	1850
77	Delhi	Jodhpur	5706	14290	1850
78	Delhi	Kanpur	5701		1850
79	Delhi	Khajuraho	5651	15108	1850
80	Delhi	Kochi	12351	37731	3650
81	Delhi	Kolkata	9061	24251	2950
82	Delhi	Kozhikode	10051	32763	3650
83	Delhi	Kullu	6301		1850
84	Delhi	Leh	5501	15141	1850
85	Delhi	Lucknow	4821	12505	1850
86	Delhi	Ludhiana	4351		1850
87	Delhi	Mangalore	9901	29248	3650
88	Delhi	Mumbai	8951	22740	2950
89	Delhi	Pantnagar	4301		1850
90	Delhi	Nagpur	7171	17336	2150
91	Delhi	Pathankot	5101		1850
92	Delhi	Patna	7151	17265	2150
93	Delhi	Port Blair	21516		3650
94	Delhi	Pune	9401	28208	2950
95	Delhi	Raipur	7851	22112	2150
96	Delhi	Rajkot	9101		2150
97	Delhi	Ranchi	8811	20732	2950
98	Delhi	Srinagar	6201	13370	1850
99	Delhi	Surat	9101	20819	2150
100	Delhi	Tirupati	9016	23756	3650
101	Delhi	Trivandrum	12156	37731	3650
102	Delhi	Udaipur	5786	15382	1850
103	Delhi	Vadodra	7051	19853	2150
104	Delhi	Varanasi	5681	15327	1850
105	Delhi	Vijayawada	8566	26202	2950
106	Delhi	Vishakhapatnam	10401	30218	2950
107	Dibrugarh	Dimapur	3251	5106	1850
108	Dibrugarh	Guwahati	4801		1850
109	Dibrugarh	Kolkata	7401	14776	2150
110	Dibrugarh	Lilabari	4051		1850
111	Dimapur	Guwahati	4701		1850
112	Dimapur	Imphal	4401		1850
113	Dimapur	Kolkata	6101	13822	1850
114	Dimapur	Shillong	4101		1850
115	Gaya	Kolkata	4501	11744	1850
116	Gaya	Varanasi	4851	9518	1850
117	Goa	Kochi	5001	15159	1850
118	Goa	Hyderabad	5251	13657	1850
119	Goa	Mumbai	5321	11232	1850
120	Goa	Pune	4536	8874	1850
121	Goa	Srinagar	12351	38431	3650
122	Guwahati	Imphal	4901	9498	1850
123	Guwahati	Jorhat	3736		1850
124	Guwahati	Kolkata	5076	11465	1850
125	Guwahati	Lilabari	5151		1850
126	Guwahati	Silchar	5251		1850
127	Guwahati	Tezpur	4436		1850
128	Gwalior	Mumbai	8401	19551	2150
129	Hyderabad	Kolkata	9696	24985	2950
130	Hyderabad	Mumbai	5251	14980	1850
131	Hyderabad	Pune	5231	14265	1850
132	Hyderabad	Tirupati	4656	12571	1850
133	Hyderabad	Varanasi	8811	21806	2950
134	Hyderabad	Vijayawada	5051	10655	1850
135	Hyderabad	Vishakhapatnam	4946	12951	1850
136	Imphal	Kolkata	4281	11680	1850
137	Imphal	Silchar	4601		1850
138	Indore	Mumbai	4481	12637	1850
139	Jaipur	Mumbai	7851	18794	2150
140	Jammu	Leh	4886	9069	1850
141	Jammu	Srinagar	4403	6998	1850
142	Jamnagar	Mumbai	5181	12400	1850
143	Jodhpur	Mumbai	7686	18670	2150
144	Jodhpur	Udaipur	4231	8724	1850
145	Jorhat	Kolkata	4976		1850
146	Jorhat	Tezpur	4136		1850
147	Kanpur	Kolkata	7401		2150
148	Khajuraho	Varanasi	4936	12681	1850
149	Kochi	Kozhikode	3501	7283	1850
150	Kochi	Madurai	4301		1850
151	Kochi	Mumbai	8401	21634	2950
152	Kochi	Trivandrum	4301	8326	1850
153	Kolkata	Kochi	10051		3650
154	Kolkata	Lilabari	7800		2150
155	Kolkata	Mumbai	8486	23558	3650
156	Kolkata	Patna	5706		1850
157	Kolkata	Port Blair	11071	26781	2950
158	Kolkata	Ranchi	4536		1850
159	Kolkata	Shillong	5481		1850
160	Kolkata	Silchar	5001	11085	1850
161	Kolkata	Tezpur	5151		1850
162	Kozhikode	Chennai	5151		1850
163	Kozhikode	Kolkata	8456		3650
164	Kozhikode	Mumbai	9100	16513	2150
165	Kozhikode	Trivandrum	4391		1850
166	Kullu	Pathankot	4001		1850
167	Leh	Srinagar	4603	8283	1850
168	Lilabari	Tezpur	3881		1850
169	Lucknow	Mumbai	8051	24985	2950
170	Lucknow	Varanasi	4626	9607	1850
171	Ludhiana	Pathankot	4201		1850
172	Madurai	Mumbai	7851	23657	2950
173	Mangalore	Mumbai	6086	15761	1850
174	Mumbai	Nagpur	5001	15159	1850
175	Mumbai	Raipur	9500	20692	2150
176	Mumbai	Rajkot	5281	12473	1850
177	Mumbai	Ranchi	9751	22813	2950
178	Mumbai	Srinagar	9016	23756	3650
179	Mumbai	Trivandrum	10201	23901	2950
180	Mumbai	Udaipur	4786	15407	1850
181	Mumbai	Varanasi	9696	24511	2950
182	Mumbai	Vishakhapatnam	9101	24872	2950
183	Patna	Ranchi	4603		1850
184	PortBlair	Vishakhapatnam	9696	24511	2950
185	Raipur	Bhubaneshwar	4281	9977	1850
186	Raipur	Nagpur	5181	12660	1850
187	Raipur	Vishakhapatnam	4251	11606	1850
188	Shillong	Jorhat	4551		1850
189	Silchar	Tezpur	4101		1850
190	Tirupati	Vijayawada	5406		1850
191	Vishakhapatnam	Bhubaneshwar	5321	10518	1850
)

complete_Array := strsplit(var, ["`n", "`t"])

loop, % complete_Array.MaxIndex()
{
	if ( complete_Array[A_index] = "" ) ; to store 0 where in DLTC  fare is not shown
		complete_Array[A_index] := 0
}


	



array_from_places_list := {}
array_to_places_list := {}

array := strsplit(var, ["`n"])

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 2 )
		from_places .= array_[A_index] . "`n"
}
sort from_places
loop, parse, from_places, "`n"
{
if ( array_from_places_list[A_loopfield] = "" )
{
	array_from_places_list[A_loopfield] := A_loopfield
	list_of_from_places .= A_loopfield . "|"
}
}

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 3 )
		to_places .= array_[A_index] . "`n"
}
sort to_places
loop, parse, to_places, "`n"
{
if ( array_to_places_list[A_loopfield] = "" )
{
	array_to_places_list[A_loopfield] := A_loopfield
	list_of_to_places .= A_loopfield . "|"
}
}



Gui, Add, Text,, From:
Gui, Add, ComboBox, vFrom ym gButtonOK, %list_of_from_places%  ; The ym option starts a new column of controls.

Gui, Add, Text, ym, To:
Gui, Add, ComboBox, vto ym gButtonOK, %list_of_to_places% 

Gui, Add, Text, gButtonOK xm vResult w1000 h200  ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Simple Input Example
return  ; End of auto-execute section. The script is idle until the user does something.

GuiClose:
ButtonOK:
Gui, Submit, nohide  ; Save the input from the user to each control's associated variable.
loop, % complete_Array.MaxIndex()
{
if ( complete_Array[A_index] = from ) && ( complete_Array[A_index+1] = to )
{
	;~ MsgBox % complete_Array[A_index] . " " . complete_Array[A_index+1] . " " . complete_Array[A_index+2] . " " . complete_Array[A_index+4] . " " . complete_Array[A_index+5]
	test := "From: " . complete_Array[A_index] . "	To: " . complete_Array[A_index+1] . "	HLTC (Economy Class): " . complete_Array[A_index+2] . "	DLTC (Executive Class): " . complete_Array[A_index+3] . "	Airline Fuel Charge:" . complete_Array[A_index+4] . "		HLTC (Economy Class)+Airline Fuel Charge: " . complete_Array[A_index+2] + complete_Array[A_index+4]
GuiControl,, Result, % test
return	
}


if ( A_index = complete_Array.MaxIndex() )
{
;==========LEVEL 2=============================================================================================================
	from_list := to_list := Result := ""
	
	loop, % complete_Array.MaxIndex()
	{
	;~ result := ""
		if ( complete_Array[( (A_index-1) * 6 + 2)] = from )
		{
			f_f := A_index
			;~ 2_from_place := complete_Array[( (f_f-1) * 6 + 2)]
			;~ from_list .= complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "`n" 
			new_from := complete_Array[( (f_f-1) * 6 + 2+1)]
			
				loop, % complete_Array.MaxIndex()
	{
		if ( complete_Array[( (A_index-1) * 6 + 2)] = new_from ) && ( complete_Array[( (A_index-1) * 6 + 3)] = to )
		{
			t_t := A_index
			;~ 2_from_place := complete_Array[( (t_t-1) * 6 + 2)]
			from_list := complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "`n" 
			to_list := complete_Array[( (t_t-1) * 6 + 2)] . " " . complete_Array[( (t_t-1) * 6 + 2+1)] . " " . complete_Array[( (t_t-1) * 6 + 2+2)] . " " . complete_Array[( (t_t-1) * 6 + 2+3)] . " " . complete_Array[( (t_t-1) * 6 + 2+4)] . "`n" 
			;~ if ( A_index = complete_Array.MaxIndex() )
			MsgBox % Result .= from_list . to_list . "`n"
		}

	}
	}
	;~ GuiControl,, Result, % result
	;~ break
	}
	GuiControl,, Result, % result
	}
;=================LEVEL 2==================================================================================================================

}




GuiControl,, Result, result

return

esc::ExitApp

John ... you working ?
Guest

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 03:13

An improved level 2, similarly there has to be level 3 and level 4

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
var =
(
1	Agartala	Guwahati	4831	10140	1850
2	Agartala	Kolkata	3891	8506	1850
3	Agartala	Silchar	4401		1850
4	Agatti	Bengaluru	10691		1850
5	Agatti	Chennai	10646		2150
6	Agatti	Kochi	8571		1850
7	Agatti	Kozhikode	7471		1850
8	Agra	Delhi	5681	15327	1850
9	Agra	Khajuraho	3891	8506	1850
10	Agra	Varanasi	4946	12951	1850
11	Agra	Mumbai	8571		2950
12	Ahmedabad	Chennai	7426	26186	2950
13	Ahmedabad	Delhi	6000	15502	2150
14	Ahmedabad	Hyderabad	7076	19532	2150
15	Ahmedabad	Mumbai	4351	13425	1850
16	Aizawl	Guwahati	5351		1850
17	Aizawl	Imphal	4466	7337	1850
18	Aizawl	Kolkata	4626	11108	1850
19	Allahabad	Delhi	6541		1850
20	Allahabad	Kanpur	4751		1850
21	Allahabad	Mumbai	9401		2950
22	Amritsar	Delhi	4366	12436	1850
23	Aurangabad	Delhi	8801	21747	2150
24	Aurangabad	Mumbai	4451	10133	1850
25	Bagdogra	Delhi	9716	21024	2950
26	Bagdogra	Guwahati	4536	8398	1850
27	Bagdogra	Kolkata	5436	13188	1850
28	Bengaluru	Chennai	4701	10691	1850
29	Bengaluru	Delhi	9901	28985	3650
30	Bengaluru	Goa	5151	13297	1850
31	Bengaluru	Hyderabad	5451	14823	1850
32	Bengaluru	Kochi	4501	10907	1850
33	Bengaluru	Kolkata	9701	30799	3650
34	Bengaluru	Mangalore	4936		1850
35	Bengaluru	Mumbai	6851	16356	2150
36	Bengaluru	Pune	6184	16506	1850
37	Bengaluru	Tirupati	5221		1850
38	Bengaluru	Trivandrum	5451	12473	1850
39	Bhopal	Delhi	4801	14856	1850
40	Bhopal	Indore	4281	8625	1850
41	Bhopal	Mumbai	5356	15560	1850
42	Bhubaneshwar	Chennai	8291	17520	2950
43	Bhubaneshwar	Delhi	9001	27424	2950
44	Bhubaneshwar	Kolkata	5406	11764	1850
45	Bhubaneshwar	Mumbai	9401	29518	2950
46	Bhubaneshwar	Port Blair	11216		2950
47	Bhuj	Mumbai	6541		1850
48	Chandigarh	Delhi	4301	10534	1850
49	Chandigarh	Mumbai	8836	26295	2950
50	Chennai	Coimbatore	4251	12166	1850
51	Chennai	Delhi	8456	28474	3650
52	Chennai	Goa	6311	16217	1850
53	Chennai	Hyderabad	4451	13732	1850
54	Chennai	Kochi	5251	14630	1850
55	Chennai	Kolkata	8566	27543	2950
56	Chennai	Madurai	4251	11801	1850
57	Chennai	Mumbai	8571	18623	2950
58	Chennai	Pune	7851	21017	2150
59	Chennai	Portblair	9411	24229	2950
60	Chennai	Trivandrum	5601	14637	1850
61	Chennai	Vishakhapatnam	4801	14673	1850
62	Coimbatore	Delhi	9751	32763	3650
63	Coimbatore	Kozhikode	4451	6739	1850
64	Coimbatore	Mumbai	8001	18331	2950
65	Dehradun	Delhi	5221	13980	1850
66	Dehli	Dharamsala	4821		1850
67	Delhi	Gaya	6851	19532	2150
68	Delhi	Goa	8821	25860	3650
69	Delhi	Guwahati	9811	24988	3650
70	Delhi	Gwalior	5051	9977	1850
71	Delhi	Hyderabad	8401	25748	2950
72	Delhi	Imphal	9081	27248	3650
73	Delhi	Indore	4851	15867	1850
74	Delhi	Jabalpur	6401		1850
75	Delhi	Jaipur	3551	8815	1850
76	Delhi	Jammu	4401	13181	1850
77	Delhi	Jodhpur	5706	14290	1850
78	Delhi	Kanpur	5701		1850
79	Delhi	Khajuraho	5651	15108	1850
80	Delhi	Kochi	12351	37731	3650
81	Delhi	Kolkata	9061	24251	2950
82	Delhi	Kozhikode	10051	32763	3650
83	Delhi	Kullu	6301		1850
84	Delhi	Leh	5501	15141	1850
85	Delhi	Lucknow	4821	12505	1850
86	Delhi	Ludhiana	4351		1850
87	Delhi	Mangalore	9901	29248	3650
88	Delhi	Mumbai	8951	22740	2950
89	Delhi	Pantnagar	4301		1850
90	Delhi	Nagpur	7171	17336	2150
91	Delhi	Pathankot	5101		1850
92	Delhi	Patna	7151	17265	2150
93	Delhi	Port Blair	21516		3650
94	Delhi	Pune	9401	28208	2950
95	Delhi	Raipur	7851	22112	2150
96	Delhi	Rajkot	9101		2150
97	Delhi	Ranchi	8811	20732	2950
98	Delhi	Srinagar	6201	13370	1850
99	Delhi	Surat	9101	20819	2150
100	Delhi	Tirupati	9016	23756	3650
101	Delhi	Trivandrum	12156	37731	3650
102	Delhi	Udaipur	5786	15382	1850
103	Delhi	Vadodra	7051	19853	2150
104	Delhi	Varanasi	5681	15327	1850
105	Delhi	Vijayawada	8566	26202	2950
106	Delhi	Vishakhapatnam	10401	30218	2950
107	Dibrugarh	Dimapur	3251	5106	1850
108	Dibrugarh	Guwahati	4801		1850
109	Dibrugarh	Kolkata	7401	14776	2150
110	Dibrugarh	Lilabari	4051		1850
111	Dimapur	Guwahati	4701		1850
112	Dimapur	Imphal	4401		1850
113	Dimapur	Kolkata	6101	13822	1850
114	Dimapur	Shillong	4101		1850
115	Gaya	Kolkata	4501	11744	1850
116	Gaya	Varanasi	4851	9518	1850
117	Goa	Kochi	5001	15159	1850
118	Goa	Hyderabad	5251	13657	1850
119	Goa	Mumbai	5321	11232	1850
120	Goa	Pune	4536	8874	1850
121	Goa	Srinagar	12351	38431	3650
122	Guwahati	Imphal	4901	9498	1850
123	Guwahati	Jorhat	3736		1850
124	Guwahati	Kolkata	5076	11465	1850
125	Guwahati	Lilabari	5151		1850
126	Guwahati	Silchar	5251		1850
127	Guwahati	Tezpur	4436		1850
128	Gwalior	Mumbai	8401	19551	2150
129	Hyderabad	Kolkata	9696	24985	2950
130	Hyderabad	Mumbai	5251	14980	1850
131	Hyderabad	Pune	5231	14265	1850
132	Hyderabad	Tirupati	4656	12571	1850
133	Hyderabad	Varanasi	8811	21806	2950
134	Hyderabad	Vijayawada	5051	10655	1850
135	Hyderabad	Vishakhapatnam	4946	12951	1850
136	Imphal	Kolkata	4281	11680	1850
137	Imphal	Silchar	4601		1850
138	Indore	Mumbai	4481	12637	1850
139	Jaipur	Mumbai	7851	18794	2150
140	Jammu	Leh	4886	9069	1850
141	Jammu	Srinagar	4403	6998	1850
142	Jamnagar	Mumbai	5181	12400	1850
143	Jodhpur	Mumbai	7686	18670	2150
144	Jodhpur	Udaipur	4231	8724	1850
145	Jorhat	Kolkata	4976		1850
146	Jorhat	Tezpur	4136		1850
147	Kanpur	Kolkata	7401		2150
148	Khajuraho	Varanasi	4936	12681	1850
149	Kochi	Kozhikode	3501	7283	1850
150	Kochi	Madurai	4301		1850
151	Kochi	Mumbai	8401	21634	2950
152	Kochi	Trivandrum	4301	8326	1850
153	Kolkata	Kochi	10051		3650
154	Kolkata	Lilabari	7800		2150
155	Kolkata	Mumbai	8486	23558	3650
156	Kolkata	Patna	5706		1850
157	Kolkata	Port Blair	11071	26781	2950
158	Kolkata	Ranchi	4536		1850
159	Kolkata	Shillong	5481		1850
160	Kolkata	Silchar	5001	11085	1850
161	Kolkata	Tezpur	5151		1850
162	Kozhikode	Chennai	5151		1850
163	Kozhikode	Kolkata	8456		3650
164	Kozhikode	Mumbai	9100	16513	2150
165	Kozhikode	Trivandrum	4391		1850
166	Kullu	Pathankot	4001		1850
167	Leh	Srinagar	4603	8283	1850
168	Lilabari	Tezpur	3881		1850
169	Lucknow	Mumbai	8051	24985	2950
170	Lucknow	Varanasi	4626	9607	1850
171	Ludhiana	Pathankot	4201		1850
172	Madurai	Mumbai	7851	23657	2950
173	Mangalore	Mumbai	6086	15761	1850
174	Mumbai	Nagpur	5001	15159	1850
175	Mumbai	Raipur	9500	20692	2150
176	Mumbai	Rajkot	5281	12473	1850
177	Mumbai	Ranchi	9751	22813	2950
178	Mumbai	Srinagar	9016	23756	3650
179	Mumbai	Trivandrum	10201	23901	2950
180	Mumbai	Udaipur	4786	15407	1850
181	Mumbai	Varanasi	9696	24511	2950
182	Mumbai	Vishakhapatnam	9101	24872	2950
183	Patna	Ranchi	4603		1850
184	PortBlair	Vishakhapatnam	9696	24511	2950
185	Raipur	Bhubaneshwar	4281	9977	1850
186	Raipur	Nagpur	5181	12660	1850
187	Raipur	Vishakhapatnam	4251	11606	1850
188	Shillong	Jorhat	4551		1850
189	Silchar	Tezpur	4101		1850
190	Tirupati	Vijayawada	5406		1850
191	Vishakhapatnam	Bhubaneshwar	5321	10518	1850
)

complete_Array := strsplit(var, ["`n", "`t"])

loop, % complete_Array.MaxIndex()
{
	if ( complete_Array[A_index] = "" ) ; to store 0 where in DLTC  fare is not shown
		complete_Array[A_index] := 0
}


	



array_from_places_list := {}
array_to_places_list := {}

array := strsplit(var, ["`n"])

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 2 )
		from_places .= array_[A_index] . "`n"
}
sort from_places
loop, parse, from_places, "`n"
{
if ( array_from_places_list[A_loopfield] = "" )
{
	array_from_places_list[A_loopfield] := A_loopfield
	list_of_from_places .= A_loopfield . "|"
}
}

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 3 )
		to_places .= array_[A_index] . "`n"
}
sort to_places
loop, parse, to_places, "`n"
{
if ( array_to_places_list[A_loopfield] = "" )
{
	array_to_places_list[A_loopfield] := A_loopfield
	list_of_to_places .= A_loopfield . "|"
}
}



Gui, Add, Text,, From:
Gui, Add, ComboBox, vFrom ym gButtonOK, %list_of_from_places%  ; The ym option starts a new column of controls.

Gui, Add, Text, ym, To:
Gui, Add, ComboBox, vto ym gButtonOK, %list_of_to_places% 

Gui, Add, Text, gButtonOK xm vResult w1000 h200  ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Simple Input Example
return  ; End of auto-execute section. The script is idle until the user does something.

GuiClose:
ButtonOK:
Gui, Submit, nohide  ; Save the input from the user to each control's associated variable.
loop, % complete_Array.MaxIndex()
{
if ( complete_Array[A_index] = from ) && ( complete_Array[A_index+1] = to )
{
	;~ MsgBox % complete_Array[A_index] . " " . complete_Array[A_index+1] . " " . complete_Array[A_index+2] . " " . complete_Array[A_index+4] . " " . complete_Array[A_index+5]
	test := "From: " . complete_Array[A_index] . "	To: " . complete_Array[A_index+1] . "	HLTC (Economy Class): " . complete_Array[A_index+2] . "	DLTC (Executive Class): " . complete_Array[A_index+3] . "	Airline Fuel Charge:" . complete_Array[A_index+4] . "		HLTC (Economy Class)+Airline Fuel Charge: " . complete_Array[A_index+2] + complete_Array[A_index+4]
GuiControl,, Result, % test
return	
}


if ( A_index = complete_Array.MaxIndex() )
{
;==========LEVEL 2=============================================================================================================
	from_list := to_list := Result := ""
	
	loop, % complete_Array.MaxIndex()
	{
		if ( A_index = 1 )
			result := ""
		if ( complete_Array[( (A_index-1) * 6 + 2)] = from )
		{
			f_f := A_index
			;~ 2_from_place := complete_Array[( (f_f-1) * 6 + 2)]
			;~ from_list .= complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "`n" 
			new_from := complete_Array[( (f_f-1) * 6 + 2+1)]
			
				loop, % complete_Array.MaxIndex()
	{
		if ( complete_Array[( (A_index-1) * 6 + 2)] = new_from ) && ( complete_Array[( (A_index-1) * 6 + 3)] = to )
		{
			t_t := A_index
			;~ 2_from_place := complete_Array[( (t_t-1) * 6 + 2)]
			from_list := complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "	Total: " . complete_Array[( (f_f-1) * 6 + 2+2)]+complete_Array[( (f_f-1) * 6 + 2+4)] . "`n"
			to_list := complete_Array[( (t_t-1) * 6 + 2)] . " " . complete_Array[( (t_t-1) * 6 + 2+1)] . " " . complete_Array[( (t_t-1) * 6 + 2+2)] . " " . complete_Array[( (t_t-1) * 6 + 2+3)] . " " . complete_Array[( (t_t-1) * 6 + 2+4)] . "	Total: " . complete_Array[( (t_t-1) * 6 + 2+2)]+complete_Array[( (t_t-1) * 6 + 2+4)]+complete_Array[( (f_f-1) * 6 + 2+2)]+complete_Array[( (f_f-1) * 6 + 2+4)] . "`n"
			;~ if ( A_index = complete_Array.MaxIndex() )
			Result .= from_list . to_list . "`n"
		}

	}
	}
	;~ GuiControl,, Result, % result
	;~ break
	}
	GuiControl,, Result, % result
	;~ MsgBox
	return
	}
;=================LEVEL 2==================================================================================================================

}




GuiControl,, Result, result

return

esc::ExitApp

User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 04:07

@hd0202
not working :\
sorry if i am missing something.
Btw: the guest is also by me.

thanks for your time. :)
John ... you working ?
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 05:21

Here is my new suggestion, I deleted the previous as I found the problems by myself:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
var =
(
1	Agartala	Guwahati	4831	10140	1850
2	Agartala	Kolkata	3891	8506	1850
3	Agartala	Silchar	4401		1850
4	Agatti	Bengaluru	10691		1850
5	Agatti	Chennai	10646		2150
6	Agatti	Kochi	8571		1850
7	Agatti	Kozhikode	7471		1850
8	Agra	Delhi	5681	15327	1850
9	Agra	Khajuraho	3891	8506	1850
10	Agra	Varanasi	4946	12951	1850
11	Agra	Mumbai	8571		2950
12	Ahmedabad	Chennai	7426	26186	2950
13	Ahmedabad	Delhi	6000	15502	2150
14	Ahmedabad	Hyderabad	7076	19532	2150
15	Ahmedabad	Mumbai	4351	13425	1850
16	Aizawl	Guwahati	5351		1850
17	Aizawl	Imphal	4466	7337	1850
18	Aizawl	Kolkata	4626	11108	1850
19	Allahabad	Delhi	6541		1850
20	Allahabad	Kanpur	4751		1850
21	Allahabad	Mumbai	9401		2950
22	Amritsar	Delhi	4366	12436	1850
23	Aurangabad	Delhi	8801	21747	2150
24	Aurangabad	Mumbai	4451	10133	1850
25	Bagdogra	Delhi	9716	21024	2950
26	Bagdogra	Guwahati	4536	8398	1850
27	Bagdogra	Kolkata	5436	13188	1850
28	Bengaluru	Chennai	4701	10691	1850
29	Bengaluru	Delhi	9901	28985	3650
30	Bengaluru	Goa	5151	13297	1850
31	Bengaluru	Hyderabad	5451	14823	1850
32	Bengaluru	Kochi	4501	10907	1850
33	Bengaluru	Kolkata	9701	30799	3650
34	Bengaluru	Mangalore	4936		1850
35	Bengaluru	Mumbai	6851	16356	2150
36	Bengaluru	Pune	6184	16506	1850
37	Bengaluru	Tirupati	5221		1850
38	Bengaluru	Trivandrum	5451	12473	1850
39	Bhopal	Delhi	4801	14856	1850
40	Bhopal	Indore	4281	8625	1850
41	Bhopal	Mumbai	5356	15560	1850
42	Bhubaneshwar	Chennai	8291	17520	2950
43	Bhubaneshwar	Delhi	9001	27424	2950
44	Bhubaneshwar	Kolkata	5406	11764	1850
45	Bhubaneshwar	Mumbai	9401	29518	2950
46	Bhubaneshwar	Port Blair	11216		2950
47	Bhuj	Mumbai	6541		1850
48	Chandigarh	Delhi	4301	10534	1850
49	Chandigarh	Mumbai	8836	26295	2950
50	Chennai	Coimbatore	4251	12166	1850
51	Chennai	Delhi	8456	28474	3650
52	Chennai	Goa	6311	16217	1850
53	Chennai	Hyderabad	4451	13732	1850
54	Chennai	Kochi	5251	14630	1850
55	Chennai	Kolkata	8566	27543	2950
56	Chennai	Madurai	4251	11801	1850
57	Chennai	Mumbai	8571	18623	2950
58	Chennai	Pune	7851	21017	2150
59	Chennai	Portblair	9411	24229	2950
60	Chennai	Trivandrum	5601	14637	1850
61	Chennai	Vishakhapatnam	4801	14673	1850
62	Coimbatore	Delhi	9751	32763	3650
63	Coimbatore	Kozhikode	4451	6739	1850
64	Coimbatore	Mumbai	8001	18331	2950
65	Dehradun	Delhi	5221	13980	1850
66	Dehli	Dharamsala	4821		1850
67	Delhi	Gaya	6851	19532	2150
68	Delhi	Goa	8821	25860	3650
69	Delhi	Guwahati	9811	24988	3650
70	Delhi	Gwalior	5051	9977	1850
71	Delhi	Hyderabad	8401	25748	2950
72	Delhi	Imphal	9081	27248	3650
73	Delhi	Indore	4851	15867	1850
74	Delhi	Jabalpur	6401		1850
75	Delhi	Jaipur	3551	8815	1850
76	Delhi	Jammu	4401	13181	1850
77	Delhi	Jodhpur	5706	14290	1850
78	Delhi	Kanpur	5701		1850
79	Delhi	Khajuraho	5651	15108	1850
80	Delhi	Kochi	12351	37731	3650
81	Delhi	Kolkata	9061	24251	2950
82	Delhi	Kozhikode	10051	32763	3650
83	Delhi	Kullu	6301		1850
84	Delhi	Leh	5501	15141	1850
85	Delhi	Lucknow	4821	12505	1850
86	Delhi	Ludhiana	4351		1850
87	Delhi	Mangalore	9901	29248	3650
88	Delhi	Mumbai	8951	22740	2950
89	Delhi	Pantnagar	4301		1850
90	Delhi	Nagpur	7171	17336	2150
91	Delhi	Pathankot	5101		1850
92	Delhi	Patna	7151	17265	2150
93	Delhi	Port Blair	21516		3650
94	Delhi	Pune	9401	28208	2950
95	Delhi	Raipur	7851	22112	2150
96	Delhi	Rajkot	9101		2150
97	Delhi	Ranchi	8811	20732	2950
98	Delhi	Srinagar	6201	13370	1850
99	Delhi	Surat	9101	20819	2150
100	Delhi	Tirupati	9016	23756	3650
101	Delhi	Trivandrum	12156	37731	3650
102	Delhi	Udaipur	5786	15382	1850
103	Delhi	Vadodra	7051	19853	2150
104	Delhi	Varanasi	5681	15327	1850
105	Delhi	Vijayawada	8566	26202	2950
106	Delhi	Vishakhapatnam	10401	30218	2950
107	Dibrugarh	Dimapur	3251	5106	1850
108	Dibrugarh	Guwahati	4801		1850
109	Dibrugarh	Kolkata	7401	14776	2150
110	Dibrugarh	Lilabari	4051		1850
111	Dimapur	Guwahati	4701		1850
112	Dimapur	Imphal	4401		1850
113	Dimapur	Kolkata	6101	13822	1850
114	Dimapur	Shillong	4101		1850
115	Gaya	Kolkata	4501	11744	1850
116	Gaya	Varanasi	4851	9518	1850
117	Goa	Kochi	5001	15159	1850
118	Goa	Hyderabad	5251	13657	1850
119	Goa	Mumbai	5321	11232	1850
120	Goa	Pune	4536	8874	1850
121	Goa	Srinagar	12351	38431	3650
122	Guwahati	Imphal	4901	9498	1850
123	Guwahati	Jorhat	3736		1850
124	Guwahati	Kolkata	5076	11465	1850
125	Guwahati	Lilabari	5151		1850
126	Guwahati	Silchar	5251		1850
127	Guwahati	Tezpur	4436		1850
128	Gwalior	Mumbai	8401	19551	2150
129	Hyderabad	Kolkata	9696	24985	2950
130	Hyderabad	Mumbai	5251	14980	1850
131	Hyderabad	Pune	5231	14265	1850
132	Hyderabad	Tirupati	4656	12571	1850
133	Hyderabad	Varanasi	8811	21806	2950
134	Hyderabad	Vijayawada	5051	10655	1850
135	Hyderabad	Vishakhapatnam	4946	12951	1850
136	Imphal	Kolkata	4281	11680	1850
137	Imphal	Silchar	4601		1850
138	Indore	Mumbai	4481	12637	1850
139	Jaipur	Mumbai	7851	18794	2150
140	Jammu	Leh	4886	9069	1850
141	Jammu	Srinagar	4403	6998	1850
142	Jamnagar	Mumbai	5181	12400	1850
143	Jodhpur	Mumbai	7686	18670	2150
144	Jodhpur	Udaipur	4231	8724	1850
145	Jorhat	Kolkata	4976		1850
146	Jorhat	Tezpur	4136		1850
147	Kanpur	Kolkata	7401		2150
148	Khajuraho	Varanasi	4936	12681	1850
149	Kochi	Kozhikode	3501	7283	1850
150	Kochi	Madurai	4301		1850
151	Kochi	Mumbai	8401	21634	2950
152	Kochi	Trivandrum	4301	8326	1850
153	Kolkata	Kochi	10051		3650
154	Kolkata	Lilabari	7800		2150
155	Kolkata	Mumbai	8486	23558	3650
156	Kolkata	Patna	5706		1850
157	Kolkata	Port Blair	11071	26781	2950
158	Kolkata	Ranchi	4536		1850
159	Kolkata	Shillong	5481		1850
160	Kolkata	Silchar	5001	11085	1850
161	Kolkata	Tezpur	5151		1850
162	Kozhikode	Chennai	5151		1850
163	Kozhikode	Kolkata	8456		3650
164	Kozhikode	Mumbai	9100	16513	2150
165	Kozhikode	Trivandrum	4391		1850
166	Kullu	Pathankot	4001		1850
167	Leh	Srinagar	4603	8283	1850
168	Lilabari	Tezpur	3881		1850
169	Lucknow	Mumbai	8051	24985	2950
170	Lucknow	Varanasi	4626	9607	1850
171	Ludhiana	Pathankot	4201		1850
172	Madurai	Mumbai	7851	23657	2950
173	Mangalore	Mumbai	6086	15761	1850
174	Mumbai	Nagpur	5001	15159	1850
175	Mumbai	Raipur	9500	20692	2150
176	Mumbai	Rajkot	5281	12473	1850
177	Mumbai	Ranchi	9751	22813	2950
178	Mumbai	Srinagar	9016	23756	3650
179	Mumbai	Trivandrum	10201	23901	2950
180	Mumbai	Udaipur	4786	15407	1850
181	Mumbai	Varanasi	9696	24511	2950
182	Mumbai	Vishakhapatnam	9101	24872	2950
183	Patna	Ranchi	4603		1850
184	PortBlair	Vishakhapatnam	9696	24511	2950
185	Raipur	Bhubaneshwar	4281	9977	1850
186	Raipur	Nagpur	5181	12660	1850
187	Raipur	Vishakhapatnam	4251	11606	1850
188	Shillong	Jorhat	4551		1850
189	Silchar	Tezpur	4101		1850
190	Tirupati	Vijayawada	5406		1850
191	Vishakhapatnam	Bhubaneshwar	5321	10518	1850
)

array_from_places := {}
array := strsplit(var, "`n")

loop, % array.maxindex()
{
	lines := array[A_index]
	array_ := strsplit(lines, "`t")	
	array_from_places[array_[2], array_[3]] := [array_[4], array_[5] = "" ? 0 : array_[5], array_[6]]
	list_of_from_places .= array_[2] . "|"
	list_of_to_places .= array_[3] . "|"
} 
stringtrimright, list_of_from_places, list_of_from_places, 1
stringtrimright, list_of_to_places, list_of_to_places, 1
sort, list_of_from_places, D| U
sort, list_of_to_places, D| U

Gui, Add, Text,, From:
Gui, Add, ComboBox, vFrom ym gNew, %list_of_from_places%  ; The ym option starts a new column of controls.
Gui, Add, Text, ym, To:
Gui, Add, ComboBox, vto ym gNew, %list_of_to_places% 
Gui, Add, Button, gButtonOK vNew xm w80, % test
Gui, Add, Text, xm+30 vResult w1000 h300
Gui, Show,, Simple Input Example
return  ; End of auto-execute section. The script is idle until the user does something.

New:
test = start search
GuiControl,, New, % test
GuiControl,, Result, 
return

GuiClose:
ButtonOK:
Gui, Submit, nohide  ; Save the input from the user to each control's associated variable.
used =
found = 
result := {}
result := search(from, to)
test =
loop, % result.maxindex()
{
	key := result.maxindex() - a_index + 1
	value := result[key] 
	test .= "From: " . value[1] . "	To: " . value[2] . "	HLTC (Economy Class): " . value[3] . "	DLTC (Executive Class): " . value[4] . "	Airline Fuel Charge:" . value[5] . "		HLTC (Economy Class)+Airline Fuel Charge: " . value[3] + value[5] "`n"
}
if !test
	test = no connection found
GuiControl,, Result, % test
return	

search(from, to)
{
	global array_from_places, used, result, found
	if !from
		return
	used .= from ","
	if array_from_places[from].haskey(to)
	{
		htlc := array_from_places[from, to, 1]
		dtlc := array_from_places[from, to, 2]
		afc := array_from_places[from, to , 3]
		result.insert([from, to, htlc, dtlc, afc])
	}
	else
	{
		for key, value in array_from_places[from]
		{
			if !key
				return
			if key in %used%
				continue
			if (key = to)
			{
				htlc := array_from_places[from, key, 1]
				dtlc := array_from_places[from, key, 2]
				afc := array_from_places[from, key, 3]
				result.insert([from, key, htlc, dtlc, afc])
				found = 1
				break
			}
			search(key, to)
			if array_from_places[key].haskey(to) or found
			{
				htlc := array_from_places[from, key, 1]
				dtlc := array_from_places[from, key, 2]
				afc := array_from_places[from, key, 3]
				result.insert([from, key, htlc, dtlc, afc])
				found = 1
				break
			}
		}
	}
return result
}
Hubert
User avatar
boiler
Posts: 2372
Joined: 21 Dec 2014, 02:44

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:08

smorgasbord wrote:@boiler, please tell the line no.s thanks.
You have this:
complete_Array := strsplit(var, ["`n", "`t"])

You can't have the [ ] in it. So it should look like this:
complete_Array := strsplit(var, "`n", "`t")

...except I don't think you are really trying to use the third parameter which would say you want to omit the tab character. If you are trying to make a two-dimensional array, You can't do that from one StrSplit.
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:20

@hd0202
Attachments
hd.PNG
hd.PNG (2.41 KiB) Viewed 2238 times
John ... you working ?
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:24

@boiler: sorry, you are wrong. Please read the docu about StrSplit():
Delimiters

If this parameter is blank or omitted, each character of the input string will be treated as a separate substring.

Otherwise, Delimiters can be either a single string or an array of strings, each of which is used to determine where the boundaries between substrings occur.
Hubert
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:24

@boiler

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
var =
(
1	Agartala	Guwahati	4831	10140	1850
2	Agartala	Kolkata	3891	8506	1850
3	Agartala	Silchar	4401		1850
4	Agatti	Bengaluru	10691		1850
5	Agatti	Chennai	10646		2150
6	Agatti	Kochi	8571		1850
7	Agatti	Kozhikode	7471		1850
8	Agra	Delhi	5681	15327	1850
9	Agra	Khajuraho	3891	8506	1850
10	Agra	Varanasi	4946	12951	1850
11	Agra	Mumbai	8571		2950
12	Ahmedabad	Chennai	7426	26186	2950
13	Ahmedabad	Delhi	6000	15502	2150
14	Ahmedabad	Hyderabad	7076	19532	2150
15	Ahmedabad	Mumbai	4351	13425	1850
16	Aizawl	Guwahati	5351		1850
17	Aizawl	Imphal	4466	7337	1850
18	Aizawl	Kolkata	4626	11108	1850
19	Allahabad	Delhi	6541		1850
20	Allahabad	Kanpur	4751		1850
21	Allahabad	Mumbai	9401		2950
22	Amritsar	Delhi	4366	12436	1850
23	Aurangabad	Delhi	8801	21747	2150
24	Aurangabad	Mumbai	4451	10133	1850
25	Bagdogra	Delhi	9716	21024	2950
26	Bagdogra	Guwahati	4536	8398	1850
27	Bagdogra	Kolkata	5436	13188	1850
28	Bengaluru	Chennai	4701	10691	1850
29	Bengaluru	Delhi	9901	28985	3650
30	Bengaluru	Goa	5151	13297	1850
31	Bengaluru	Hyderabad	5451	14823	1850
32	Bengaluru	Kochi	4501	10907	1850
33	Bengaluru	Kolkata	9701	30799	3650
34	Bengaluru	Mangalore	4936		1850
35	Bengaluru	Mumbai	6851	16356	2150
36	Bengaluru	Pune	6184	16506	1850
37	Bengaluru	Tirupati	5221		1850
38	Bengaluru	Trivandrum	5451	12473	1850
39	Bhopal	Delhi	4801	14856	1850
40	Bhopal	Indore	4281	8625	1850
41	Bhopal	Mumbai	5356	15560	1850
42	Bhubaneshwar	Chennai	8291	17520	2950
43	Bhubaneshwar	Delhi	9001	27424	2950
44	Bhubaneshwar	Kolkata	5406	11764	1850
45	Bhubaneshwar	Mumbai	9401	29518	2950
46	Bhubaneshwar	Port Blair	11216		2950
47	Bhuj	Mumbai	6541		1850
48	Chandigarh	Delhi	4301	10534	1850
49	Chandigarh	Mumbai	8836	26295	2950
50	Chennai	Coimbatore	4251	12166	1850
51	Chennai	Delhi	8456	28474	3650
52	Chennai	Goa	6311	16217	1850
53	Chennai	Hyderabad	4451	13732	1850
54	Chennai	Kochi	5251	14630	1850
55	Chennai	Kolkata	8566	27543	2950
56	Chennai	Madurai	4251	11801	1850
57	Chennai	Mumbai	8571	18623	2950
58	Chennai	Pune	7851	21017	2150
59	Chennai	Portblair	9411	24229	2950
60	Chennai	Trivandrum	5601	14637	1850
61	Chennai	Vishakhapatnam	4801	14673	1850
62	Coimbatore	Delhi	9751	32763	3650
63	Coimbatore	Kozhikode	4451	6739	1850
64	Coimbatore	Mumbai	8001	18331	2950
65	Dehradun	Delhi	5221	13980	1850
66	Dehli	Dharamsala	4821		1850
67	Delhi	Gaya	6851	19532	2150
68	Delhi	Goa	8821	25860	3650
69	Delhi	Guwahati	9811	24988	3650
70	Delhi	Gwalior	5051	9977	1850
71	Delhi	Hyderabad	8401	25748	2950
72	Delhi	Imphal	9081	27248	3650
73	Delhi	Indore	4851	15867	1850
74	Delhi	Jabalpur	6401		1850
75	Delhi	Jaipur	3551	8815	1850
76	Delhi	Jammu	4401	13181	1850
77	Delhi	Jodhpur	5706	14290	1850
78	Delhi	Kanpur	5701		1850
79	Delhi	Khajuraho	5651	15108	1850
80	Delhi	Kochi	12351	37731	3650
81	Delhi	Kolkata	9061	24251	2950
82	Delhi	Kozhikode	10051	32763	3650
83	Delhi	Kullu	6301		1850
84	Delhi	Leh	5501	15141	1850
85	Delhi	Lucknow	4821	12505	1850
86	Delhi	Ludhiana	4351		1850
87	Delhi	Mangalore	9901	29248	3650
88	Delhi	Mumbai	8951	22740	2950
89	Delhi	Pantnagar	4301		1850
90	Delhi	Nagpur	7171	17336	2150
91	Delhi	Pathankot	5101		1850
92	Delhi	Patna	7151	17265	2150
93	Delhi	Port Blair	21516		3650
94	Delhi	Pune	9401	28208	2950
95	Delhi	Raipur	7851	22112	2150
96	Delhi	Rajkot	9101		2150
97	Delhi	Ranchi	8811	20732	2950
98	Delhi	Srinagar	6201	13370	1850
99	Delhi	Surat	9101	20819	2150
100	Delhi	Tirupati	9016	23756	3650
101	Delhi	Trivandrum	12156	37731	3650
102	Delhi	Udaipur	5786	15382	1850
103	Delhi	Vadodra	7051	19853	2150
104	Delhi	Varanasi	5681	15327	1850
105	Delhi	Vijayawada	8566	26202	2950
106	Delhi	Vishakhapatnam	10401	30218	2950
107	Dibrugarh	Dimapur	3251	5106	1850
108	Dibrugarh	Guwahati	4801		1850
109	Dibrugarh	Kolkata	7401	14776	2150
110	Dibrugarh	Lilabari	4051		1850
111	Dimapur	Guwahati	4701		1850
112	Dimapur	Imphal	4401		1850
113	Dimapur	Kolkata	6101	13822	1850
114	Dimapur	Shillong	4101		1850
115	Gaya	Kolkata	4501	11744	1850
116	Gaya	Varanasi	4851	9518	1850
117	Goa	Kochi	5001	15159	1850
118	Goa	Hyderabad	5251	13657	1850
119	Goa	Mumbai	5321	11232	1850
120	Goa	Pune	4536	8874	1850
121	Goa	Srinagar	12351	38431	3650
122	Guwahati	Imphal	4901	9498	1850
123	Guwahati	Jorhat	3736		1850
124	Guwahati	Kolkata	5076	11465	1850
125	Guwahati	Lilabari	5151		1850
126	Guwahati	Silchar	5251		1850
127	Guwahati	Tezpur	4436		1850
128	Gwalior	Mumbai	8401	19551	2150
129	Hyderabad	Kolkata	9696	24985	2950
130	Hyderabad	Mumbai	5251	14980	1850
131	Hyderabad	Pune	5231	14265	1850
132	Hyderabad	Tirupati	4656	12571	1850
133	Hyderabad	Varanasi	8811	21806	2950
134	Hyderabad	Vijayawada	5051	10655	1850
135	Hyderabad	Vishakhapatnam	4946	12951	1850
136	Imphal	Kolkata	4281	11680	1850
137	Imphal	Silchar	4601		1850
138	Indore	Mumbai	4481	12637	1850
139	Jaipur	Mumbai	7851	18794	2150
140	Jammu	Leh	4886	9069	1850
141	Jammu	Srinagar	4403	6998	1850
142	Jamnagar	Mumbai	5181	12400	1850
143	Jodhpur	Mumbai	7686	18670	2150
144	Jodhpur	Udaipur	4231	8724	1850
145	Jorhat	Kolkata	4976		1850
146	Jorhat	Tezpur	4136		1850
147	Kanpur	Kolkata	7401		2150
148	Khajuraho	Varanasi	4936	12681	1850
149	Kochi	Kozhikode	3501	7283	1850
150	Kochi	Madurai	4301		1850
151	Kochi	Mumbai	8401	21634	2950
152	Kochi	Trivandrum	4301	8326	1850
153	Kolkata	Kochi	10051		3650
154	Kolkata	Lilabari	7800		2150
155	Kolkata	Mumbai	8486	23558	3650
156	Kolkata	Patna	5706		1850
157	Kolkata	Port Blair	11071	26781	2950
158	Kolkata	Ranchi	4536		1850
159	Kolkata	Shillong	5481		1850
160	Kolkata	Silchar	5001	11085	1850
161	Kolkata	Tezpur	5151		1850
162	Kozhikode	Chennai	5151		1850
163	Kozhikode	Kolkata	8456		3650
164	Kozhikode	Mumbai	9100	16513	2150
165	Kozhikode	Trivandrum	4391		1850
166	Kullu	Pathankot	4001		1850
167	Leh	Srinagar	4603	8283	1850
168	Lilabari	Tezpur	3881		1850
169	Lucknow	Mumbai	8051	24985	2950
170	Lucknow	Varanasi	4626	9607	1850
171	Ludhiana	Pathankot	4201		1850
172	Madurai	Mumbai	7851	23657	2950
173	Mangalore	Mumbai	6086	15761	1850
174	Mumbai	Nagpur	5001	15159	1850
175	Mumbai	Raipur	9500	20692	2150
176	Mumbai	Rajkot	5281	12473	1850
177	Mumbai	Ranchi	9751	22813	2950
178	Mumbai	Srinagar	9016	23756	3650
179	Mumbai	Trivandrum	10201	23901	2950
180	Mumbai	Udaipur	4786	15407	1850
181	Mumbai	Varanasi	9696	24511	2950
182	Mumbai	Vishakhapatnam	9101	24872	2950
183	Patna	Ranchi	4603		1850
184	PortBlair	Vishakhapatnam	9696	24511	2950
185	Raipur	Bhubaneshwar	4281	9977	1850
186	Raipur	Nagpur	5181	12660	1850
187	Raipur	Vishakhapatnam	4251	11606	1850
188	Shillong	Jorhat	4551		1850
189	Silchar	Tezpur	4101		1850
190	Tirupati	Vijayawada	5406		1850
191	Vishakhapatnam	Bhubaneshwar	5321	10518	1850
)

complete_Array := strsplit(var, ["`n", "`t"])
MsgBox % complete_Array.MaxIndex()

complete_Array := strsplit(var, "`n", "`t")
MsgBox % complete_Array.MaxIndex()
John ... you working ?
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:40

@smorgasbord: sorry, this is one of my test cases, and here is the result as msgbox:
---------------------------
Script(2)_neu2.ahk
---------------------------
From: Agartala To: Guwahati HLTC (Economy Class): 4831 DLTC (Executive Class): 10140 Airline Fuel Charge:1850 HLTC (Economy Class)+Airline Fuel Charge: 6681

a_ahkversion: 1.1.21.00
a_osversion: WIN_8.1
a_is64bitos 1
---------------------------
OK
---------------------------
Hubert
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:48

@Hubert
Version v1.1.21.02
WIN_8
Attachments
hubert.PNG
hubert.PNG (1.24 KiB) Viewed 2217 times
John ... you working ?
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:53

@Hubert
Attachments
hubert.PNG
John ... you working ?
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 07:56

@smorgasbord: remove #warn

Hubert
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 08:04

@smorgasbord: or insert at the beginning:

Code: Select all

test := ""
list_of_from_places := ""
list_of_to_places := ""
and change the loop:

Code: Select all

loop, % result.maxindex()
{
	k := result.maxindex() - a_index + 1
	v := result[k] 
	test .= "From: " . v[1] . "	To: " . v[2] . "	HLTC (Economy Class): " . v[3] . "	DLTC (Executive Class): " . v[4] . "	Airline Fuel Charge:" . v[5] . "		HLTC (Economy Class)+Airline Fuel Charge: " . v[3] + v[5] "`n"
}
Hubert
User avatar
TLM
Posts: 1323
Joined: 01 Oct 2013, 07:52

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 08:21

boiler wrote:You have this:
complete_Array := strsplit(var, ["`n", "`t"])

You can't have the [ ] in it. So it should look like this:
complete_Array := strsplit(var, "`n", "`t")

...except I don't think you are really trying to use the third parameter which would say you want to omit the tab character. If you are trying to make a two-dimensional array, You can't do that from one StrSplit.
This is not true. The StrSplit() function excepts an array of delimiters: msgbox % StrSplit( "a,b,c!d*e", [ ",", "!", "*" ] ).Length()

Code: Select all

For i, key in StrSplit( "a,b,c!d*e", [ ",", "!", "*" ] )
    msgbox % key
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 08:27

@Hubert

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
test := ""
list_of_from_places := ""
list_of_to_places := ""


var =
(
1   Agartala   Guwahati   4831   10140   1850
2   Agartala   Kolkata   3891   8506   1850
3   Agartala   Silchar   4401      1850
4   Agatti   Bengaluru   10691      1850
5   Agatti   Chennai   10646      2150
6   Agatti   Kochi   8571      1850
7   Agatti   Kozhikode   7471      1850
8   Agra   Delhi   5681   15327   1850
9   Agra   Khajuraho   3891   8506   1850
10   Agra   Varanasi   4946   12951   1850
11   Agra   Mumbai   8571      2950
12   Ahmedabad   Chennai   7426   26186   2950
13   Ahmedabad   Delhi   6000   15502   2150
14   Ahmedabad   Hyderabad   7076   19532   2150
15   Ahmedabad   Mumbai   4351   13425   1850
16   Aizawl   Guwahati   5351      1850
17   Aizawl   Imphal   4466   7337   1850
18   Aizawl   Kolkata   4626   11108   1850
19   Allahabad   Delhi   6541      1850
20   Allahabad   Kanpur   4751      1850
21   Allahabad   Mumbai   9401      2950
22   Amritsar   Delhi   4366   12436   1850
23   Aurangabad   Delhi   8801   21747   2150
24   Aurangabad   Mumbai   4451   10133   1850
25   Bagdogra   Delhi   9716   21024   2950
26   Bagdogra   Guwahati   4536   8398   1850
27   Bagdogra   Kolkata   5436   13188   1850
28   Bengaluru   Chennai   4701   10691   1850
29   Bengaluru   Delhi   9901   28985   3650
30   Bengaluru   Goa   5151   13297   1850
31   Bengaluru   Hyderabad   5451   14823   1850
32   Bengaluru   Kochi   4501   10907   1850
33   Bengaluru   Kolkata   9701   30799   3650
34   Bengaluru   Mangalore   4936      1850
35   Bengaluru   Mumbai   6851   16356   2150
36   Bengaluru   Pune   6184   16506   1850
37   Bengaluru   Tirupati   5221      1850
38   Bengaluru   Trivandrum   5451   12473   1850
39   Bhopal   Delhi   4801   14856   1850
40   Bhopal   Indore   4281   8625   1850
41   Bhopal   Mumbai   5356   15560   1850
42   Bhubaneshwar   Chennai   8291   17520   2950
43   Bhubaneshwar   Delhi   9001   27424   2950
44   Bhubaneshwar   Kolkata   5406   11764   1850
45   Bhubaneshwar   Mumbai   9401   29518   2950
46   Bhubaneshwar   Port Blair   11216      2950
47   Bhuj   Mumbai   6541      1850
48   Chandigarh   Delhi   4301   10534   1850
49   Chandigarh   Mumbai   8836   26295   2950
50   Chennai   Coimbatore   4251   12166   1850
51   Chennai   Delhi   8456   28474   3650
52   Chennai   Goa   6311   16217   1850
53   Chennai   Hyderabad   4451   13732   1850
54   Chennai   Kochi   5251   14630   1850
55   Chennai   Kolkata   8566   27543   2950
56   Chennai   Madurai   4251   11801   1850
57   Chennai   Mumbai   8571   18623   2950
58   Chennai   Pune   7851   21017   2150
59   Chennai   Portblair   9411   24229   2950
60   Chennai   Trivandrum   5601   14637   1850
61   Chennai   Vishakhapatnam   4801   14673   1850
62   Coimbatore   Delhi   9751   32763   3650
63   Coimbatore   Kozhikode   4451   6739   1850
64   Coimbatore   Mumbai   8001   18331   2950
65   Dehradun   Delhi   5221   13980   1850
66   Dehli   Dharamsala   4821      1850
67   Delhi   Gaya   6851   19532   2150
68   Delhi   Goa   8821   25860   3650
69   Delhi   Guwahati   9811   24988   3650
70   Delhi   Gwalior   5051   9977   1850
71   Delhi   Hyderabad   8401   25748   2950
72   Delhi   Imphal   9081   27248   3650
73   Delhi   Indore   4851   15867   1850
74   Delhi   Jabalpur   6401      1850
75   Delhi   Jaipur   3551   8815   1850
76   Delhi   Jammu   4401   13181   1850
77   Delhi   Jodhpur   5706   14290   1850
78   Delhi   Kanpur   5701      1850
79   Delhi   Khajuraho   5651   15108   1850
80   Delhi   Kochi   12351   37731   3650
81   Delhi   Kolkata   9061   24251   2950
82   Delhi   Kozhikode   10051   32763   3650
83   Delhi   Kullu   6301      1850
84   Delhi   Leh   5501   15141   1850
85   Delhi   Lucknow   4821   12505   1850
86   Delhi   Ludhiana   4351      1850
87   Delhi   Mangalore   9901   29248   3650
88   Delhi   Mumbai   8951   22740   2950
89   Delhi   Pantnagar   4301      1850
90   Delhi   Nagpur   7171   17336   2150
91   Delhi   Pathankot   5101      1850
92   Delhi   Patna   7151   17265   2150
93   Delhi   Port Blair   21516      3650
94   Delhi   Pune   9401   28208   2950
95   Delhi   Raipur   7851   22112   2150
96   Delhi   Rajkot   9101      2150
97   Delhi   Ranchi   8811   20732   2950
98   Delhi   Srinagar   6201   13370   1850
99   Delhi   Surat   9101   20819   2150
100   Delhi   Tirupati   9016   23756   3650
101   Delhi   Trivandrum   12156   37731   3650
102   Delhi   Udaipur   5786   15382   1850
103   Delhi   Vadodra   7051   19853   2150
104   Delhi   Varanasi   5681   15327   1850
105   Delhi   Vijayawada   8566   26202   2950
106   Delhi   Vishakhapatnam   10401   30218   2950
107   Dibrugarh   Dimapur   3251   5106   1850
108   Dibrugarh   Guwahati   4801      1850
109   Dibrugarh   Kolkata   7401   14776   2150
110   Dibrugarh   Lilabari   4051      1850
111   Dimapur   Guwahati   4701      1850
112   Dimapur   Imphal   4401      1850
113   Dimapur   Kolkata   6101   13822   1850
114   Dimapur   Shillong   4101      1850
115   Gaya   Kolkata   4501   11744   1850
116   Gaya   Varanasi   4851   9518   1850
117   Goa   Kochi   5001   15159   1850
118   Goa   Hyderabad   5251   13657   1850
119   Goa   Mumbai   5321   11232   1850
120   Goa   Pune   4536   8874   1850
121   Goa   Srinagar   12351   38431   3650
122   Guwahati   Imphal   4901   9498   1850
123   Guwahati   Jorhat   3736      1850
124   Guwahati   Kolkata   5076   11465   1850
125   Guwahati   Lilabari   5151      1850
126   Guwahati   Silchar   5251      1850
127   Guwahati   Tezpur   4436      1850
128   Gwalior   Mumbai   8401   19551   2150
129   Hyderabad   Kolkata   9696   24985   2950
130   Hyderabad   Mumbai   5251   14980   1850
131   Hyderabad   Pune   5231   14265   1850
132   Hyderabad   Tirupati   4656   12571   1850
133   Hyderabad   Varanasi   8811   21806   2950
134   Hyderabad   Vijayawada   5051   10655   1850
135   Hyderabad   Vishakhapatnam   4946   12951   1850
136   Imphal   Kolkata   4281   11680   1850
137   Imphal   Silchar   4601      1850
138   Indore   Mumbai   4481   12637   1850
139   Jaipur   Mumbai   7851   18794   2150
140   Jammu   Leh   4886   9069   1850
141   Jammu   Srinagar   4403   6998   1850
142   Jamnagar   Mumbai   5181   12400   1850
143   Jodhpur   Mumbai   7686   18670   2150
144   Jodhpur   Udaipur   4231   8724   1850
145   Jorhat   Kolkata   4976      1850
146   Jorhat   Tezpur   4136      1850
147   Kanpur   Kolkata   7401      2150
148   Khajuraho   Varanasi   4936   12681   1850
149   Kochi   Kozhikode   3501   7283   1850
150   Kochi   Madurai   4301      1850
151   Kochi   Mumbai   8401   21634   2950
152   Kochi   Trivandrum   4301   8326   1850
153   Kolkata   Kochi   10051      3650
154   Kolkata   Lilabari   7800      2150
155   Kolkata   Mumbai   8486   23558   3650
156   Kolkata   Patna   5706      1850
157   Kolkata   Port Blair   11071   26781   2950
158   Kolkata   Ranchi   4536      1850
159   Kolkata   Shillong   5481      1850
160   Kolkata   Silchar   5001   11085   1850
161   Kolkata   Tezpur   5151      1850
162   Kozhikode   Chennai   5151      1850
163   Kozhikode   Kolkata   8456      3650
164   Kozhikode   Mumbai   9100   16513   2150
165   Kozhikode   Trivandrum   4391      1850
166   Kullu   Pathankot   4001      1850
167   Leh   Srinagar   4603   8283   1850
168   Lilabari   Tezpur   3881      1850
169   Lucknow   Mumbai   8051   24985   2950
170   Lucknow   Varanasi   4626   9607   1850
171   Ludhiana   Pathankot   4201      1850
172   Madurai   Mumbai   7851   23657   2950
173   Mangalore   Mumbai   6086   15761   1850
174   Mumbai   Nagpur   5001   15159   1850
175   Mumbai   Raipur   9500   20692   2150
176   Mumbai   Rajkot   5281   12473   1850
177   Mumbai   Ranchi   9751   22813   2950
178   Mumbai   Srinagar   9016   23756   3650
179   Mumbai   Trivandrum   10201   23901   2950
180   Mumbai   Udaipur   4786   15407   1850
181   Mumbai   Varanasi   9696   24511   2950
182   Mumbai   Vishakhapatnam   9101   24872   2950
183   Patna   Ranchi   4603      1850
184   PortBlair   Vishakhapatnam   9696   24511   2950
185   Raipur   Bhubaneshwar   4281   9977   1850
186   Raipur   Nagpur   5181   12660   1850
187   Raipur   Vishakhapatnam   4251   11606   1850
188   Shillong   Jorhat   4551      1850
189   Silchar   Tezpur   4101      1850
190   Tirupati   Vijayawada   5406      1850
191   Vishakhapatnam   Bhubaneshwar   5321   10518   1850
)

array_from_places := {}
array := strsplit(var, "`n")

loop, % array.maxindex()
{
   lines := array[A_index]
   array_ := strsplit(lines, "`t")   
   array_from_places[array_[2], array_[3]] := [array_[4], array_[5] = "" ? 0 : array_[5], array_[6]]
   list_of_from_places .= array_[2] . "|"
   list_of_to_places .= array_[3] . "|"
} 
stringtrimright, list_of_from_places, list_of_from_places, 1
stringtrimright, list_of_to_places, list_of_to_places, 1
sort, list_of_from_places, D| U
sort, list_of_to_places, D| U

Gui, Add, Text,, From:
Gui, Add, ComboBox, vFrom ym gNew, %list_of_from_places%  ; The ym option starts a new column of controls.
Gui, Add, Text, ym, To:
Gui, Add, ComboBox, vto ym gNew, %list_of_to_places% 
Gui, Add, Button, gButtonOK vNew xm w80, % test
Gui, Add, Text, xm+30 vResult w1000 h300
Gui, Show,, Simple Input Example
return  ; End of auto-execute section. The script is idle until the user does something.

New:
test = start search
GuiControl,, New, % test
GuiControl,, Result, 
return

GuiClose:
ButtonOK:
Gui, Submit, nohide  ; Save the input from the user to each control's associated variable.
used =
found = 
result := {}
result := search(from, to)
test =
loop, % result.maxindex()
{
   k := result.maxindex() - a_index + 1
   v := result[k] 
   test .= "From: " . v[1] . "   To: " . v[2] . "   HLTC (Economy Class): " . v[3] . "   DLTC (Executive Class): " . v[4] . "   Airline Fuel Charge:" . v[5] . "      HLTC (Economy Class)+Airline Fuel Charge: " . v[3] + v[5] "`n"
}
if !test
   test = no connection found
GuiControl,, Result, % test
return   

search(from, to)
{
   global array_from_places, used, result, found
   if !from
      return
   used .= from ","
   if array_from_places[from].haskey(to)
   {
      htlc := array_from_places[from, to, 1]
      dtlc := array_from_places[from, to, 2]
      afc := array_from_places[from, to , 3]
      result.insert([from, to, htlc, dtlc, afc])
   }
   else
   {
      for key, value in array_from_places[from]
      {
         if !key
            return
         if key in %used%
            continue
         if (key = to)
         {
            htlc := array_from_places[from, key, 1]
            dtlc := array_from_places[from, key, 2]
            afc := array_from_places[from, key, 3]
            result.insert([from, key, htlc, dtlc, afc])
            found = 1
            break
         }
         search(key, to)
         if array_from_places[key].haskey(to) or found
         {
            htlc := array_from_places[from, key, 1]
            dtlc := array_from_places[from, key, 2]
            afc := array_from_places[from, key, 3]
            result.insert([from, key, htlc, dtlc, afc])
            found = 1
            break
         }
      }
   }
return result
}
:( not working
John ... you working ?
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 08:40

Reached LEVEL 3. eg: AgartalAgatti to Ranchi

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
var =
(
1	Agartala	Guwahati	4831	10140	1850
2	Agartala	Kolkata	3891	8506	1850
3	Agartala	Silchar	4401		1850
4	Agatti	Bengaluru	10691		1850
5	Agatti	Chennai	10646		2150
6	Agatti	Kochi	8571		1850
7	Agatti	Kozhikode	7471		1850
8	Agra	Delhi	5681	15327	1850
9	Agra	Khajuraho	3891	8506	1850
10	Agra	Varanasi	4946	12951	1850
11	Agra	Mumbai	8571		2950
12	Ahmedabad	Chennai	7426	26186	2950
13	Ahmedabad	Delhi	6000	15502	2150
14	Ahmedabad	Hyderabad	7076	19532	2150
15	Ahmedabad	Mumbai	4351	13425	1850
16	Aizawl	Guwahati	5351		1850
17	Aizawl	Imphal	4466	7337	1850
18	Aizawl	Kolkata	4626	11108	1850
19	Allahabad	Delhi	6541		1850
20	Allahabad	Kanpur	4751		1850
21	Allahabad	Mumbai	9401		2950
22	Amritsar	Delhi	4366	12436	1850
23	Aurangabad	Delhi	8801	21747	2150
24	Aurangabad	Mumbai	4451	10133	1850
25	Bagdogra	Delhi	9716	21024	2950
26	Bagdogra	Guwahati	4536	8398	1850
27	Bagdogra	Kolkata	5436	13188	1850
28	Bengaluru	Chennai	4701	10691	1850
29	Bengaluru	Delhi	9901	28985	3650
30	Bengaluru	Goa	5151	13297	1850
31	Bengaluru	Hyderabad	5451	14823	1850
32	Bengaluru	Kochi	4501	10907	1850
33	Bengaluru	Kolkata	9701	30799	3650
34	Bengaluru	Mangalore	4936		1850
35	Bengaluru	Mumbai	6851	16356	2150
36	Bengaluru	Pune	6184	16506	1850
37	Bengaluru	Tirupati	5221		1850
38	Bengaluru	Trivandrum	5451	12473	1850
39	Bhopal	Delhi	4801	14856	1850
40	Bhopal	Indore	4281	8625	1850
41	Bhopal	Mumbai	5356	15560	1850
42	Bhubaneshwar	Chennai	8291	17520	2950
43	Bhubaneshwar	Delhi	9001	27424	2950
44	Bhubaneshwar	Kolkata	5406	11764	1850
45	Bhubaneshwar	Mumbai	9401	29518	2950
46	Bhubaneshwar	Port Blair	11216		2950
47	Bhuj	Mumbai	6541		1850
48	Chandigarh	Delhi	4301	10534	1850
49	Chandigarh	Mumbai	8836	26295	2950
50	Chennai	Coimbatore	4251	12166	1850
51	Chennai	Delhi	8456	28474	3650
52	Chennai	Goa	6311	16217	1850
53	Chennai	Hyderabad	4451	13732	1850
54	Chennai	Kochi	5251	14630	1850
55	Chennai	Kolkata	8566	27543	2950
56	Chennai	Madurai	4251	11801	1850
57	Chennai	Mumbai	8571	18623	2950
58	Chennai	Pune	7851	21017	2150
59	Chennai	Portblair	9411	24229	2950
60	Chennai	Trivandrum	5601	14637	1850
61	Chennai	Vishakhapatnam	4801	14673	1850
62	Coimbatore	Delhi	9751	32763	3650
63	Coimbatore	Kozhikode	4451	6739	1850
64	Coimbatore	Mumbai	8001	18331	2950
65	Dehradun	Delhi	5221	13980	1850
66	Dehli	Dharamsala	4821		1850
67	Delhi	Gaya	6851	19532	2150
68	Delhi	Goa	8821	25860	3650
69	Delhi	Guwahati	9811	24988	3650
70	Delhi	Gwalior	5051	9977	1850
71	Delhi	Hyderabad	8401	25748	2950
72	Delhi	Imphal	9081	27248	3650
73	Delhi	Indore	4851	15867	1850
74	Delhi	Jabalpur	6401		1850
75	Delhi	Jaipur	3551	8815	1850
76	Delhi	Jammu	4401	13181	1850
77	Delhi	Jodhpur	5706	14290	1850
78	Delhi	Kanpur	5701		1850
79	Delhi	Khajuraho	5651	15108	1850
80	Delhi	Kochi	12351	37731	3650
81	Delhi	Kolkata	9061	24251	2950
82	Delhi	Kozhikode	10051	32763	3650
83	Delhi	Kullu	6301		1850
84	Delhi	Leh	5501	15141	1850
85	Delhi	Lucknow	4821	12505	1850
86	Delhi	Ludhiana	4351		1850
87	Delhi	Mangalore	9901	29248	3650
88	Delhi	Mumbai	8951	22740	2950
89	Delhi	Pantnagar	4301		1850
90	Delhi	Nagpur	7171	17336	2150
91	Delhi	Pathankot	5101		1850
92	Delhi	Patna	7151	17265	2150
93	Delhi	Port Blair	21516		3650
94	Delhi	Pune	9401	28208	2950
95	Delhi	Raipur	7851	22112	2150
96	Delhi	Rajkot	9101		2150
97	Delhi	Ranchi	8811	20732	2950
98	Delhi	Srinagar	6201	13370	1850
99	Delhi	Surat	9101	20819	2150
100	Delhi	Tirupati	9016	23756	3650
101	Delhi	Trivandrum	12156	37731	3650
102	Delhi	Udaipur	5786	15382	1850
103	Delhi	Vadodra	7051	19853	2150
104	Delhi	Varanasi	5681	15327	1850
105	Delhi	Vijayawada	8566	26202	2950
106	Delhi	Vishakhapatnam	10401	30218	2950
107	Dibrugarh	Dimapur	3251	5106	1850
108	Dibrugarh	Guwahati	4801		1850
109	Dibrugarh	Kolkata	7401	14776	2150
110	Dibrugarh	Lilabari	4051		1850
111	Dimapur	Guwahati	4701		1850
112	Dimapur	Imphal	4401		1850
113	Dimapur	Kolkata	6101	13822	1850
114	Dimapur	Shillong	4101		1850
115	Gaya	Kolkata	4501	11744	1850
116	Gaya	Varanasi	4851	9518	1850
117	Goa	Kochi	5001	15159	1850
118	Goa	Hyderabad	5251	13657	1850
119	Goa	Mumbai	5321	11232	1850
120	Goa	Pune	4536	8874	1850
121	Goa	Srinagar	12351	38431	3650
122	Guwahati	Imphal	4901	9498	1850
123	Guwahati	Jorhat	3736		1850
124	Guwahati	Kolkata	5076	11465	1850
125	Guwahati	Lilabari	5151		1850
126	Guwahati	Silchar	5251		1850
127	Guwahati	Tezpur	4436		1850
128	Gwalior	Mumbai	8401	19551	2150
129	Hyderabad	Kolkata	9696	24985	2950
130	Hyderabad	Mumbai	5251	14980	1850
131	Hyderabad	Pune	5231	14265	1850
132	Hyderabad	Tirupati	4656	12571	1850
133	Hyderabad	Varanasi	8811	21806	2950
134	Hyderabad	Vijayawada	5051	10655	1850
135	Hyderabad	Vishakhapatnam	4946	12951	1850
136	Imphal	Kolkata	4281	11680	1850
137	Imphal	Silchar	4601		1850
138	Indore	Mumbai	4481	12637	1850
139	Jaipur	Mumbai	7851	18794	2150
140	Jammu	Leh	4886	9069	1850
141	Jammu	Srinagar	4403	6998	1850
142	Jamnagar	Mumbai	5181	12400	1850
143	Jodhpur	Mumbai	7686	18670	2150
144	Jodhpur	Udaipur	4231	8724	1850
145	Jorhat	Kolkata	4976		1850
146	Jorhat	Tezpur	4136		1850
147	Kanpur	Kolkata	7401		2150
148	Khajuraho	Varanasi	4936	12681	1850
149	Kochi	Kozhikode	3501	7283	1850
150	Kochi	Madurai	4301		1850
151	Kochi	Mumbai	8401	21634	2950
152	Kochi	Trivandrum	4301	8326	1850
153	Kolkata	Kochi	10051		3650
154	Kolkata	Lilabari	7800		2150
155	Kolkata	Mumbai	8486	23558	3650
156	Kolkata	Patna	5706		1850
157	Kolkata	Port Blair	11071	26781	2950
158	Kolkata	Ranchi	4536		1850
159	Kolkata	Shillong	5481		1850
160	Kolkata	Silchar	5001	11085	1850
161	Kolkata	Tezpur	5151		1850
162	Kozhikode	Chennai	5151		1850
163	Kozhikode	Kolkata	8456		3650
164	Kozhikode	Mumbai	9100	16513	2150
165	Kozhikode	Trivandrum	4391		1850
166	Kullu	Pathankot	4001		1850
167	Leh	Srinagar	4603	8283	1850
168	Lilabari	Tezpur	3881		1850
169	Lucknow	Mumbai	8051	24985	2950
170	Lucknow	Varanasi	4626	9607	1850
171	Ludhiana	Pathankot	4201		1850
172	Madurai	Mumbai	7851	23657	2950
173	Mangalore	Mumbai	6086	15761	1850
174	Mumbai	Nagpur	5001	15159	1850
175	Mumbai	Raipur	9500	20692	2150
176	Mumbai	Rajkot	5281	12473	1850
177	Mumbai	Ranchi	9751	22813	2950
178	Mumbai	Srinagar	9016	23756	3650
179	Mumbai	Trivandrum	10201	23901	2950
180	Mumbai	Udaipur	4786	15407	1850
181	Mumbai	Varanasi	9696	24511	2950
182	Mumbai	Vishakhapatnam	9101	24872	2950
183	Patna	Ranchi	4603		1850
184	PortBlair	Vishakhapatnam	9696	24511	2950
185	Raipur	Bhubaneshwar	4281	9977	1850
186	Raipur	Nagpur	5181	12660	1850
187	Raipur	Vishakhapatnam	4251	11606	1850
188	Shillong	Jorhat	4551		1850
189	Silchar	Tezpur	4101		1850
190	Tirupati	Vijayawada	5406		1850
191	Vishakhapatnam	Bhubaneshwar	5321	10518	1850
)

complete_Array := strsplit(var, ["`n", "`t"])


loop, % complete_Array.MaxIndex()
{
	if ( complete_Array[A_index] = "" ) ; to store 0 where in DLTC  fare is not shown
		complete_Array[A_index] := 0
}


	



array_from_places_list := {}
array_to_places_list := {}

array := strsplit(var, ["`n"])

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 2 )
		from_places .= array_[A_index] . "`n"
}
sort from_places
loop, parse, from_places, "`n"
{
if ( array_from_places_list[A_loopfield] = "" )
{
	array_from_places_list[A_loopfield] := A_loopfield
	list_of_from_places .= A_loopfield . "|"
}
}

loop, % array.maxindex()
{
	lines := array[A_index]
array_ := strsplit(lines, ["`t"])	
loop, % array_.maxindex()
	if ( A_index = 3 )
		to_places .= array_[A_index] . "`n"
}
sort to_places
loop, parse, to_places, "`n"
{
if ( array_to_places_list[A_loopfield] = "" )
{
	array_to_places_list[A_loopfield] := A_loopfield
	list_of_to_places .= A_loopfield . "|"
}
}


gui, font, s10, Verdana  ; 
Gui, Add, Text,, From:
Gui, Add, ComboBox, vFrom ym gButtonOK, %list_of_from_places%  ; The ym option starts a new column of controls.

Gui, Add, Text, ym, To:
Gui, Add, ComboBox, vto ym gButtonOK, %list_of_to_places% 

Gui, Add, Text, gButtonOK xm vResult w1300 h400  ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Simple Input Example
return  ; End of auto-execute section. The script is idle until the user does something.

ButtonOK:
Gui, Submit, nohide  ; Save the input from the user to each control's associated variable.
loop, % complete_Array.MaxIndex()
{
if ( complete_Array[A_index] = from ) && ( complete_Array[A_index+1] = to )
{
	;~ MsgBox % complete_Array[A_index] . " " . complete_Array[A_index+1] . " " . complete_Array[A_index+2] . " " . complete_Array[A_index+4] . " " . complete_Array[A_index+5]
	test := "From: " . complete_Array[A_index] . "	To: " . complete_Array[A_index+1] . "	HLTC (Economy Class): " . complete_Array[A_index+2] . "	DLTC (Executive Class): " . complete_Array[A_index+3] . "	Airline Fuel Charge:" . complete_Array[A_index+4] . "	HLTC (Economy Class)+Airline Fuel Charge: " . complete_Array[A_index+2] + complete_Array[A_index+4]
GuiControl,, Result, % test
return	
}


if ( A_index = complete_Array.MaxIndex() )
{
;==========LEVEL 2=============================================================================================================
	from_list := to_list := Result := ""
	
	loop, % complete_Array.MaxIndex()
	{
		if ( A_index = 1 )
			result := ""
		if ( complete_Array[( (A_index-1) * 6 + 2)] = from )
		{
			f_f := A_index
			;~ 2_from_place := complete_Array[( (f_f-1) * 6 + 2)]
			;~ from_list .= complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "`n" 
			new_from := complete_Array[( (f_f-1) * 6 + 2+1)]
			
				loop, % complete_Array.MaxIndex()
	{
		if ( complete_Array[( (A_index-1) * 6 + 2)] = new_from ) && ( complete_Array[( (A_index-1) * 6 + 3)] = to )
		{
			t_t := A_index
			;~ 2_from_place := complete_Array[( (t_t-1) * 6 + 2)]
			from_list := complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "	Total: " . complete_Array[( (f_f-1) * 6 + 2+2)]+complete_Array[( (f_f-1) * 6 + 2+4)] . "`n"
			to_list := complete_Array[( (t_t-1) * 6 + 2)] . " " . complete_Array[( (t_t-1) * 6 + 2+1)] . " " . complete_Array[( (t_t-1) * 6 + 2+2)] . " " . complete_Array[( (t_t-1) * 6 + 2+3)] . " " . complete_Array[( (t_t-1) * 6 + 2+4)] . "	Total: " . complete_Array[( (t_t-1) * 6 + 2+2)]+complete_Array[( (t_t-1) * 6 + 2+4)]+complete_Array[( (f_f-1) * 6 + 2+2)]+complete_Array[( (f_f-1) * 6 + 2+4)] . "`n"
			;~ if ( A_index = complete_Array.MaxIndex() )
			Result .= from_list . to_list . "`n"
		}

	}
	}
	;~ GuiControl,, Result, % result
	;~ break
	}
	GuiControl,, Result, % result
	if ( result = "" )
	{
		
		;~ MsgBox % from . " " . new_from
		level3_from := From
		level3_to := new_from
;;;////////////////
loop, % complete_Array.MaxIndex()
{
if ( complete_Array[A_index] = level3_from ) && ( complete_Array[A_index+1] = level3_to )
{
	;~ MsgBox % complete_Array[A_index] . " " . complete_Array[A_index+1] . " " . complete_Array[A_index+2] . " " . complete_Array[A_index+4] . " " . complete_Array[A_index+5]
	test := complete_Array[A_index] . " " . complete_Array[A_index+1] . " " . complete_Array[A_index+2] . " " . complete_Array[A_index+3] . " " . complete_Array[A_index+4] . "	Total:" . complete_Array[A_index+2] + complete_Array[A_index+4]
	total_1_of_level3 := complete_Array[A_index+2] + complete_Array[A_index+4]
	from_list := to_list := Result := ""
	
	loop, % complete_Array.MaxIndex()
	{
		if ( A_index = 1 )
			result := ""
		if ( complete_Array[( (A_index-1) * 6 + 2)] = new_from )
		{
			f_f := A_index
			;~ 2_from_place := complete_Array[( (f_f-1) * 6 + 2)]
			;~ from_list .= complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "`n" 
			new_new_from := complete_Array[( (f_f-1) * 6 + 2+1)]
			
				loop, % complete_Array.MaxIndex()
	{
		if ( complete_Array[( (A_index-1) * 6 + 2)] = new_new_from ) && ( complete_Array[( (A_index-1) * 6 + 3)] = to )
		{
			t_t := A_index
			;~ 2_from_place := complete_Array[( (t_t-1) * 6 + 2)]
			from_list := complete_Array[( (f_f-1) * 6 + 2)] . " " . complete_Array[( (f_f-1) * 6 + 2+1)] . " " . complete_Array[( (f_f-1) * 6 + 2+2)] . " " . complete_Array[( (f_f-1) * 6 + 2+3)] . " " . complete_Array[( (f_f-1) * 6 + 2+4)] . "	Total: " . complete_Array[( (f_f-1) * 6 + 2+2)]+complete_Array[( (f_f-1) * 6 + 2+4)]+total_1_of_level3 . "`n"
			to_list := complete_Array[( (t_t-1) * 6 + 2)] . " " . complete_Array[( (t_t-1) * 6 + 2+1)] . " " . complete_Array[( (t_t-1) * 6 + 2+2)] . " " . complete_Array[( (t_t-1) * 6 + 2+3)] . " " . complete_Array[( (t_t-1) * 6 + 2+4)] . "	Total: " . complete_Array[( (t_t-1) * 6 + 2+2)]+complete_Array[( (t_t-1) * 6 + 2+4)]+complete_Array[( (f_f-1) * 6 + 2+2)]+complete_Array[( (f_f-1) * 6 + 2+4)]+total_1_of_level3 . "`n"
			;~ if ( A_index = complete_Array.MaxIndex() )
			Result .= test . "`n" . from_list . to_list . "`n"
		}

	}
	}
	;~ GuiControl,, Result, % result
	;~ break
	}
	GuiControl,, Result, % result
;~ GuiControl,, Result, % test
;~ return	
}
}
;;;////////////////

		
;-===========================LEVEL 3======================================================================================================

;============================LEVEL 3======================================================================================================		
		
		
		
	}
	return
	
	}
;=================LEVEL 2==================================================================================================================

}




GuiControl,, Result, result

return
guiclose:
ExitApp
esc::ExitApp

John ... you working ?
hd0202
Posts: 61
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 08:47

@smorgasbord: please copy the 191 flight lines from your old version. On the way over this forum the `t were expanded to spaces

Hubert
User avatar
smorgasbord
Posts: 490
Joined: 30 Sep 2013, 09:34

Re: how to search for via routes when there are no direct ro

08 Apr 2015, 08:55

@hd0202
could you paste the code at some other site?
like
http://ahk.uk.to/
OR
someother similar site?
thanks
John ... you working ?

Return to “Ask For Help”

Who is online

Users browsing this forum: Bad husband, kczx3, pteronaut, swagfag and 27 guests