-
Notifications
You must be signed in to change notification settings - Fork 0
/
SEARCH.C
127 lines (121 loc) · 3.52 KB
/
SEARCH.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "golf.h"
extern player_array players; /* stores all player element data */
extern course_array courses; /* variable to store the courses in memory */
extern int p_index; /* keeps track of current record */
extern int c_index; /* keeps track of current record */
extern int r_index;
extern int r_last;
extern HWND hWndRList;
/*
**************************************************************************
search.c Brett A. Morrison
This file contains the routines for searching for a player
**************************************************************************
*/
void SearchFor(HWND hwnd, BOOL bWhich, int iKey, char szSearch_for[], BOOL bBeginning)
{
int i;
BOOL bFound = FALSE;
char szTemp[SEARCH_LENGTH+1];
switch(bWhich)
{
case IDM_P_SEARCH:
for ((bBeginning) ? (i = 0) : (i = p_index+1); i<=(players).player_numb && !bFound; i++)
{
switch(iKey)
{
case IDD_S_FIRSTNAME:
if (lstrcmp(szSearch_for, (players).player[i].p_first) == 0)
bFound = TRUE;
break;
case IDD_S_LASTNAME:
if (lstrcmp(szSearch_for, (players).player[i].p_last) == 0)
bFound = TRUE;
break;
case IDD_S_STREET:
if (lstrcmp(szSearch_for, (players).player[i].p_street) == 0)
bFound = TRUE;
break;
case IDD_S_CITY:
if (lstrcmp(szSearch_for, (players).player[i].p_city) == 0)
bFound = TRUE;
break;
case IDD_S_STATE:
if (lstrcmp(szSearch_for, (players).player[i].p_state) == 0)
bFound = TRUE;
break;
case IDD_S_ZIP:
if (lstrcmp(szSearch_for, (players).player[i].p_zip) == 0)
bFound = TRUE;
break;
case IDD_S_PHONE:
if (lstrcmp(szSearch_for, (players).player[i].p_phone) == 0)
bFound = TRUE;
break;
} /* switch iKey */
} /* for */
if (bFound)
{
if (p_index != i-1) /* need to show - else already on screen */
{
p_index = i-1;
show_player(hwnd, hWndRList, &players, &p_index, &r_index, &r_last);
} /* if */
} /* if */
else
{
lstrcpy(szTemp, szSearch_for);
lstrcat(szTemp, " Not Found");
MessageBeep(0);
MessageBox(hwnd, szTemp, "Search Player", MB_OK | MB_ICONINFORMATION);
} /* else */
break;
case IDM_C_SEARCH:
for ((bBeginning) ? (i = 0) : (i = c_index+1); i<=(courses).course_numb && !bFound; i++)
{
switch(iKey)
{
case IDD_S_COURSE:
if (lstrcmp(szSearch_for, (courses).course[i].c_name) == 0)
bFound = TRUE;
break;
case IDD_S_STREET:
if (lstrcmp(szSearch_for, (courses).course[i].c_street) == 0)
bFound = TRUE;
break;
case IDD_S_CITY:
if (lstrcmp(szSearch_for, (courses).course[i].c_city) == 0)
bFound = TRUE;
break;
case IDD_S_STATE:
if (lstrcmp(szSearch_for, (courses).course[i].c_state) == 0)
bFound = TRUE;
break;
case IDD_S_ZIP:
if (lstrcmp(szSearch_for, (courses).course[i].c_zip) == 0)
bFound = TRUE;
break;
case IDD_S_PHONE:
if (lstrcmp(szSearch_for, (courses).course[i].c_phone) == 0)
bFound = TRUE;
break;
} /* switch iKey */
} /* for */
if (bFound)
{
if (c_index != i-1) /* need to show - else already on screen */
{
c_index = i-1;
show_course(hwnd, &courses, &c_index);
} /* if */
} /* if */
else
{
lstrcpy(szTemp, szSearch_for);
lstrcat(szTemp, " Not Found");
MessageBeep(0);
MessageBox(hwnd, szTemp, "Search Course", MB_OK | MB_ICONINFORMATION);
} /* else */
break;
} /* switch bWhich */
} /* SearchFor */