Page 1 of 1 1
Topic Options
#49525 - 2000-04-14 09:28 AM How do I create a file
Anonymous
Unregistered


Im after a way of creating a .txt file through a script, or possible add a line to an existing one.

Any Ideas?

Top
#49526 - 2000-04-14 07:02 PM Re: How do I create a file
Anonymous
Unregistered


open(1,newfile.txt,5)

writeline(1,"I should have read the manual ...")

close(1)

Top
#49527 - 2000-04-17 05:20 AM Re: How do I create a file
Anonymous
Unregistered


shell "cmd /c YourPgm.exe >c:\YourFile.txt"
is allso useful if you want to get the output form a program (IPconfig, dir, mem)in the file, for later use.
Then you can open the file, read the line you want, and get the positions you want fromm it.

Top
#49528 - 2000-04-20 06:19 AM Re: How do I create a file
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Create a new file

shell "cmd /c echo Hello!! > file.txt"

Append to existing file

shell "cmd /c echo Hello!! >> file.txt"


You can use @macros after the echo and as part of a filename too.

cj

Top
#49529 - 2000-04-20 09:37 AM Re: How do I create a file
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I don't know what you are trying to do but I try to avoid this type of self modifying code. I find creative thinking usually offers an alternative.
_________________________
Jack

Top
#49530 - 2000-04-20 10:21 AM Re: How do I create a file
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jack...

What is your definition of "Self Modifying Code"

To me - self modifying code is this kind of crap ...

code:

break on


$x=1 $y=2
shell 'cmd /c echo $$x=$x > prog.kix'
shell 'cmd /c echo $$y=$y >> prog.kix'
shell 'cmd /c echo ?"x + y = "$$x+$$y >> prog.kix'
call "prog.kix"


exit


Are you taking issue with perlarsson's example of doing something fundamental like this...

shell 'cmd /c dir.exe *.* >list.txt'

Am I missing something here ?

Shawn.


Top
#49531 - 2000-04-20 11:43 AM Re: How do I create a file
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I think my comment "You can use @macros after the echo and as part of a filename too." might have been confusing.

Let me give some examples:

shell "cmd /c echo Hello @userid!! > greeting.txt"

will create a file called greeting.txt and will contain Hello (your logon id here)!!

shell "cmd /c echo Hello!! > @wksta.txt"

will create a file that is (your computers name here).txt and will contain the text "Hello!!"

changing the > to >> will append your line to a file...

shell "cmd /c echo @userid logged onto @wksta at @time on @date >> \\server\share\monitorusers.txt"

will add "John logged onto COMPAQ002 at 13:55:29 on 2000/04/20" to the end of the file called monitorusers.txt. This file will have each occurance of this action on each line.

I hope this helps. I can give you some examples of self modifying code too...

cj

P.S. Spelling mistake corrected

[This message has been edited by cj (edited 20 April 2000).]

Top
#49532 - 2000-04-20 02:39 PM Re: How do I create a file
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
By that logic, whats the difference between writing this...

shell "cmd /c echo Hello!! > @wksta.txt"

and writing this...

MD "%userprofile%\desktop\MyFolder"

???

The question really becomes ...

Is there a big, or subtle, difference between writing self modifying code and simply using dynamic, context sensitive environment variables.

Seems to me that there's a big difference !

Shawn.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1636 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org