Mettre parenthèse dans un "if" en Batch/
Résolu
alexislucky
Messages postés
149
Date d'inscription
Statut
Membre
Dernière intervention
-
Richard.M Messages postés 105 Date d'inscription Statut Membre Dernière intervention -
Richard.M Messages postés 105 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'aimerai savoir :
Je veux creer un programme dans lequel il y a une condition et si celle si est remplie, le batch ecrit dans un fichier seulement voila :
Dans le texte que le batch va ecrire, il y a une parenthese dons le batch le lit comme la fin de la condition ce qui fout un brin monstre dans le script x)
Quelqu'un aurait-il une astuce pour mettre des parentheses dans une condition "if" ??
Merci d'avance
J'aimerai savoir :
Je veux creer un programme dans lequel il y a une condition et si celle si est remplie, le batch ecrit dans un fichier seulement voila :
Dans le texte que le batch va ecrire, il y a une parenthese dons le batch le lit comme la fin de la condition ce qui fout un brin monstre dans le script x)
Quelqu'un aurait-il une astuce pour mettre des parentheses dans une condition "if" ??
Merci d'avance
A voir également:
- Mettre parenthèse dans un "if" en Batch/
- Fichier batch - Guide
- Parenthese bizarre - Forum Clavier
- Parenthèse carré - Forum Bureautique
- Batch renommer une partie du nom de plusieurs fichiers ✓ - Forum Programmation
- Parenthèse clavier - Forum Logiciels
7 réponses
Voila :
cls
set choix_casque=1
echo.
echo.
echo Appuyez sur une touche pour generer un fichier test.sql dans le dossier test
echo contenant vos equipements ...
pause
if %choix_casque% NEQ 2 (
echo INSERT INTO item_template >> test.sql
echo (`entry`, `class`, `subclass`, `unk0`, `name`, `displayid`, `Quality`, `Flags` >> test.sql
echo ,`BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace` >> test.sql
echo , `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell` >> test.sql
echo , `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank` >> test.sql
echo , `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1` >> test.sql
echo , `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4` >> test.sql
echo ,`stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7` >> test.sql
echo ,`stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10` >> test.sql
echo ,`ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1` >> test.sql
echo ,`dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res` >> test.sql
echo , `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange` >> test.sql
echo , `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1` >> test.sql
echo , `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2` >> test.sql
echo , `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2` >> test.sql
echo , `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3` >> test.sql
echo , `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4` >> test.sql
echo , `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5` >> test.sql
echo , `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5` >> test.sql
echo , `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial` >> test.sql
echo , `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset` >> test.sql
echo , `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1` >> test.sql
echo , `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus` >> test.sql
echo , `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `Duration`, `ItemLimitCategory` >> test.sql
echo ,`HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`) VALUES >> test.sql
echo ('%id_casque%', 4, 6, -1, '%nom_casque%', '%display_casque%', '%Qualite_casque%', 0, 1, '%achat_casque%', '%vente_casque%', 1, '%classe_casque%', '%race_casque%', '%level_item_casque%', '%lvl_requis_casque%', 0, 0, 0, 0, 0, 0, 0, '%quantite_casque_par_player%', 1, 0, 0, '%stat1_casque%', '%valeur_stat1_casque%', '%stat2_casque%', '%valeur_stat2_casque%', '%stat3_casque%', '%valeur_stat3_casque%', '%stat4_casque%', '%valeur_stat4_casque%', '%stat5_casque%', '%valeur_stat5_casque%', '%stat6_casque%', '%valeur_stat6_casque%', '%stat7_casque%', '%valeur_stat7_casque%', '%stat8_casque%', '%valeur_stat8_casque%', '%stat9_casque%', '%valeur_stat9_casque%', '%stat10_casque%', '%valeur_stat10_casque%', 0, 0, 0, 0, 0, 0, 0, 0, '%armure_casque%', '%res_sacre_casque%', '%res_feu_casque%', '%res_nature_casque%', '%res_gele_casque%', '%res_ombre_casque%', '%res_arcane_casque%', 1000, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, '%citation_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, '%bloquage_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0); >> test.sql
echo. >> test.sql
)
pause
cls
set choix_casque=1
echo.
echo.
echo Appuyez sur une touche pour generer un fichier test.sql dans le dossier test
echo contenant vos equipements ...
pause
if %choix_casque% NEQ 2 (
echo INSERT INTO item_template >> test.sql
echo (`entry`, `class`, `subclass`, `unk0`, `name`, `displayid`, `Quality`, `Flags` >> test.sql
echo ,`BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace` >> test.sql
echo , `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell` >> test.sql
echo , `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank` >> test.sql
echo , `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1` >> test.sql
echo , `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4` >> test.sql
echo ,`stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7` >> test.sql
echo ,`stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10` >> test.sql
echo ,`ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1` >> test.sql
echo ,`dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res` >> test.sql
echo , `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange` >> test.sql
echo , `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1` >> test.sql
echo , `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2` >> test.sql
echo , `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2` >> test.sql
echo , `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3` >> test.sql
echo , `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4` >> test.sql
echo , `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5` >> test.sql
echo , `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5` >> test.sql
echo , `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial` >> test.sql
echo , `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset` >> test.sql
echo , `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1` >> test.sql
echo , `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus` >> test.sql
echo , `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `Duration`, `ItemLimitCategory` >> test.sql
echo ,`HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`) VALUES >> test.sql
echo ('%id_casque%', 4, 6, -1, '%nom_casque%', '%display_casque%', '%Qualite_casque%', 0, 1, '%achat_casque%', '%vente_casque%', 1, '%classe_casque%', '%race_casque%', '%level_item_casque%', '%lvl_requis_casque%', 0, 0, 0, 0, 0, 0, 0, '%quantite_casque_par_player%', 1, 0, 0, '%stat1_casque%', '%valeur_stat1_casque%', '%stat2_casque%', '%valeur_stat2_casque%', '%stat3_casque%', '%valeur_stat3_casque%', '%stat4_casque%', '%valeur_stat4_casque%', '%stat5_casque%', '%valeur_stat5_casque%', '%stat6_casque%', '%valeur_stat6_casque%', '%stat7_casque%', '%valeur_stat7_casque%', '%stat8_casque%', '%valeur_stat8_casque%', '%stat9_casque%', '%valeur_stat9_casque%', '%stat10_casque%', '%valeur_stat10_casque%', 0, 0, 0, 0, 0, 0, 0, 0, '%armure_casque%', '%res_sacre_casque%', '%res_feu_casque%', '%res_nature_casque%', '%res_gele_casque%', '%res_ombre_casque%', '%res_arcane_casque%', 1000, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, '%citation_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, '%bloquage_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0); >> test.sql
echo. >> test.sql
)
pause
J'avance, doucement, mais j'avance ...
Maintenant j'ai un autre probleme...
Quel que soit la condition, la tache est executée ...
voici le nouveau code source:
cls
set choix_casque=2
echo.
echo.
echo Appuyez sur une touche pour generer un fichier test.sql dans le dossier test
echo contenant vos equipements ...
pause
if/i "%choix_casque%NEQ"2"(
echo INSERT INTO item_template >> test.sql
echo (`entry`, `class`, `subclass`, `unk0`, `name`, `displayid`, `Quality`, `Flags`,`BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`,`stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`,`stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`,`ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1`,`dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `Duration`, `ItemLimitCategory`,`HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`) VALUES >> test.sql
echo ('%id_casque%', 4, 6, -1, '%nom_casque%', '%display_casque%', '%Qualite_casque%', 0, 1, '%achat_casque%', '%vente_casque%', 1, '%classe_casque%', '%race_casque%', '%level_item_casque%', '%lvl_requis_casque%', 0, 0, 0, 0, 0, 0, 0, '%quantite_casque_par_player%', 1, 0, 0, '%stat1_casque%', '%valeur_stat1_casque%', '%stat2_casque%', '%valeur_stat2_casque%', '%stat3_casque%', '%valeur_stat3_casque%', '%stat4_casque%', '%valeur_stat4_casque%', '%stat5_casque%', '%valeur_stat5_casque%', '%stat6_casque%', '%valeur_stat6_casque%', '%stat7_casque%', '%valeur_stat7_casque%', '%stat8_casque%', '%valeur_stat8_casque%', '%stat9_casque%', '%valeur_stat9_casque%', '%stat10_casque%', '%valeur_stat10_casque%', 0, 0, 0, 0, 0, 0, 0, 0, '%armure_casque%', '%res_sacre_casque%', '%res_feu_casque%', '%res_nature_casque%', '%res_gele_casque%', '%res_ombre_casque%', '%res_arcane_casque%', 1000, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, '%citation_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, '%bloquage_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0); >> test.sql
echo. >> test.sql
)
pause
Maintenant j'ai un autre probleme...
Quel que soit la condition, la tache est executée ...
voici le nouveau code source:
cls
set choix_casque=2
echo.
echo.
echo Appuyez sur une touche pour generer un fichier test.sql dans le dossier test
echo contenant vos equipements ...
pause
if/i "%choix_casque%NEQ"2"(
echo INSERT INTO item_template >> test.sql
echo (`entry`, `class`, `subclass`, `unk0`, `name`, `displayid`, `Quality`, `Flags`,`BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`,`stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`,`stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`,`ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1`,`dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `Duration`, `ItemLimitCategory`,`HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`) VALUES >> test.sql
echo ('%id_casque%', 4, 6, -1, '%nom_casque%', '%display_casque%', '%Qualite_casque%', 0, 1, '%achat_casque%', '%vente_casque%', 1, '%classe_casque%', '%race_casque%', '%level_item_casque%', '%lvl_requis_casque%', 0, 0, 0, 0, 0, 0, 0, '%quantite_casque_par_player%', 1, 0, 0, '%stat1_casque%', '%valeur_stat1_casque%', '%stat2_casque%', '%valeur_stat2_casque%', '%stat3_casque%', '%valeur_stat3_casque%', '%stat4_casque%', '%valeur_stat4_casque%', '%stat5_casque%', '%valeur_stat5_casque%', '%stat6_casque%', '%valeur_stat6_casque%', '%stat7_casque%', '%valeur_stat7_casque%', '%stat8_casque%', '%valeur_stat8_casque%', '%stat9_casque%', '%valeur_stat9_casque%', '%stat10_casque%', '%valeur_stat10_casque%', 0, 0, 0, 0, 0, 0, 0, 0, '%armure_casque%', '%res_sacre_casque%', '%res_feu_casque%', '%res_nature_casque%', '%res_gele_casque%', '%res_ombre_casque%', '%res_arcane_casque%', 1000, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, '%citation_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, '%bloquage_casque%', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0); >> test.sql
echo. >> test.sql
)
pause
tu peux peut-être essayé d'inclure tout ton texte dans une fonction qui l'affiche, genre "afficher_texte". Ensuite tu teste ta condition, puis si elle est valide tu fais appel a ta fonction. Du coup ton code sera déja plus clair et la parenthèse ne devrais pas posé problème. Si sa ne marche pas j'ai bien une autre solution, mais un peu plus compliqué qui consiste à imbriqué un while dans ton if: tu inclus ton texte dans une fonction, et à la fin tu met une variable " ok " à laquelle tu donne la valeur 0. ensuite tu test ta condition dans ton if, si elle est valide tu fais :
while(ok==1)
appel de la fonction
Du coup a la fin de ta fonction la variable ok est à 0 et on sort du while et ensuite du if sans problème si tous va bien.
Voilà j'espère que j'ai pu t'aider.
A+
while(ok==1)
appel de la fonction
Du coup a la fin de ta fonction la variable ok est à 0 et on sort du while et ensuite du if sans problème si tous va bien.
Voilà j'espère que j'ai pu t'aider.
A+
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Richard merci de ton aide mais j'ai reussi a le resoudre mais maintenant un autre probleme se pose : quelque soit la condition, la tache est executée ... je ne vois pas d'ou sa peut venir :s le code source est deux posts au dessus