35
35
extern int ascii ;
36
36
37
37
/* Fields to display (-f) */
38
- int fields [10 ] = {
39
- 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1
38
+ int fields [] = {
39
+ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
40
+ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
41
+ 1 , 1 , 1 , 1 , 1
40
42
};
41
43
42
- int max_field = 9 ;
44
+ int max_field = 24 ;
43
45
44
46
char program_name [20 ] = "cwsub" ;
45
47
@@ -137,6 +139,128 @@ DECLARE_FIELDFUNC(cwsub_event_number)
137
139
gameiter -> state -> event_count : gameiter -> state -> event_count + 1 );
138
140
}
139
141
142
+ /* Field 10 */
143
+ DECLARE_FIELDFUNC (cwsub_balls )
144
+ {
145
+ if (strlen (gameiter -> event -> count ) >= 2 &&
146
+ gameiter -> event -> count [0 ] != '?' &&
147
+ gameiter -> event -> count [1 ] != '?' ) {
148
+ return sprintf (buffer , "%c" , gameiter -> event -> count [0 ]);
149
+ }
150
+ else {
151
+ return sprintf (buffer , "0" );
152
+ }
153
+ }
154
+
155
+ /* Field 11 */
156
+ DECLARE_FIELDFUNC (cwsub_strikes )
157
+ {
158
+ if (strlen (gameiter -> event -> count ) >= 2 &&
159
+ gameiter -> event -> count [0 ] != '?' &&
160
+ gameiter -> event -> count [1 ] != '?' ) {
161
+ return sprintf (buffer , "%c" , gameiter -> event -> count [1 ]);
162
+ }
163
+ else {
164
+ return sprintf (buffer , "0" );
165
+ }
166
+ }
167
+
168
+ /* Field 12 */
169
+ DECLARE_FIELDFUNC (cwsub_pitches )
170
+ {
171
+ /* This bit of code wipes out leading whitespace, which bevent
172
+ * does not include in its output */
173
+ char * foo = gameiter -> event -> pitches ;
174
+ while (foo && isspace (* foo )) {
175
+ foo ++ ;
176
+ }
177
+ return sprintf (buffer , (ascii ) ? "\"%s\"" : "%-20s" , foo );
178
+ }
179
+
180
+ /* Field 13 */
181
+ DECLARE_FIELDFUNC (cwsub_pitches_balls )
182
+ {
183
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
184
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_ball_thrown ));
185
+ }
186
+
187
+ /* Field 14 */
188
+ DECLARE_FIELDFUNC (cwsub_pitches_balls_called )
189
+ {
190
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
191
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_ball_called ));
192
+ }
193
+
194
+ /* Field 15 */
195
+ DECLARE_FIELDFUNC (cwsub_pitches_balls_intentional )
196
+ {
197
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
198
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_ball_intentional ));
199
+ }
200
+
201
+ /* Field 16 */
202
+ DECLARE_FIELDFUNC (cwsub_pitches_balls_pitchout )
203
+ {
204
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
205
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_ball_pitchout ));
206
+ }
207
+
208
+ /* Field 17 */
209
+ DECLARE_FIELDFUNC (cwsub_pitches_balls_hit_batter )
210
+ {
211
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
212
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_ball_hit_batter ));
213
+ }
214
+
215
+ /* Field 18 */
216
+ DECLARE_FIELDFUNC (cwsub_pitches_balls_other )
217
+ {
218
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
219
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_ball_other ));
220
+ }
221
+
222
+ /* Field 19 */
223
+ DECLARE_FIELDFUNC (cwsub_pitches_strikes )
224
+ {
225
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
226
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_strike_thrown ));
227
+ }
228
+
229
+ /* Field 20 */
230
+ DECLARE_FIELDFUNC (cwsub_pitches_strikes_called )
231
+ {
232
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
233
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_strike_called ));
234
+ }
235
+
236
+ /* Field 21 */
237
+ DECLARE_FIELDFUNC (cwsub_pitches_strikes_swinging )
238
+ {
239
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
240
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_strike_swinging ));
241
+ }
242
+
243
+ /* Field 22 */
244
+ DECLARE_FIELDFUNC (cwsub_pitches_strikes_foul )
245
+ {
246
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
247
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_strike_foul ));
248
+ }
249
+
250
+ /* Field 23 */
251
+ DECLARE_FIELDFUNC (cwsub_pitches_strikes_inplay )
252
+ {
253
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
254
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_strike_inplay ));
255
+ }
256
+
257
+ /* Field 24 */
258
+ DECLARE_FIELDFUNC (cwsub_pitches_strikes_other )
259
+ {
260
+ return sprintf (buffer , (ascii ) ? "%d" : "%02d" ,
261
+ cw_pitch_count_pitches (gameiter -> event -> pitches , cw_pitch_strike_other ));
262
+ }
263
+
140
264
static field_struct field_data [] = {
141
265
{ cwsub_game_id , "GAME_ID" , "game id" },
142
266
{ cwsub_inning , "INN_CT" , "inning" },
@@ -147,7 +271,22 @@ static field_struct field_data[] = {
147
271
{ cwsub_position , "SUB_FLD_CD" , "fielding position" },
148
272
{ cwsub_removed_player , "REMOVED_ID" , "removed player" },
149
273
{ cwsub_removed_position , "REMOVED_FLD_CD" , "position of removed player" },
150
- { cwsub_event_number , "EVENT_ID" , "event number" }
274
+ { cwsub_event_number , "EVENT_ID" , "event number" },
275
+ { cwsub_balls , "BALLS_CT" , "balls" },
276
+ { cwsub_strikes , "STRIKES_CT" , "strikes" },
277
+ { cwsub_pitches , "PITCH_SEQ_TX" , "pitch sequence" },
278
+ { cwsub_pitches_balls , "PA_BALL_CT" , "number of balls thrown in plate appearance" },
279
+ { cwsub_pitches_balls_called , "PA_CALLED_BALL_CT" , "number of called balls in plate appearance" },
280
+ { cwsub_pitches_balls_intentional , "PA_INTENT_BALL_CT" , "number of intentional balls in plate appearance" },
281
+ { cwsub_pitches_balls_pitchout , "PA_PITCHOUT_BALL_CT" , "number of pitchouts in plate appearance" },
282
+ { cwsub_pitches_balls_hit_batter , "PA_HITBATTER_BALL_CT" , "number of pitches hitting batter in plate appearance" },
283
+ { cwsub_pitches_balls_other , "PA_OTHER_BALL_CT" , "number of other balls in plate appearance" },
284
+ { cwsub_pitches_strikes , "PA_STRIKE_CT" , "number of strikes thrown in plate appearance" },
285
+ { cwsub_pitches_strikes_called , "PA_CALLED_STRIKE_CT" , "number of called strikes in plate appearance" },
286
+ { cwsub_pitches_strikes_swinging , "PA_SWINGMISS_STRIKE_CT" , "number of swinging strikes in plate appearance" },
287
+ { cwsub_pitches_strikes_foul , "PA_FOUL_STRIKE_CT" , "number of foul balls in plate appearance" },
288
+ { cwsub_pitches_strikes_inplay , "PA_INPLAY_STRIKE_CT" , "number of balls in play in plate appearance" },
289
+ { cwsub_pitches_strikes_other , "PA_OTHER_STRIKE_CT" , "number of other strikes in plate appearance" }
151
290
};
152
291
153
292
void
@@ -164,7 +303,7 @@ cwsub_process_game(CWGame *game, CWRoster *_visitors, CWRoster *_home)
164
303
comma = 0 ;
165
304
strcpy (output_line , "" );
166
305
buf = output_line ;
167
- for (i = 0 ; i < 10 ; i ++ ) {
306
+ for (i = 0 ; i <= max_field ; i ++ ) {
168
307
if (fields [i ]) {
169
308
if (ascii && comma ) {
170
309
* (buf ++ ) = ',' ;
0 commit comments