Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to make the < char. echo to a text file  (Read 4376 times)

0 Members and 1 Guest are viewing this topic.

wkmaccaughey

  • Guest
how to make the < char. echo to a text file
« on: April 11, 2005, 09:55:39 AM »
Hi!  Anyone know how to make the < character echo to a text file.  I'm creating a basic pgm via a dos batch file and need to use the < character in the basic program but it is an operator that the batch file acts on so it doesn't echo to the basic program.

example:  echo if t < 3 then goto sleepsub >> timer.bas


thanks!
bill
[email protected]

gussery

  • Guest
Re: how to make the < char. echo to a text file
« Reply #1 on: April 11, 2005, 10:22:37 AM »
Use the caret(^) symbol before special characters.


echo if t ^< 3 then goto sleepsub >>timer.bas

wkmaccaughey

  • Guest
Re: how to make the < char. echo to a text file
« Reply #2 on: April 11, 2005, 11:11:54 AM »
Thanks, Gary!
I've been tinkering with DOS for 20 yrs and never knew that one!

One other q: what's the syntax to automatically feed a response to a called program.  For example: time usually reports the time then asks for an input.  If I want to run a batch file that sets the time to 00:00 how would it look?

Bill

gussery

  • Guest
Re: how to make the < char. echo to a text file
« Reply #3 on: April 11, 2005, 11:21:42 AM »
time 00:00
will set the computer's clock to midnight.


wkmaccaughey

  • Guest
Re: how to make the < char. echo to a text file
« Reply #4 on: April 11, 2005, 11:41:07 AM »
I think I messed up my reply so I'm starting over..

If a program asks for a response like a number or name how would the batch file input it.  
Also, (last q!) can batch files perform math functions from inputs?  ex: echo %1 * %2

Thanks for your help!

gussery

  • Guest
Re: how to make the < char. echo to a text file
« Reply #5 on: April 11, 2005, 11:53:35 AM »
Time to dig out some of the old books and dust them off. :)  Now where did I put those.....?

I think you may be pushing the capabilities of batch files here.  I believe you can do both in batch but I know you can do them is script files, using VBScript etc.

Does this really need to be a batch file?

« Last Edit: April 11, 2005, 11:56:55 AM by gussery »

wkmaccaughey

  • Guest
Re: how to make the < char. echo to a text file
« Reply #6 on: April 11, 2005, 11:57:43 AM »
I once used such a command to automatically feed a response to a query but I can't remember how I did it.

re: the math operations, I'm trying to simplify some things.  How does vb scripting work?

gussery

  • Guest
Re: how to make the < char. echo to a text file
« Reply #7 on: April 11, 2005, 12:30:26 PM »
VB Script is a subset of VB.  Unless you have disabled it any Windows computer will run the scripts without the addition of any software.

While DOS is basically used for doing disk operations, VB Script can interact with programs, perform Window functions, perform math, present dialog boxes, input boxes, etc. to users.  Just tons of stuff.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtorivbscript.asp



wkmaccaughey

  • Guest
Re: how to make the < char. echo to a text file
« Reply #8 on: April 11, 2005, 01:18:45 PM »
Many thanks again!  I check out vbscript and it looks really interesting.  How are vbscript programs named and run? Are they compiled or can I type the commands into a text file and create the vbscript pgm.   I didn't see any doc'n on the msn website.

gussery

  • Guest
Re: how to make the < char. echo to a text file
« Reply #9 on: April 11, 2005, 01:27:07 PM »
Just type it in notepad and name the file with a vbs extension.

myfile.vbs

If you would like, send me a private message and I will send you a couple of simple samples.

Here is a super simple one that ask the user a question using an input box and converts centigrade to farenheit.  Just paste it into notepad and save as something.vbs.  Then double click it.

dim c
dim f
c = InputBox("Please enter centigrade temperature")
f = (9.0 / 5.0) * c + 32
msgbox f

wkmaccaughey

  • Guest
Re: how to make the < char. echo to a text file
« Reply #10 on: April 11, 2005, 01:35:54 PM »
(I don't see option for private msg. )

I created the file example you gave;  how do you execute the vbs pgm?  I tried a start and call statement from a batch file and that doesn't work.


gussery

  • Guest
Re: how to make the < char. echo to a text file
« Reply #11 on: April 11, 2005, 01:40:10 PM »
Double click it in windows.

Or from the command prompt you just type the file name and hit enter, assuming you are running a later version of Windows.  If you are on 95, 98, etc. you may need to download and install Windows Scripting Host.

To send me a private message click on my user name on the left of this message and then you should see a send private message link.

Note:  When you double click a script in Windows it will normally run, if you run it from a command prompt your firewall, maleware, or virus software may as you whether or not to allow it to run.
« Last Edit: April 11, 2005, 01:42:00 PM by gussery »