WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Operations

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Write File Contents to Screen

Keywords:     display

Question:

I use a file I named, ExtractLines.WBT, to search for strings in my database and write the lines found to a new file. I then view the new file in Notepad. The program works fine and serves me well.

Is there a way to write the lines directly to the screen from within the winbatch file? Or write to the clipboard or a temporary file and then show on screen directly from the WinBatch program?

Answer:

There are many ways to do what you want. Here are some notes: Here is a file and a binary example:
;display the contents of a file
testfile1=FileLocate("win.ini")
old = FileOpen(testfile1, "READ")
msg="" 
  while @TRUE             ; Loop till break do us end
        line=fileread(old)
        If Line == "*EOF*" Then Break
        msg=strcat(msg,line,@CRLF)
  endwhile
FileClose(old)
display(5,"Filetext" ,msg)

;Binary example (runs much faster)
fs=FileSize("C:\WINDOWS\WIN.INI")
binbuf = BinaryAlloc(fs+100)
if binbuf == 0
        Message("Error", "BinaryAlloc Failed")
else
        BinaryRead(binbuf, "C:\WINDOWS\WIN.INI")
        maxlen=min(binaryEODget(binbuf),30000)
        text=Binarypeekstr(binbuf,0,maxlen)
        binbuf=BinaryFree(binbuf)
endif
display(5, "", text)

Article ID:   W13231
Filename:   Display - Write File Contents to Screen.txt
File Created: 1999:04:15:16:52:38
Last Updated: 1999:04:15:16:52:38