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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending text to existing file

Status
Not open for further replies.

vsprogrammer

Programmer
Jun 26, 2006
40
0
0
CA
Hi,

I am trying to write text back to a notepad file, the following code works, however, it keeps overriding the original value. So what I am doing is checking a checkbox and then reading the text that is associated with the checkbox and storing it back to the file for later use, ie.
(Using CitraText with VB coding)

For y = 1 To iCheckboxCount
returnStatus = ClickOnImage("Checkbox_Unchecked.bmp", LEFT_BUTTON, 1, 2, "NONE", USE_COLOR_VARIATION + USE_NEAREST_IMAGE, STANDARD_COLOR_TOLERANCE, 0)

'*READ WHAT THE ORDER NAME IS AND STORE IN A FILE FOR LATER
returnStatus = ReadText("Dummy_relative_area.relative", "MSSansSerif8_Bold", 2)

returnStatus = ReadText("Read_Order_Checkbox.relative", "MSSansSerif8_Bold", STANDARD_TIMEOUT)
If returnStatus <> SUCCESS Then
scriptStatus = SCRIPT_FAIL
Exit Sub
Else
TextRead = Replace(TextRead, "I", "l")
Dim FILE_NAME As String = "C:\Documents and Settings\vsnook\Desktop\OrderName.ini"

If System.IO.File.Exists(FILE_NAME) = True Then
Dim sb As New System.Text.StringBuilder
sb.Append(TextRead)
Using writer As System.IO.StreamWriter = New System.IO.StreamWriter(FILE_NAME)
writer.Write(sb.tostring)
sb.End Using
Else
MsgBox("File Does Not Exist")
End If

End If

If returnStatus <> SUCCESS Then
Exit For
End If

Delay(".3")
Next y

****************** END CODE *****************
Any help would be appreciated!
Have a great day!
Vicky
 
At a first glance
Code:
TextRead = Replace(TextRead, "I", "l")
might be
Code:
TextRead = Replace([COLOR=red]ReadText[/color], "I", "l")
or everything is ReadText?

Zameer Abdulla
 
Hi Zameer,

Thanks so much for the quick reply!
"TextRead = Replace(TextRead, "I", "l")"
This line replaces the "I" (capital eye) with "l" (lower elle) because the font changes it when it captures the text.

The TextRead is a variable built into CitraText that stores the text when it gets read. (with the readtext function)

ReadText is the function name built into citratext.

(hope this makes sense?)

Thanks! Vicky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top