|
-
May 13th, 2001, 04:22 PM
#1
Question
I have an app that simply saves urls what I need to do is verify that the app does not add duplicates to the text file any ideas
-
May 13th, 2001, 04:57 PM
#2
Frenzied Member
Let's say that the variable that you want to add is VarURL, then:
Code:
Dim AllURL As String
Open "Filename" for Input As #1
Get #1, ,AllURL
Close #1
If InStr(1, AllURL, VarURL, vbTextCompare) <> 0 then
VarURL = ""
End If
Open "Filename" for Output As #1
If VarURL<>"" Then Put #1, ,VarURL
Close #1
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
May 13th, 2001, 05:14 PM
#3
Microbasic when I run your code I get " Bad File Mode "
error any Idea why
-
May 13th, 2001, 05:27 PM
#4
Frenzied Member
Sorry, I forgot. You can't use Get+Put on Input+Append+Output files:
Code:
Dim AllURL As String, Data As String, fr As Integer
fr = FileFree
Open "Filename" for Input As #fr
Do Until EOF(fr)
Line Input #fr, Data
AllURL = AllURL & " + " & Data
Loop
Close #fr
If InStr(1, AllURL, VarURL, vbTextCompare) <> 0 then
VarURL = ""
End If
fr = FileFree
Open "Filename" for Append As #fr
If VarURL<>"" Then Print #fr, ,VarURL
Close #fr
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
May 13th, 2001, 05:42 PM
#5
Hyperactive Member
If the files start getting large, you might want to read the files as binary. It would look like this:
Code:
Private Const FILENAME = "test.txt"
Private Sub Command1_Click()
Dim FF As Long
Dim str_URL As String
Dim str_Test_URL As String
str_Test_URL = "http://zasdfzz.com"
FF = FreeFile
Open FILENAME For Binary As FF
str_URL = Space(LOF(FF))
Get #FF, , str_URL
If InStr(str_URL, str_Test_URL) = 0 Then
Put #FF, Seek(FF), str_Test_URL & vbCrLf
End If
Close FF
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|