MSFN Forum: synax incorrect - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

synax incorrect I am making a game maker which exports .bat Rate Topic: -----

#1 User is offline   faissaloo 

  • Newbie
  • Group: Members
  • Posts: 18
  • Joined: 26-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 26 December 2011 - 04:45 AM

well, I am making a program called batty, it is a batch game maker, I am adding questions and this is the code that it exports:
CHOICE /C YN /M "hi"
IF errorlevel==1

i get the error:

Quote

synax of command is incorrect
HEEEEEEELP!!!



#2 User is offline   5eraph 

  • Update Packrat
  • Group: Supreme Sponsor
  • Posts: 816
  • Joined: 04-July 05
  • OS:XP Pro x64
  • Country: Country Flag

Posted 26 December 2011 - 08:43 AM

I have found ss64.com to be a very useful free resource for batch scripting.

#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 26 December 2011 - 10:19 AM

%ERRORLEVEL%

#4 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,111
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 26 December 2011 - 11:20 AM

You can have (in 2K/XP etc.)

Quote

IF ERRORLEVEL 1 ...

(old "DOS" style)
or

Quote

IF %ERRORLEVEL%==1 ....

(new NT style)

http://www.robvander.../errorlevel.php

The second won't work in DOS.

It depends on the intended OS, since CHOICE was used, I presume DOS, otherwise SET /P is the normal NT way to have choices.

http://www.robvander...m/userinput.php

jaclaz

#5 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 26 December 2011 - 11:43 AM

Choice made a return in Windows 7;
Posted Image

#6 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,111
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 26 December 2011 - 11:51 AM

View PostYzöwl, on 26 December 2011 - 11:43 AM, said:

Choice made a return in Windows 7;

Good to know! :) :thumbup

jaclaz

#7 User is offline   myselfidem 

  • 2 Slow 4 You
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,753
  • Joined: 06-January 10
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 26 December 2011 - 12:35 PM

Same command prompt but with French language:

Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tous droits réservés.

C:\Users\Antoine>choice /?

CHOICE [/C choix] [/N] [/CS] [/T délai /D choix] [/M texte]

Description :
    Cet outil permet aux utilisateurs de sélectionner un élément d'une liste
    de choix et renvoie l'index du choix sélectionné.

Liste de paramètres :
   /C    choix         Spécifie la liste des choix à créer.
                       La liste par défaut est "ON".

   /N                  Masque la liste des choix dans l'invite de commande.
                       Le message avant l'invite de commande est affiché
                       et les choix restent activés.

   /CS                 Permet la sélection de choix respectant la casse.
                       Par défaut, l'utilitaire ne respecte pas la casse.

   /T    délai         Nombre de secondes de suspension avant
                       d'effectuer un choix par défaut. Les valeurs acceptables

                       sont comprises entre 0 et 9999. Si 0 est spécifié,
                       le choix par défaut sera sélectionné sans suspension.

   /D    choix         Spécifie le choix par défaut après nnnn secondes.
                       Le caractère doit être compris dans les choix spécifiés
                       par l'option /C et doit également spécifier nnnn avec /T.


   /M    texte         Spécifie l'affichage du message avant   l'invite de
                       commande. Si l'option n'est pas spécifiée, l'utilitaire
                       affiche uniquement une invite de commande.

   /?                  Affiche ce message d'aide.

   Remarque :
   La variable d'environnement ERRORLEVEL est définie à l'index de la
   clé sélectionnée dans l'ensemble de choix. Le premier choix
   listé renvoie la valeur 1, le second renvoie la valeur 2, etc.
   Si l'utilisateur appuie sur une touche ne représentant pas un choix valide,
   l'outil  émet un signal sonore d'avertissement. Si l'outil détecte une
   condition d'erreur, il renvoie une valeur ERRORLEVEL de 255.
   Si l'utilisateur appuie sur CTRL+Pause ou CTRL+C, l'outil renvoie
   une valeur ERRORLEVEL de 0. Lorsque vous utilisez les paramètres
   ERRORLEVEL dans un programme de commandes,
    vous devez les lister par ordre décroissant.

Exemples :
   CHOICE /?
   CHOICE /C ONA /M "Appuyez sur O pour Oui, N pour Non ou A pour Annuler."
   CHOICE /T 10 /C ona /CS /D o
   CHOICE /C ab /M "Sélectionnez a pour l'option 1 et b pour l'option 2."
   CHOICE /C ab /N /M "Sélectionnez a pour l'option 1 et b pour l'option 2."

C:\Users\Antoine>


This post has been edited by myselfidem: 27 December 2011 - 08:04 AM


#8 User is offline   faissaloo 

  • Newbie
  • Group: Members
  • Posts: 18
  • Joined: 26-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 26 December 2011 - 01:54 PM

I still get the error :wacko:

#9 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 26 December 2011 - 05:02 PM

