Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to "Put" a variable length string to file... 1

Status
Not open for further replies.

LLVW

IS-IT--Management
Jan 7, 2004
3
ZA
Hi, I am trying to write a variable length string to a file using a cognos macro.

I'm using the "Open" and then "Put" functions successfully, but need to remove the first two characters that are inserted into the file (I understand they represent the file length)

Is there another way of writing to a file to avoid getting these extra two characters?

Matt
 
Matt,

Look at the options for using the Print function. It should meet your needs.

Regards,

Dave Griffin


The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Dave, thanks for the quick response!

I've tried the Print statement, but I get "Bad file mode" message on execution.

Here is my test macro:
Sub Main()
Dim Vector As String
Vector = "TEST"
Open "C:/Sigma/RPISWORK/SKETCH.TMP" as #1
Print #1,Vector
Close #1
End Sub

I have also tried ...Open "C:/Sigma/RPISWORK/SKETCH.TMP" For Input as #1... but get the same error.

What am I missing??

Thanks again

Matt
 
Solved, wrong file mode! for Output works:

Sub Main()
Dim Vector As String
Vector = "TEST"
Open "C:/Sigma/RPISWORK/SKETCH.TMP" For Output as #1
Print #1,Vector
Close #1
End Sub
 
Glad you got it to work. I was preparing the same info on the FOR OUTPUT option when you made your follow-up post.

Dave


The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top