Batch programming help

BLACKLIST_MEMBER

Well-known member
  • Feb 9, 2008
    37,854
    14,810
    113
    127.0.0.1
    machan kawru hari dannawada batch ekaka "set" command eken hadana variable ekaka (string) value eka, ea file eka run karana kena lawwa enter karana hati? :confused:

    i mean...

    Code:
    Set a=elakiri

    me vidiyata normally a kiyana variable eke value eka batch file eka athuledima autoset wenawane.. eath mata one ea value eka enter karanna kiyala user gen ahala, eetapasse value eka set karaganna vidiyak :)
    enter %value%...

    >_

    set a=%value%

    oya wage cn ekak mama qwe :confused:

    plz danna kenek innawanam ekata use karana line eka enna one kohomada kiyala kiyanna :)

    Thanks ;)
     

    pjayampathi

    Well-known member
  • Jan 20, 2008
    6,253
    39
    48
    @ECHO OFF
    CLS
    :LOOP
    ECHO A. Menu item A
    ECHO B. Menu item B
    ECHO C. Menu item C
    ECHO Q. Quit
    :: SET /P prompts for input and sets the variable
    :: to whatever the user types
    SET Choice=
    SET /P Choice=Type the letter and press Enter:
    :: The syntax in the next line extracts the substring
    :: starting at 0 (the beginning) and 1 character long
    IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
    ECHO.
    :: /I makes the IF comparison case-insensitive
    IF /I '%Choice%'=='A' GOTO ItemA
    IF /I '%Choice%'=='B' GOTO ItemB
    IF /I '%Choice%'=='C' GOTO ItemC
    IF /I '%Choice%'=='Q' GOTO End
    ECHO "%Choice%" is not valid. Please try again.
    ECHO.
    GOTO Loop
    :ItemA
    ECHO Insert commands for Item A.
    GOTO Again
    :ItemB
    ECHO Insert commands for Item B.
    GOTO Again
    :ItemC
    ECHO Insert commands for Item C.
    GOTO Again
    :Again
    PAUSE
    CLS
    GOTO Loop
    :End
     

    BLACKLIST_MEMBER

    Well-known member
  • Feb 9, 2008
    37,854
    14,810
    113
    127.0.0.1
    pjayampathi said:
    @ECHO OFF
    CLS
    :LOOP
    ECHO A. Menu item A
    ECHO B. Menu item B
    ECHO C. Menu item C
    ECHO Q. Quit
    :: SET /P prompts for input and sets the variable
    :: to whatever the user types
    SET Choice=
    SET /P Choice=Type the letter and press Enter:
    :: The syntax in the next line extracts the substring
    :: starting at 0 (the beginning) and 1 character long
    IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
    ECHO.
    :: /I makes the IF comparison case-insensitive
    IF /I '%Choice%'=='A' GOTO ItemA
    IF /I '%Choice%'=='B' GOTO ItemB
    IF /I '%Choice%'=='C' GOTO ItemC
    IF /I '%Choice%'=='Q' GOTO End
    ECHO "%Choice%" is not valid. Please try again.
    ECHO.
    GOTO Loop
    :ItemA
    ECHO Insert commands for Item A.
    GOTO Again
    :ItemB
    ECHO Insert commands for Item B.
    GOTO Again
    :ItemC
    ECHO Insert commands for Item C.
    GOTO Again
    :Again
    PAUSE
    CLS
    GOTO Loop
    :End

    Thanks a alot machanz :D