Try this to see how it works:
@ECHO OFF
CHOICE /C YN /M "PLEASE MAKE YOUR CHOICE"
IF %ERRORLEVEL%==2 (
	ECHO.
	ECHO YOU SELECTED [N]
)
IF %ERRORLEVEL%==1 (
	ECHO.
	ECHO YOU SELECTED [Y]
)
ECHO.
PAUSE


#10 User is offline   faissaloo 

  • Newbie
  • Group: Members
  • Posts: 18
  • Joined: 26-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 27 December 2011 - 03:41 AM

your code worked perfectly :thumbup , now I just need to get it working in batty.
edit: not working, here is the exported code:
echo HELP
CHOICE /C YN /M "Help him"
IF %errorlevel%==1(

: save
echo thank you
pause
echo you got 10 points
set points=10)

This post has been edited by faissaloo: 27 December 2011 - 04:01 AM


#11 User is offline   myselfidem 

  • 2 Slow 4 You
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,753
  • Joined: 06-January 10
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 27 December 2011 - 03:55 AM

If I want the batch working - like this - on my computer I need to browse on my profile:

@ECHO OFF
cd C:\
cd %userprofile% 
CHOICE /C YN /M "PLEASE MAKE YOUR CHOICE"

IF %ERRORLEVEL%==2 (        
      ECHO.        
      ECHO YOU SELECTED [N]
)

IF %ERRORLEVEL%==1 (        
      ECHO.        
      ECHO YOU SELECTED [Y]
)

ECHO.
PAUSE


This post has been edited by myselfidem: 27 December 2011 - 04:06 AM


#12 User is offline   myselfidem 

  • 2 Slow 4 You
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,753
  • Joined: 06-January 10
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 27 December 2011 - 04:21 AM

View Postfaissaloo, on 27 December 2011 - 03:41 AM, said:

edit: not working, here is the exported code:
echo HELP
CHOICE /C YN /M "Help him"
IF %errorlevel%==1(

: save
echo thank you
pause
echo you got 10 points
set points=10)



You can try like this:

@echo off
echo HELP
CHOICE /C YN /M "Help him"


IF %ERRORLEVEL%==2 goto :exit
IF %ERRORLEVEL%==1 goto :save

:save
echo thank you
pause
echo you got 10 points

set points=10
pause

:exit


This post has been edited by myselfidem: 27 December 2011 - 08:03 AM


#13 User is offline   faissaloo 

  • Newbie
  • Group: Members
  • Posts: 18
  • Joined: 26-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 27 December 2011 - 04:39 AM

View Postmyselfidem, on 27 December 2011 - 04:21 AM, said:

View Postfaissaloo, on 27 December 2011 - 03:41 AM, said:

edit: not working, here is the exported code:
echo HELP
CHOICE /C YN /M "Help him"
IF %errorlevel%==1(

: save
echo thank you
pause
echo you got 10 points
set points=10)



You can try like this:

@echo off
echo HELP
CHOICE /C YN /M "Help him"


IF %ERRORLEVEL%==2 goto :exit
IF %ERRORLEVEL%==1 goto :save

: save
echo thank you
pause
echo you got 10 points

set points=10
pause

:exit



does not work, my current code:

echo help me

cd C:\

cd %userprofile% 

CHOICE /C YN /M "would you like to help him?"

IF %errorlevel%==1

echo thank you, here is ten coins for your help

echo you got ten coins

set %coins%=10

pause

: save

View Postmyselfidem, on 27 December 2011 - 03:55 AM, said:

If I want the batch working - like this - on my computer I need to browse on my profile:

@ECHO OFF
cd C:\
cd %userprofile% 
CHOICE /C YN /M "PLEASE MAKE YOUR CHOICE"

IF %ERRORLEVEL%==2 (        
      ECHO.        
      ECHO YOU SELECTED [N]
)

IF %ERRORLEVEL%==1 (        
      ECHO.        
      ECHO YOU SELECTED [Y]
)

ECHO.
PAUSE



still getting the error, here is my current code
echo help me
cd C:\
cd %userprofile% 
CHOICE /C YN /M "would you like to help him?"
IF %errorlevel%==1(

echo thank you, here is ten coins for your help
echo you got ten coins
set coins=10
pause
: save)


#14 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,111
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 27 December 2011 - 04:46 AM

faissaloo
check ATTENTIVELY what has been posted.

Quote

IF %errorlevel%==1[SPACE](


jaclaz

#15 User is offline   faissaloo 

  • Newbie
  • Group: Members
  • Posts: 18
  • Joined: 26-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 27 December 2011 - 07:11 AM

View Postjaclaz, on 27 December 2011 - 04:46 AM, said:

faissaloo
check ATTENTIVELY what has been posted.

Quote

IF %errorlevel%==1[SPACE](


jaclaz

thanks it is working now. ;)

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy