Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
out command without issuing a newline?
Is there a way to use the out command without issuing a newline? I'm looking for something like a "-n" flag that would do something like this:

out -n "1"
out -n "2"
out "3"

which would produce the output:


Actually my goal here is to write out a big database as a tab-delimited text file that can be imported by Excel. I tried to build an enormous string variable that I could then write out with setfile, but I believe my database got too big to hold in a single string variable, so now I'm looking for another way to do it.
out "%i%i%i" 1 2 3
An old blog on QM coding and automation.

The Macro Hook
Accumulate to a str variable and then out and clear it.

Copy      Help
str so
so.formata("%s" "1")
so.formata("[9]%i" 2)
so.formata("[9]%g" 3.45)
out so; so.fix(0)
Great responses, thanks! Either of these should enable me to write my entire database to the QM output window, so that I can then copy and paste it into Word, and then save it as plain text that can be read by Excel.

I may be asking too much here, but is there a way for me to write it directly to a .txt file from QM? As I said, representing the entire text file in a single string variable, and then writing it out with setfile, works for a small database. But if it gets large, I'm sure I'll eventually exceed the capacity of the variable. Is there a way to, say, write one line at a time to a .txt file? I'm really longing for fopen(), fprintf(), and fclose() here...
i've written out files that were hundreds of meg using the 'setfile' function. i doubt you'll over burden the string capacity if you can do a copy/ big is the db?

Copy      Help
An old blog on QM coding and automation.

The Macro Hook
Copy      Help
File f.Open("$my qm$\my out.txt" "w") ;;w writes new file. Use a to append.
fprintf f "%s[9]" "1"
fprintf f "%i[9]" 2
fprintf f "%g[]" 3.45
Well, my database may reach several MB, but it will never get to hundreds of MB. I guess QM is smarter about string variable allocation that I imagined it could be.

So the setfile method should work. But I'm also intrigued by the fprintf version, with which I'm having one problem. Apparently fprintf requires me to explicitly issue a newline character at the end of each line, but \n doesn't do the trick. Is there a different escape code I should use?
[] = \r\n
[10] = \n
Excellent. Many thanks to you both.

Forum Jump:

Users browsing this thread: 1 Guest(s)