|
|
|||||||
| About Us | Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
|
i have started to play around with dos and batch files
can anyone help me with this probelm ok i want a batch file that would do something like this please enter you name {person types there name it} hello {what ever the name was they typed in} ! end of file i know this is probably very easy to do and someone will hopefully answer this very quickly but hey every one has to start some were ! |
|
|
|
|
|
#8 (permalink) |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Aug 2002
Location: somewhere
Posts: 8,636
|
Re: a quick quiestion with an easy answer !
Thats the problem, I dont know MSDOS, but I thought you might find it useful
At any rate, I wrote it using C++ here the code for your convenience ![]() edit: the code looks messed up here, I ll attach the source file itself. Yours, -Elly
__________________
-= Now watching=-
Last edited by _E_; September 28th, 2003 at 17:08. |
|
|
|
|
|
#10 (permalink) |
|
Registered User
![]() Join Date: Jul 2003
Location: Los Angeles
Posts: 53
|
Re: a quick quiestion with an easy answer !
Well, it's not really - that I know of, even with extended NT batch commands - possible. I might be wrong though, in which case you should look at www.microsoft.com.
If you want to do things that complicated, it's better to use a programming language - not a scripting language. (batch is scripting, it's not compiled.) I recommend QuickBasic or C++ for beginners, both of which you can find for free with a simple Google search. It *MAY* be possible to do a loop, with a choice comand, and append it onto an environment variable, until which time they press enter. But that would be a royal pain. -[Unknown] |
|
|
|
|
|
#11 (permalink) |
|
Ramsus K
![]() ![]() ![]() Join Date: Mar 2003
Location: Oklahoma
Posts: 461
|
Re: a quick quiestion with an easy answer !
DOS Batch scripts are NOT intended for general programming. No shell scripting/batch language is.
For general programming and doing day-to-day tasks where you just want to get things done with no hassle, I'd suggest learning Perl. It's a very good general purpose scripting language that can do a lot of things very quickly and easily. *EDIT: As far as learning programming, I believe Python would be an excellent place to start. Java is very nice as well. Both languages are relatively simple and elegant, both are object oriented (Python is also a Functional language), and both have very large support libraries you can use. QBASIC is so outdated that finding help would be a pain, and C++ is a large and overwhelming language. Although, I have to admit that C++ was my first language. Also, [Unknown], there are lots of good scripting languages(i.e. interpreted) that are full-fledged programming languages. Being compiled has nothing to do with it. Last edited by RamsusX; September 28th, 2003 at 22:22. |
|
|
|
|
|
#12 (permalink) | |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Aug 2002
Location: somewhere
Posts: 8,636
|
Re: a quick quiestion with an easy answer !
Quote:
)Yours, -Elly
__________________
-= Now watching=-
|
|
|
|
|
|
|
#13 (permalink) |
|
Registered User
![]() Join Date: Jul 2003
Location: Los Angeles
Posts: 53
|
Re: a quick quiestion with an easy answer !
True, but you named a lot of scripting languages that won't fit the job description in dos.
QBASIC is definitely quite old, and will not fit the job description either. It could be considered a scripting language itself, since it does not compile. However, QuickBASIC is a programming language. It is actually pretty good for newbies, and it works on any DOS or NT operating system. Help can also be found for it, although you are right that it is old. Python, Perl, and even PHP are great scripting languages that could do what he asked - if they ran on DOS. Sadly, they do not... at least, in most cases. They run great on linux, and can be made to run on NT.... but... that's not what he asked for. C++ can be simple if you use it for simple things... and exe's made with it will work on dos. Java is a different case. Because it does not compile to an exe, it also does not fit the job description - although it does compile. Again, we're looking for something that talks, walks, and breathes like a batch file. QuickBASIC was the least complicated example I could come up with... You'd just do this: LINE INPUT "What's your name? ", $name PRINT "Hello "; $name; "!" (if I remember right, it's been years... but that was my first language, it still has a user base, and it has a good help file.) ****ens books are old - does that mean they are useless? That no one can read them, or that no one knows what they mean anymore? I do, however, agree that it is outdated - it's just that it does happen to work nicely, imho, for this situation. -[Unknown] |
|
|
|
|
|
#14 (permalink) |
|
Ramsus K
![]() ![]() ![]() Join Date: Mar 2003
Location: Oklahoma
Posts: 461
|
Re: a quick quiestion with an easy answer !
[Unknown]: Looks like I missed the part about DOS.
In that case, QBASIC is just fine for getting the job done. Using QBASIC outside of real-mode DOS might not be the best option. After all, DOS programs on a 386 can make use of Protected mode (either using a DOS extender or setting things up itself), and a number of scripting languages and UNIX tools have been ported to protected mode DOS. As far as C++ development on DOS goes, there are currently two good and free C++ compilers for DOS available: GCC (DJGPP) and Borland's Turbo C++. DJGPP only allows you to create protected-mode DOS programs, which require a 386 or higher to run. Turbo C++ only allows you to create 16-bit real-mode programs. DJGPP also has a C compiler, and Turbo C is available at the same location Turbo C++ is. Pascal might be a good choice for a beginner too. Developed to teach beginning programmers good structural programming techniques, it's not too difficult a language to learn, and it forces good structural programming techniques. You can find DJGPP here: http://www.delorie.com/djgpp/ And you can find Turbo C/C++/Pascal here: http://community.borland.com/museum/ But so far you're right: these languages don't fit the "job description." If the machine is a 386 or better, there are ports to DOS of Perl and Python available that use protected mode. Python's DOS port is available on its homepage, and Perl's DOS port can be downloaded as part of DJGPP. Python might be overkill for DOS, but Perl would definitely be useful. So Perl fits the job description and is available for DOS on a 386 or better. I'd suggest it over QBASIC on such a machine. If anyone needs instructions on setting it up, post a thread here and I'll post a reply. The only language I suggested that can't be reasonably used in DOS would be Java. But even then, there's Waba for DOS. There's also assembly, for which I would suggest the great x86 assembler NASM, which is free and open source. Assembly may be complicated and difficult, but it helps develop a better understanding of what you're really doing and how the machine does things. DOS is definitely one of the nicer environments to do real assembly programming in as well, since it gives you direct access to the hardware. little knipper: BTW, if you're interested in a good, free DOS OS, or you're looking for DOS tools and utilities, check out FreeDOS. Batch scripts are useful for organizing tasks so you don't have to do as much work. They're most useful when used with the programs that you write. Last edited by RamsusX; September 28th, 2003 at 23:16. |
|
|
|
|
|
#15 (permalink) |
|
Registered User
![]() Join Date: Jul 2003
Location: Los Angeles
Posts: 53
|
Re: a quick quiestion with an easy answer !
You mis my point. For perl, you cannot say:
whatsmyname.pl Bad command or filename. At a command prompt and expect it to work; you can make this work on NT, but on DOS it REQUIRES you to use perl.exe. This is not true of compiled languages, or batch files. That was part of the "job description." You can however do this with C++ or QuickBASIC. whatsmyname[.exe] What's your name? Unknown Hello, Unknown! For the beginner, I would suggest the MASM linker, which is freely downloadable from Microsoft. Much easier to use, and has compilation of if statements. NASM has weird syntax as far as I'm concerned... pfft, AT&T.. -[Unknown] |
|
|
|
|
|
#16 (permalink) | ||
|
Ramsus K
![]() ![]() ![]() Join Date: Mar 2003
Location: Oklahoma
Posts: 461
|
Re: a quick quiestion with an easy answer !
Quote:
Quote:
NASM is somewhat more barebones/low-level than MASM, but you can build up some of the same functionality using macros. However, finding the download for the MASM assembler and the Microsoft linker is a major pain these days. The nice thing about using MASM (if you can find it) is that if you do use it, then you can also make use of this excellent online book called The Art of Assembly for DOS, available here: http://webster.cs.ucr.edu/Page_asm/A..._ArtofAsm.html There's also a lot of MASM code for DOS available on the Internet for you to use. *EDIT: Isn't it nearly impossible to find the QuickBASIC compiler these days? I know the Windows 98 CD has the QBASIC interpreter. |
||
|
|
|
|
|
#17 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
|
Re: a quick quiestion with an easy answer !
you really like perl don't you ?
i was just asking a reasonable question oh and i don't intend to start really programing till i leave school i have done some YABASIC for the PS2 but only simple stuff like pong (unfortunatly the ball went through the bats )i also have a great php website running but i don't really want to do any more than that 'cause of exams and stuff
|
|
|
|
|
|
#18 (permalink) | |||
|
Ramsus K
![]() ![]() ![]() Join Date: Mar 2003
Location: Oklahoma
Posts: 461
|
Re: a quick quiestion with an easy answer !
Quote:
Quote:
Quote:
Anyway, this has all revived my interest in doing DOS development, so I'll probably install FreeDOS later this week along with some development tools. |
|||
|
|
|
|
|
#19 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
|
Re: a quick quiestion with an easy answer !
Perl is a very flexable, easy to use, and fully object oriented programming language. For Linux, grab the source from CPAN (http://www.cpan.org/) or for Win32 Activestate's build is great. It is my favorite programming language.
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|