Image Map Image Map
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Menu maker / batch file?

  1. #1

    Default Menu maker / batch file?

    Hi all,

    In Linux, this would be an easy task, but in DOS, not so simple for me (either because I may have forgotten how to do this sort of stuff, or because you can't do it with simple batch scripts).

    I have a text file, 5 columns: column 1 has a unique ID number, column 2 has the name of a BBS I want to connect to, column 3 has the telnet hostname for the BBS, column 4 has the appropriate port number. I also have a fifth column with notes which isn't of much consequence, but could be displayed if needed.

    The idea of the batch file is simple:
    1) Display the contents of each line of the text file.
    2) Ask for input for the user for the number of the unique ID related to the BBS I want to connect to
    3) Execute mtelnet <hostname> <portnum>

    I've looked at menu makers on google for a while as well, but couldn't find anything that would do what I need. If

    Thanks in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Dublin, CA USA
    Posts
    2,926
    Blog Entries
    1

    Default

    I don't think you can do exactly that with a batch file, though others may correct me on this. I'd look to do it in basic with Quick Basic.

    IBM 5160 - 360k, 1.44Mb Floppies, NEC V20, 8087-3, 45MB MFM Hard Drive, Vega 7 Graphics, IBM 5154 Monitor running MS-DOS 5.00
    IBM PCJr Model 48360 640kb RAM, NEC V20,, jrIDE Side Cart, 360kb Floppy drives running MS-DOS 5.00
    Evergreen Am5x86-133 64Mb Ram, 8gb HDD, SB16 in a modified ATX case running IBM PC-DOS 7.10

  3. #3
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,613
    Blog Entries
    18

    Default

    Not DOS batch, per se, but a good old add-on, called CENVID. Basically, interpreted C as a batch program. I used it a lot back in the day.

    Here's an example, HEXDUMP.BAT:

    Code:
    @echo off
    REM **********************************************************************
    REM *** HexDump.bat - Hexidecimal dump of the contents of a file. This ***
    REM ***               examples program uses the CEnvi file routines.   ***
    REM **********************************************************************
    cenvi %0.bat %1 %2
    GOTO CENVI_EXIT
    
    main(argc,argv)
    {
       if ( 2 != argc ) {
          Instructions()
       } else if ( NULL == (fp = fopen(argv[1],"rb")) ) {
          printf("Could not open file \"%s\" for hex output.\a\n",argv[1])
       } else {
          dump(fp)
          fclose(fp)
       }
    }
    
    dump(file)
    {
       Unprintables = "\a\b\t\r\n\032\033"
       for ( offset = 0; 0 < (count = fread(data,16,file)); offset += 16 ) {
          // display hex offset in file
          printf("%06X  ",offset)
          // display hex value for each number
          for ( i = 0; i < count; i++ )
             printf("%02X ",data[i])
          // fill in any extra gaps if count < 16
          while( i++ < 16 )
             printf("   ")
          // display ascii value for each printable character
          // substitute a period for unprintable characters
          data[count] = 0; // string must be null-terminated
          while( (UnprintableIndex = strcspn(data,Unprintables)) < count )
             data[UnprintableIndex] = '.';
          printf("   %s\n",data)
          if ( count < 16 )
             break
       }
    }
    
    :CENVI_EXIT

  4. #4
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    4,744
    Blog Entries
    1

    Default

    Might be able to do it with DOS 6's CHOICE command. Something like

    Code:
    TYPE phonenum.txt
    CHOICE /C:1234 "ENTER NUMBER TO CALL"
    IF ERRORLEVEL 1 GOTO ONE
    
    :ONE
    metelnet <correct command line>
    GOTO END
    
    :END
    Each command line would need to be set up manually with this example and additional ERRORLEVEL branches for each line in the text file would be needed.

  5. #5
    Join Date
    Mar 2009
    Location
    Dublin, CA USA
    Posts
    2,926
    Blog Entries
    1

    Default

    Quote Originally Posted by krebizfan View Post
    Might be able to do it with DOS 6's CHOICE command. Something like

    Code:
    TYPE phonenum.txt
    CHOICE /C:1234 "ENTER NUMBER TO CALL"
    IF ERRORLEVEL 1 GOTO ONE
    
    :ONE
    metelnet <correct command line>
    GOTO END
    
    :END
    Each command line would need to be set up manually with this example and additional ERRORLEVEL branches for each line in the text file would be needed.
    This would not read and display the options from OP's text file and ask for a choice from the user. I am reasonably sure you could not do that in a batch file. So other tools would be needed, such as what Chuck suggests or writing it in a language of some sort (Basic, Pascal, C etc).

    IBM 5160 - 360k, 1.44Mb Floppies, NEC V20, 8087-3, 45MB MFM Hard Drive, Vega 7 Graphics, IBM 5154 Monitor running MS-DOS 5.00
    IBM PCJr Model 48360 640kb RAM, NEC V20,, jrIDE Side Cart, 360kb Floppy drives running MS-DOS 5.00
    Evergreen Am5x86-133 64Mb Ram, 8gb HDD, SB16 in a modified ATX case running IBM PC-DOS 7.10

  6. #6
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,613
    Blog Entries
    18

    Default

    Also, if you're used to using bash or the bourne shell in Linux, there are ports to DOS.

  7. #7
    Join Date
    Aug 2009
    Location
    Oslo, Norway
    Posts
    1,360
    Blog Entries
    3

    Default

    For number 1: why not simply TYPE the text file?
    Torfinn

  8. #8
    Join Date
    Mar 2009
    Location
    Dublin, CA USA
    Posts
    2,926
    Blog Entries
    1

    Default

    Quote Originally Posted by tingo View Post
    For number 1: why not simply TYPE the text file?
    I think OP wants to use the text file as the menu items list and not re-create it in the batch file. So just typing it would display the contents, but then you'd have to build in a ton of if statements to accommodate the input Doing this could work, but it would double the work needed to add or remove anything.

    IBM 5160 - 360k, 1.44Mb Floppies, NEC V20, 8087-3, 45MB MFM Hard Drive, Vega 7 Graphics, IBM 5154 Monitor running MS-DOS 5.00
    IBM PCJr Model 48360 640kb RAM, NEC V20,, jrIDE Side Cart, 360kb Floppy drives running MS-DOS 5.00
    Evergreen Am5x86-133 64Mb Ram, 8gb HDD, SB16 in a modified ATX case running IBM PC-DOS 7.10

  9. #9
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    4,744
    Blog Entries
    1

    Default

    The truly easy way would be if the program had its own macro language that accepted command line switches. Then one could
    TYPE the data file
    CHOICE the line to launch
    PROGRAM launch-macro errorlevel from choice which would start the program using the matching line

    Everything else would require some effort; either to build the conditional responses or to parse the data structure to create a command line.

  10. #10
    Join Date
    Mar 2009
    Location
    Dublin, CA USA
    Posts
    2,926
    Blog Entries
    1

    Default

    Quote Originally Posted by krebizfan View Post
    The truly easy way would be if the program had its own macro language that accepted command line switches. Then one could
    TYPE the data file
    CHOICE the line to launch
    PROGRAM launch-macro errorlevel from choice which would start the program using the matching line

    Everything else would require some effort; either to build the conditional responses or to parse the data structure to create a command line.
    How would this work is the data file contained more than 35 CHOICEs ?

    IBM 5160 - 360k, 1.44Mb Floppies, NEC V20, 8087-3, 45MB MFM Hard Drive, Vega 7 Graphics, IBM 5154 Monitor running MS-DOS 5.00
    IBM PCJr Model 48360 640kb RAM, NEC V20,, jrIDE Side Cart, 360kb Floppy drives running MS-DOS 5.00
    Evergreen Am5x86-133 64Mb Ram, 8gb HDD, SB16 in a modified ATX case running IBM PC-DOS 7.10

Tags for this Thread

Bookmarks

Posting Permissions

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