Subversion Repositories svn1-original

Rev

Rev 46 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46 Rev 54
Line 57... Line 57...
57
unsigned char manstart;                          /* Manual start time entry */
57
unsigned char manstart;                          /* Manual start time entry */
58
 
58
 
59
 
59
 
60
menu_table  sup_menu[] = {
60
menu_table  sup_menu[] = {
61
    { '1', "Load team information from external file", tupload },
61
    { '1', "Load team information from external file", tupload },
-
 
62
    { '2', "Store team information from external file", tdnload_store },
62
    { '2', "Create external team information file", tdnload },
63
    { '3', "Create external team information file", tdnload },
63
    { '3', "Create external leg data file", dnload },
64
    { '4', "Create external leg data file", dnload },
64
    { '4', "Upload time information", upload },
65
    { '5', "Upload time information", upload },
65
    { 'q', "Return to main menu", 0 },
66
    { 'q', "Return to main menu", 0 },
66
    { '\0' }
67
    { '\0' }
67
};
68
};
68
 
69
 
69
/*========================================================================
70
/*========================================================================
Line 350... Line 351...
350
 
351
 
351
        /*
352
        /*
352
        **  The first entry on the line should be team number
353
        **  The first entry on the line should be team number
353
        **  If it is not a valid team number then skip
354
        **  If it is not a valid team number then skip
354
        */
355
        */
355
 
-
 
356
        if( ! t_parse_number( &linep, &team ) )
356
        if( ! t_parse_number( &linep, &team ) )
357
        {
357
        {
358
            printf( "No team number: %-30s.\n", line );
358
            printf( "No team number: %-30s.\n", line );
359
            error++;
359
            error++;
360
        }
360
        }
Line 479... Line 479...
479
 
479
 
480
bool t_parse_number( char **linep, int *number )
480
bool t_parse_number( char **linep, int *number )
481
{
481
{
482
    long    lnumber;
482
    long    lnumber;
483
    char    *work = *linep;
483
    char    *work = *linep;
-
 
484
    char    *endp;
484
 
485
 
485
    /*
486
    /*
486
    **  Expecting a number
487
    **  Extract data from the CSV field
487
    **  strtol will remove leading white space
488
    **  May need to remove quotes
-
 
489
    **  Use temp work space
488
    */
490
    */
489
    lnumber = strtol( work, &work, 10 );
491
    t_parse_text( &work, line_text);
490
 
492
 
491
    /*
493
    /*
492
    **  Skip the trailing delimiter(s)
494
    **  Expecting a number
-
 
495
    **  strtol will remove leading white space
493
    */
496
    */
494
    while ( p_del(work) )
497
    lnumber = strtol( line_text, &endp, 10 );
495
    {
-
 
496
        work++;
-
 
497
    }
-
 
498
 
498
 
499
    /*
499
    /*
500
    **  A valid number ?
500
    **  A valid number ?
-
 
501
    **  All the field must be numeric, otherwise it wasn't a number
501
    */
502
    */
502
    if ( lnumber == 0 )
503
    if ( lnumber == 0 || *endp  )
503
        return FALSE;
504
        return FALSE;
504
 
505
 
505
    *number = (int) lnumber;
506
    *number = (int) lnumber;
506
    *linep = work;
507
    *linep = work;
507
    return TRUE;
508
    return TRUE;
Line 576... Line 577...
576
            continue;
577
            continue;
577
        }
578
        }
578
 
579
 
579
 
580
 
580
        /*
581
        /*
581
        **  A quoted " may be en embedded quote or the end of a quote
582
        **  A quoted " may be an embedded quote or the end of a quote
582
        */
583
        */
583
        if ( quoted && uch == '"' )
584
        if ( quoted && uch == '"' )
