Notepad coding!
Re:Notepad coding!
oh. i didnt know about that anyway when i did it. i had no clue you could do that. but for future reference, all i do is scandisk/autofix ?
Re:Notepad coding!
hrm, in response to whom denies the existance of the DOS command "move"(Windows 98SE:
Code: Select all
C:\WINDOWS\Desktop>move /?
To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
[drive:][path]filename1 Specifies the location and name of the f
or files you want to move.
destination Specifies the new location of the file.
can consist of a drive letter and colon,
name, or a combination. If you are movin
file, you can also include a filename if
to rename the file when you move it.
[drive:][path]dirname1 Specifies the directory you want to rena
dirname2 Specifies the new name of the directory.
/Y Suppresses prompting to confirm creation of a di
or overwriting of the destination.
/-Y Causes prompting to confirm creation of a direct
overwriting of the destination.
The switch /Y may be present in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
Re:Notepad coding!
Well, I started programming Batch.
Well some things aren't mentioned here, like parameters.
I think you, Joey, know that these exists:
But you also can have more than 9 parameters, using the SHIFT command.
If you have more questions, post it here, I can help
Well some things aren't mentioned here, like parameters.
I think you, Joey, know that these exists:
Code: Select all
%1 %2 %3 %4 %5 %6 %7 %8 %9
Code: Select all
rem a messager, prints everything you put on %1, %2, etc.
rem example: mess Hello, how are you ? I am fine, thanks Hello world.
:loop
echo %1
shift
if "%1" == "" goto endloop
goto loop
:endloop
Re:Notepad coding!
If I am not completely mistaken, no-one has yet answered Joey's *real* question(s)...
A .bat file is passed to an interpreter, which reads the file line by line, and executes the commands it finds. There are other forms of files that can be interpreted, given that a corresponding interpreter is available that understands the programming language you used. (A popular example is the interpreter for the "Perl" language, which isn't shipped with Windows however and must be installed seperately.)
Now, you can save a file from notepad, or rename it, to any filename extension you like, but you do not change the type of the file. You could, for example, save your .bat file as .gif, and the next time you click on it, Windows will try to open it as a picture because it ends in ".gif". Needless to say that this attempt will not be successful, since your batch script isn't a picture. Likewise, saving your file as ".exe" does not make it an executable.
Executables are saved in a form the CPU understands - which means, 01101010 11010101 01010100 01001000 etc. Needless to say that this form is hardly understood by any mortal being, and even the sick-o's who can read binary need quite some time to figure it out. Hence, executables are written in some form of human-readable language instead, and then compiled into binary form. And even if you take your notepad and type "00101100 10001111 ..." and save that as .exe file, that wouldn't help you. What you're typing are the characters '0' and '1'...
Basically, this is very similar to a batch file - but instead of an interpreted making sense out of a human-readable file whenever that is "executed", a compiler makes sense out of a human-readable file only once, and saves it in computer-readable form. Compiled programs are, as a rule, faster than interpreted ones. Unfortunately, Windows does not come with any compilers pre-installed.
But don't despair, I have something juicy for you at the end of this posting.
Ah, to hell with it. I hereby recommend you to start http://www.cygwin.com/setup.exe - it is an installation programm that will add a completely new "DOS box" to your system, which is called "bash", and which contains many tools that Windows does not have otherwise. Just stick with the defaults of the installation program; the download will take quite a while, but it's worth it. After the installation completes, start it again, and this time, when the long list of packages comes up fom which you can chose, make sure to check "gcc", in the category "development". That will again take some while to download and install - this is a compiler for a programming language called C.
Then go to your local bookstore, and look for a book like "The C Programming Language", "C for beginners", or any other book on "C" that you find understandable. (Not C++, or C#, just C. The two others are more powerful, but also more confusing.) When you get home, you can compile the example programs in those books by calling the tool "gcc" in the new Cygwin shell you just installed.
Welcome to a completely new world. You just entered geekhood.
The Windows operating system determines how to handle a file by the filename extension. Files ending in ".bat" are executed as a "batch script". In a batch script, you can use any command that is available on the command line (DOS box), plus a number of additional stuff like @echo, parameters etc.Joey wrote: You type in this code then save it as a .bat file. can you save any thing you write in notepad as ANY type of file?
A .bat file is passed to an interpreter, which reads the file line by line, and executes the commands it finds. There are other forms of files that can be interpreted, given that a corresponding interpreter is available that understands the programming language you used. (A popular example is the interpreter for the "Perl" language, which isn't shipped with Windows however and must be installed seperately.)
Now, you can save a file from notepad, or rename it, to any filename extension you like, but you do not change the type of the file. You could, for example, save your .bat file as .gif, and the next time you click on it, Windows will try to open it as a picture because it ends in ".gif". Needless to say that this attempt will not be successful, since your batch script isn't a picture. Likewise, saving your file as ".exe" does not make it an executable.
Executables are saved in a form the CPU understands - which means, 01101010 11010101 01010100 01001000 etc. Needless to say that this form is hardly understood by any mortal being, and even the sick-o's who can read binary need quite some time to figure it out. Hence, executables are written in some form of human-readable language instead, and then compiled into binary form. And even if you take your notepad and type "00101100 10001111 ..." and save that as .exe file, that wouldn't help you. What you're typing are the characters '0' and '1'...
Basically, this is very similar to a batch file - but instead of an interpreted making sense out of a human-readable file whenever that is "executed", a compiler makes sense out of a human-readable file only once, and saves it in computer-readable form. Compiled programs are, as a rule, faster than interpreted ones. Unfortunately, Windows does not come with any compilers pre-installed.
But don't despair, I have something juicy for you at the end of this posting.
Correct - there are literally hundreds of languages in which you can write the human-readable form of the program, and hundreds corresponding compilers to translate them to executable form.But there has to be a language or something for .exe files.
Correct - DOS.im confused here. if i made programs in notepad and wanted to save them as a .bat file, there is a language for .bat right?
It's itching me to recommend you a language, or a book, but I fear no matter what I recommend, I will be flamed by onlookers, because programming languages have always been a reason for holy wars...Can someone explain how i would know what code i would need to type for a .exe file or something like that.
Ah, to hell with it. I hereby recommend you to start http://www.cygwin.com/setup.exe - it is an installation programm that will add a completely new "DOS box" to your system, which is called "bash", and which contains many tools that Windows does not have otherwise. Just stick with the defaults of the installation program; the download will take quite a while, but it's worth it. After the installation completes, start it again, and this time, when the long list of packages comes up fom which you can chose, make sure to check "gcc", in the category "development". That will again take some while to download and install - this is a compiler for a programming language called C.
Then go to your local bookstore, and look for a book like "The C Programming Language", "C for beginners", or any other book on "C" that you find understandable. (Not C++, or C#, just C. The two others are more powerful, but also more confusing.) When you get home, you can compile the example programs in those books by calling the tool "gcc" in the new Cygwin shell you just installed.
Welcome to a completely new world. You just entered geekhood.
Nope. Keep your posting saved away somewhere save, and in five years or so, dig it out and read it again. You'll probably laugh your head off.i typed in the following for a .bat file in notepad, and it worked:
echo off
@del c:\test
echo your a dumb @$$
echo on
now if i saved it as a .exe file, would it do the same as the .bat file?
Every good solution is obvious once you've found it.
Re:Notepad coding!
Ok, to answer the original question.
Yes you can.
It involves typing everything on one line, using the ctrl-# mechanism to give you access to the full ASCII character range, knowing ASCII->Hex, how to program in machine code, the .com/.exe format and finally the Windows API of your choice.
In short you can use notepad as a hex editor if you REALLY want to, but unless you're stuck on a desert island with no internet connection and debug isn't working then DO NOT DO IT.
On the plus side it really doesn't take that much to write a basic assembler, and from there a simple compiler. So given the intel manuals, the C standard and plenty of suntan lotion you should be writing in C within a couple of months on your island ;D
Yes you can.
It involves typing everything on one line, using the ctrl-# mechanism to give you access to the full ASCII character range, knowing ASCII->Hex, how to program in machine code, the .com/.exe format and finally the Windows API of your choice.
In short you can use notepad as a hex editor if you REALLY want to, but unless you're stuck on a desert island with no internet connection and debug isn't working then DO NOT DO IT.
On the plus side it really doesn't take that much to write a basic assembler, and from there a simple compiler. So given the intel manuals, the C standard and plenty of suntan lotion you should be writing in C within a couple of months on your island ;D
Re:Notepad coding!
It's ALT+#It involves typing everything on one line, using the ctrl-# mechanism to give you access to the full ASCII character range, knowing ASCII->Hex, how to program in machine code, the .com/.exe format and finally the Windows API of your choice.
Re:Notepad coding!
whoa whoa whoa. now you struck my interest. you can write a basic assembler and compiler in notepad? haha or were you saying you could in c or something.
Re:Notepad coding!
i just thought it would be quick and simple to make a few quick programs in notepad, like an installer. just using the copy command or something. but if you can make an assembler and from there a compiler in notepad, tell me how! i dont even know what an assembler is though. so could you please explain that. ;D
Re:Notepad coding!
There is no DOS command called move. There is a DOS program called MOVE.EXE.erebus- wrote: hrm, in response to whom denies the existance of the DOS command "move"(Windows 98SE:
Code: Select all
C:\WINDOWS\Desktop>move /? To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
For the difference, try moving move away, and then try move. Then, attempt that with copy (try to make the copy command defective). With move it's moving the exe, with copy it's impossible.
Re:Notepad coding!
You can write an assembler in anything that can emit plain binary (Assuming it can also use a value of 0->255 for each byte). A couple of months back I wrote a very basic one (It only recognises DB, DW, DD, RET, INT) using a hex editor. Once the initial version (That can read an input file, parse it, and emit an output file) is created everything else is just a question of evolution. I keep meaning to go back and finish it, but there's never enough time.Joey wrote: whoa whoa whoa. now you struck my interest. you can write a basic assembler and compiler in notepad?
Re:Notepad coding!
so wait. what is an assembler. what does it do. and are they hard to make? ;D i just love creating things, and i want to try new things.
Re:Notepad coding!
Yes, but writing an assembler that way is like building a house out of Legos and Crazy Glue, blindfolded. While that kind of Real Programming has a certain machismo to it (or perhaps masochism), in the end it doesn't make much sense beyond proving that you can.
As for Joey's question fo what an assembler is, well, one van think of it as the ancestor of the compiler: it is a program that tunrs assembly language into machine instructions. To understand about assembly language, you have to understand that the CPU in a computer exists primarily to read in a series of operation codes (opcodes) and perform them. Each opcode is a bit pattern representing a different operation that the computer can perform. For example, in the x86 instruction set,
[tt]0100 0000[/tt]
stands for 'increment the AX register by one' (a register is a sort of 'scratch pad' memory in the CPU itself). Since binary is a real pain to work with, this would usually be written in hexidecimal, as '40' (64 decimal). But since even writing these opcodes out in hex is extremely hard and error prone, early programmers came up with a notation for representing the individual instructions symbolically. This notation, called assembly language, usually looks like this:
[tt] INC AX[/tt]
which is standard x86 assembly instruction for the opcode shown above. Most assembly languages stick to a very simple set of 2 or 4 letter mnemonics, with each mnemonic represents a single instruction (or a very simple group of instructions).
Every type of CPU has it's own assembly language. Assembly code is very close to the machine code which it represents, and usually has only a very few abstractions (such as labels) to simplify programming. It is surprisingly easy to learn the basics of assembly, but it is difficult to become an expert at it, and it can be extremely tedious for routine programming. However, well-written assembly programs are generally smaller and faster than those written in a higher-level language.
Many compilers actually output assembly code rather than machine code, as it is easier to write the code generators that way, generally speaking; also, the generated assembly code can be used in debugging. One of the classic tests of a compiler, mentioned in the original Small-C article, is to com pile the compiler with itself, then repeat this and debug until it consistently produces the same assembly code each subsequent pass.
As for Joey's question fo what an assembler is, well, one van think of it as the ancestor of the compiler: it is a program that tunrs assembly language into machine instructions. To understand about assembly language, you have to understand that the CPU in a computer exists primarily to read in a series of operation codes (opcodes) and perform them. Each opcode is a bit pattern representing a different operation that the computer can perform. For example, in the x86 instruction set,
[tt]0100 0000[/tt]
stands for 'increment the AX register by one' (a register is a sort of 'scratch pad' memory in the CPU itself). Since binary is a real pain to work with, this would usually be written in hexidecimal, as '40' (64 decimal). But since even writing these opcodes out in hex is extremely hard and error prone, early programmers came up with a notation for representing the individual instructions symbolically. This notation, called assembly language, usually looks like this:
[tt] INC AX[/tt]
which is standard x86 assembly instruction for the opcode shown above. Most assembly languages stick to a very simple set of 2 or 4 letter mnemonics, with each mnemonic represents a single instruction (or a very simple group of instructions).
Every type of CPU has it's own assembly language. Assembly code is very close to the machine code which it represents, and usually has only a very few abstractions (such as labels) to simplify programming. It is surprisingly easy to learn the basics of assembly, but it is difficult to become an expert at it, and it can be extremely tedious for routine programming. However, well-written assembly programs are generally smaller and faster than those written in a higher-level language.
Many compilers actually output assembly code rather than machine code, as it is easier to write the code generators that way, generally speaking; also, the generated assembly code can be used in debugging. One of the classic tests of a compiler, mentioned in the original Small-C article, is to com pile the compiler with itself, then repeat this and debug until it consistently produces the same assembly code each subsequent pass.