Create a file ... and write some text in

Hi all,

I am a newbie with Clarion…

I try to create a empty file with the extension .bat. and add some content.

I tried this this with filedialog and this works. But i want to do this without any window-view (save ect.)!

Just a background action. How i can simple create a empty file?

Thx for help.

Regards

Check for BASIC driver in the doc

I’m not sure BASIC is the correct driver for this. BASIC creates delimited files (Tab, Comma, etc).
The DOS driver allows you to write any values to a file, including binary data if needed.

Also, if you have StringTheory you can do it with two lines of code.

st StringTheory
  code
  st.Assign('My File Contents')
  st.SaveFile('C:\Temp\MyFile.bat')
1 Like

as well, DOS driver should be fine

1 Like

THX ALL … that helps

TextFile File,Driver(‘ASCII’)
Record Record
data String(1024)
End
End
code
textfile{prop:name} = ‘fred.bat’
remove(textfile)
create(textfile)
open(textfile)
if ~errorcode()
textfile:data = ‘@echo off’;add(textfile)
end

1 Like

yes that is how I would do it.

as a newbie Rob, I think StringTheory is the first 3rd party tool you should get. It currently costs 97 USD and will likely pay for itself in short time. If you don’t have that option then Clarion comes with SystemStringClass which will do something similar (although generally not as well).

1 Like