In the variable x I will enter the folder name. Further, the program in a certain place, for example, in folder 3 ( C:\папка1\папка2\папка3 ) should create a folder with the name I entered.
For example, it is not clear to me how to "associate" a variable with the MkDir function and where to write the path C:\папка1\папка2\папка3 ?

What in this code to add and / or change?

 var x : string; begin Writeln('название папки?'); Readln(x); MkDir() end. 
  • @Ivan777, To format the code, select it with the mouse and click on the button 101010 of the editor. - angry

2 answers 2

Try this:

 var x,y : string; begin y := 'c:\папка1\папка2\папка3'; Writeln('название папки?'); Readln(x); MkDir(y+'\'+x) end. 
  • @Ivan777, it was not necessary to award a single point, it was enough just to press the button above the number next to the answer. - insolor
  • He gave me another 2 :) - Artem
  • I was glad to obscenely therefore I gave everything that I had. Rewarding balls is bad or bad is that small? "press the button above the number next to the answer" - of course I pressed, only that this pressing would have weight, you need at least 15 respect points, and not mine some miserable 3. In general, of course, many thanks for the answer, because on other resources I answered So through Gugul I can find. - Ivan Nikolaevich
  • @ Ivan777, just for me and @Shrek 1-2 points - this is like a pellet for an elephant, but you would still need it :) - insolor pm

Another good rule is that the program does not crash to do a check.

 begin {$I-} // отключаем системную проверку Writeln('название папки?'); Readln(x); MkDir(x); // в текущей директории создаст. if IOResult <> 0 then WriteLn('Не могу создать папку.') else WriteLn('Папка создана!'); {$I+} end. 

In general, in Pascal, you need to constantly do such a check, turn off the system one and add your own, otherwise the program will constantly crash with a critical error. I know from my own experience for 4 years of programming on it. In the place where the folder cannot be created, you can return the user with the help of goto to the place where the folder name is entered. In general, check everything and always when you use system things.

ps @insolor about how to link a folder and a variable.