584
        {
585
        {
585
            if ( **linep != '"' )
586
            if ( **linep != '"' )
586
            {
587
            {
Line 638... Line 639...
638
/*========================================================================
639
/*========================================================================
639
 *
640
 *
640
 *  Generate team name file
641
 *  Generate team name file
641
 *
642
 *
642
 *  Purpose:
643
 *  Purpose:
-
 
644
 *      This function is called to Generate team name file in the format
-
 
645
 *      that can be read by the load command
-
 
646
 *
-
 
647
 *      The file contains team number,Team name,Team class
-
 
648
 *      The operator is prompted to enter the name of the file
-
 
649
 *
-
 
650
 *  Parameters:
-
 
651
 *      None
-
 
652
 *
-
 
653
 *  Returns:
-
 
654
 *      Nothing
-
 
655
 *
-
 
656
 *========================================================================*/
-
 
657
 
-
 
658
void tdnload_store(void)
-
 
659
{
-
 
660
    int         i;
-
 
661
    int         j;
-
 
662
 
-
 
663
    cur( 0, 5 );
-
 
664
    printf( "Create text file of team information" );
-
 
665
 
-
 
666
    if( !getfname( "Enter name of the file to create :", ".csv.txt" ) )
-
 
667
        return;
-
 
668
    printf( "\n" );
-
 
669
 
-
 
670
    /*
-
 
671
    **  Open printer, with known filename
-
 
672
    */
-
 
673
    if( !open_printer_name( ufilename, 2000, FALSE, NULL ) )
-
 
674
    {
-
 
675
        beep();
-
 
676
        sleep( 5 );
-
 
677
        return;
-
 
678
    }
-
 
679
 
-
 
680
    /*
-
 
681
    **  Print headings
-
 
682
    */
-
 
683
    csv_print( "%s",   "Team Number" );
-
 
684
    csv_print( "%s",   "Team Name" );
-
 
685
    csv_print( "%s",   "Class Abr");
-
 
686
 
-
 
687
    for( j = 1; j <= config.num_legs; j++ )
-
 
688
    {
-
 
689
        csv_print( "%s", "Competitor Name");
-
 
690
        csv_print( "%s", "Age");
-
 
691
    }
-
 
692
    csv_print("\n");
-
 
693
 
-
 
694
    /*
-
 
695
     * Put the data into the file
-
 
696
     */
-
 
697
 
-
 
698
    for( i = config.min_team; i <= config.max_team; i++ )
-
 
699
    {
-
 
700
        if( valid_field( i ) && g_record( i, &team_buf ) )
-
 
701
        {
-
 
702
            /*
-
 
703
            **  Basic information
-
 
704
            **      - Team number
-
 
705
            **      - Full team name
-
 
706
            */
-
 
707
            csv_print( "%d",   team_buf.numb );
-
 
708
            csv_print( "%s",   team_buf.name );
-
 
709
            csv_print( "%s",    team_buf.class == 0 ? "" : config.team_class[team_buf.class - 1].abr );
-
 
710
            for( j = 1; j <= config.num_legs; j++ )
-
 
711
            {
-
 
712
                csv_print( "%s", team_buf.members[j-1].name );
-
 
713
                csv_print( "%d", team_buf.members[j-1].age );
-
 
714
            }
-
 
715
            csv_print( "\n" );
-
 
716
        }
-
 
717
    }
-
 
718
    close_printer();
-
 
719
}
-
 
720
 
-
 
721
/*========================================================================
-
 
722
 *
-
 
723
 *  Generate team name file
-
 
724
 *
-
 
725
 *  Purpose:
643
 *      This function is called to Generate team name file
726
 *      This function is called to Generate team name file
644
 *
727
 *
645
 *      The file contains team number,Team name,Team class
728
 *      The file contains team number,Team name,Team class
646
 *      The operator is prompted to enter the name of the file
729
 *      The operator is prompted to enter the name of the file
647
 *
730
 *
Line 672... Line 755...
672
        sleep( 5 );
755
        sleep( 5 );
673
        return;
756
        return;
674
    }
757
    }
675
 
758
 
676
    /*
759
    /*
677
     * Put the data into the file 
760
     * Put the data into the file
678
     */
761
     */
679
 
762
 
680
    for( i = config.min_team; i <= config.max_team; i++ )
763
    for( i = config.min_team; i <= config.max_team; i++ )
681
    {
764
    {
682
        if( valid_field( i ) && g_record( i, &team_buf ) )
765
        if( valid_field( i ) && g_record( i, &team_buf ) )
Line 726... Line 809...
726
 
809
 
727
    }
810
    }
728
 
811
 
729
 
812
 
730
    /*
813
    /*
731
     * Find out if Start or End of leg times to be saved 
814
     * Find out if Start or End of leg times to be saved
732
     */
815
     */
733
 
816
 
734
    do
817
    do
735
    {
818
    {
736
        d_field( 0, 7, "Start of End of leg to save :", D_USTRING, 1, stend,
819
        d_field( 0, 7, "Start of End of leg to save :", D_USTRING, 1, stend,
737
                 TRUE, M_UPDATE );
820
                 TRUE, M_UPDATE );
738
    } while( ( stend[0] != 'S' ) && ( stend[0] != 'E' ) );
821
    } while( ( stend[0] != 'S' ) && ( stend[0] != 'E' ) );
739
    manstart = ( stend[0] == 'S' ? TRUE : FALSE );
822
    manstart = ( stend[0] == 'S' ? TRUE : FALSE );
740
 
823
 
741
    /*
824
    /*
742
     * Locate the required data file and prepare for processing 
825
     * Locate the required data file and prepare for processing
743
     */
826
     */
744
 
827
 
745
    printf( "\n" );
828
    printf( "\n" );
746
    sprintf( ufilename, ( manstart ? "Sleg%d" : "leg%d" ), leg );   /* Create the file name */
829
    sprintf( ufilename, ( manstart ? "Sleg%d" : "leg%d" ), leg );   /* Create the file name */
747
    ufile = fopen( ufilename, "wt" );             /* Open the file for writing */
830
    ufile = fopen( ufilename, "wt" );             /* Open the file for writing */
Line 752... Line 835...
752
        sleep( 5 );
835
        sleep( 5 );
753
        return;
836
        return;
754
    }
837
    }
755
 
838
 
756
    /*
839
    /*
757
     * Write the data to the data file 
840
     * Write the data to the data file
758
     */
841
     */
759
 
842
 
760
    for( i = config.min_team; i <= config.max_team; i++ )
843
    for( i = config.min_team; i <= config.max_team; i++ )
761
    {
844
    {
762
        if( valid_field( i ) && g_record( i, &team_buf ) )
845
        if( valid_field( i ) && g_record( i, &team_buf ) )