SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Print to text file w/out Carridge Return

    Hi everyone,

    A very simple question. How do I print data to an external file without that data automatically having a carriage return appended to it? FileWriteLine () and FileWriteValue () both append a carriage returns when they are through writing the data.

    Thanks!

    Andrew

    ------------------

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    What do you want to do ??

    What do you mean by 'carriage return'? Do you actually see a carriage return character in your file?? Are you using external language to parse the file created by your script?

    ------------------

  3. #3
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    Godknows: a carriage return is an end-of-line character; text files (on dos and windows machines) have each line separated by two characters, the carriage-return and the line-feed. On unix machines only one of these is used, but my memory is rusty as to which. So Andrew wants to be able to print a string of characters to a file without necessarily finishing the line he is printing to.

    Unfortunately I don't think there is any way of doing this from within silktest. I would recommend either doing a bit more in your script to compose the string you want to be one line, or if that can't be done (for example you want to output to a file without any end-of-line characters at all) you will need to use silktest to drive some other tool which can do this.

    ------------------

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    I know what is a carriage return, and it is a produced in MS-word for example when you press 'enter' or '\r' in C.

    I never got any carriage return when using FileWriteLine. The question lies in what the hell is he doing It's damn hard to diagnose when no context is given.



    [This message has been edited by GodKnows (edited 07-10-2001).]

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Location
    Bloomington, IL
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    To go one step further with God Knows idea. When I want to create an output string for Excel I use the following function:

    [+] FormatExcelOutput(List of String lsPart, STRING sPathFile, FILEMODE Mode)
    [ ] //************************************************** ************************************************** ******
    [ ] //* Takes a LIST OF STRING input and creates a tab delimited string
    [ ] //* for outputing to the specified excel output file sPathFile
    [ ] //* in the FILEMODE specified.
    [ ] //* FILEMODE values:
    [ ] //* FM_WRITE creates a new file each time
    [ ] //* FM_APPEND appends to an existing file, if none exists, creates a new file
    [ ] //* FM_UPDATE locks the file so no one else can use it, then acts like FM_APPEND
    [ ] //************************************************** ************************************************** *******
    [ ] STRING sPart
    [ ] STRING sOutput = ""
    [ ] HFILE hFile
    [ ]
    [-] for each sPart in lsPart //For each string in the LIST OF STRING
    [-] do
    [ ] sOutput = sOutput + sPart + " " //Concatenate the substring, and a tab to the output string
    [-] except
    [ ] sPart = " " //Set the substring to a space
    [ ] sOutput = sOutput + sPart + " " //Concatenate the substring, and a tab to the output string
    [ ] continue //Return to the for loop
    [ ]
    [ ] hFile=FileOpen (sPathFile, Mode) //Open the specified file in the mode specified
    [ ] FileWriteLine(hFile, sOutput) //Write the current line out
    [ ] FileClose(hFile) //Close the output file
    [ ]

    I liek to use the tab delimited file because it can be directly saved to an .xls extension with no conversion when the file is open, only during the save process.

    Mike

    ------------------


    [This message has been edited by MikeF (edited 07-10-2001).]

  6. #6
    Member
    Join Date
    Jan 2001
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by GodKnows:
    I know what is a carriage return, and it is a produced in MS-word for example when you press 'enter' or '\r' in C.

    I never got any carriage return when using FileWriteLine. The question lies in what the hell is he doing It's damn hard to diagnose when no context is given.
    <HR></BLOCKQUOTE>


    Sorry for the lack of context. Here's the story:

    I've written a script that clicks around on a web site. After each click on the site, I use the GetReadyTime () function to capture the time it takes for the Browser to come back to a ready state (Done) after that click. So the code looks something like this:
    As it is, the script prints out the PERFORMANCE and "Ready time..." strings and variables to the SilkTest results file.

    I capture these performance times after each click in the script. What I'd like to do is send each value to a comma-delimited external text file which can then be imported by Excel so I can track performance of the web site.

    The only way I have seen so far is to print out the value of the performance time, which if we look above is the stored in the variable "rSec," to a file using either FileWriteLine () or perhaps FileWriteValue ().

    Unfortunately, as per the 4Test Language Reference manual, both of these functions inherently append a carriage return after writing the data specified to the external file. Regarding FileWriteLine, "FileWriteLine writes the specified string to the file identified by hFile. It automatically appends the appropriate character or characters (for example, a carriage return/line feed sequence) needed to delimit a line of text on the current platform."

    Regarding FileWriteValue, "FileWriteValue writes each piece of data (aValue) on its own line in hFile. For example, if you call FileWriteValue three times on a new file, the resulting file will have three lines."

    Thus, each of these functions will not let me keep appending data to that external file; rather, it seems as though they will just add lines. This format doesn't work for Excel. I really need to just append data delimited by comma's.

    Does this clarify? Thanks for the help!

    Andrew


    ------------------


    [This message has been edited by AndrewLance (edited 07-10-2001).]

  7. #7
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    I just did a small test.

    I manually created a file
    1,2,3,4
    5,6,7,8,9,10

    and it imported in Excel very well.

    In your case you want just want to keep what you want to ouput in a list of string using ListAppend(list,item) each element of the list would be one line in the file and one row in Excel.

    Then within a loop you would write to a file. I believe this way you would be able to gather the information you want on the same line(or row in Excel).

    ------------------

  8. #8
    Member
    Join Date
    Jan 2001
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Print to text file w/out Carridge Return

    Thanks you guys for the help. Good suggestions.

    I was able to implement exactly what I wanted with these ideas. Thanks again!

    Andrew

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:05 PM.

Copyright BetaSoft Inc.