|
-
Jul 26th, 2006, 01:54 PM
#1
Thread Starter
Addicted Member
find line #3 in each paragraph
if i have a notpad file and want to search it from thired line in each paragraph
and check if first word is 'SOLUTION' then extract some words and go to the next 'SOLUTION' and do the same thing
if first word is 'COMMENT' then take the whole line
(actually it's not a paragraph they are some groups of unrelated lines separated by empty line )
can anyone help..... PLEASE
-
Jul 26th, 2006, 01:59 PM
#2
Re: find line #3 in each paragraph
VB Code:
Private Sub GetData()
Dim tmp() As String
Open "C:\path\to\filename.txt" For Input As #1
tmp = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For x = 0 To UBound(tmp)
If Left(tmp(x), 8) = "SOLUTION" Then
'Get words...from tmp(x)
ElseIf Left(tmp(x), 7) = "COMMENT" Then
'tmp(x) is the whole line
WholeLine = tmp(x)
End If
Next
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 26th, 2006, 02:10 PM
#3
Thread Starter
Addicted Member
Re: find line #3 in each paragraph
Thank you STATIC
i will try it and replay
thanks again
-
Jul 26th, 2006, 02:45 PM
#4
Thread Starter
Addicted Member
Re: find line #3 in each paragraph
it works thaks alot
but i have a problem with copying the word i need from each line
how can i these word
i wrote a code to extract them and put them in a list using normal search for a text box not string
how can i get them in case of strings?
VB Code:
Option Explicit
Private Target2Position As Integer
Private TargetPosition As Integer
' Find the text.
Private Sub cmdFind_Click()
FindText 1
End Sub
Private Sub FindText(ByVal start_at As Integer)
Dim target As String
Dim pos As Integer
Dim target2 As String
Dim pos2 As Integer
target = "SOLUTION"
target2 = ")"
pos = InStr(start_at, txtBody.Text, target)
If pos > 0 Then
'We found it.
start_at = pos + 12
pos2 = InStr(start_at, txtBody.Text, target2)
Target2Position = pos2
TargetPosition = pos
txtBody.SelStart = TargetPosition + 12
txtBody.SelLength = Target2Position - TargetPosition - 13
txtBody.SetFocus
Else
'We did not find it.
MsgBox "Not found."
txtBody.SetFocus
End If
Text1.Text = txtBody.SelText
List1.AddItem (Text1.Text)
cmdFind.Enabled = False
End Sub
' Find the next occurrance of the text.
Private Sub cmdFindNext_Click()
FindText Target2Position + 1
End Sub
sample of text
INPUT STRING: البحرين
LOOK-UP WORD: AlbHryn
SOLUTION 1: (AlbaHorayoni) [baHorayoni_1] Al/DET+baHorayoni/NOUN_PROP
(GLOSS): the + Bahrain +
SOLUTION 2: (AlbaHorayoni) [baHor_1] Al/DET+baHor/NOUN+ayoni/NSUFF_MASC_DU_ACCGEN
(GLOSS): the + sea + two
INPUT STRING: هايسث
LOOK-UP WORD: hAysv
Comment: hAysv NOT FOUND
-
Jul 26th, 2006, 02:54 PM
#5
Re: find line #3 in each paragraph
in your sample text.. what are u trying to get in the solution lines...?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 28th, 2006, 02:40 AM
#6
Thread Starter
Addicted Member
Re: find line #3 in each paragraph
sorry for being late there was a problem with my unternet connection
anyway
this is the original text
Hello ( هايسث شمس البحرين تنكسف
1.for the first word(هايسث ) this should be extracted----
hAysv NOT FOUND
2.شمس words are---
$amasa
$amisa
$am~asa
$amos
3.البحرين
AlbaHorayoni
AlbaHorayoni
4. تنكسف
tanokasif
tanokasif
8. Hello:
Non-Alphabetic Data
9. ( :
Non-Alphabetic Data
these words should be shown in a popup menu for each word in the original text
there is lots of details that i should include in the popup menu but i want to finish this part first
Last edited by om-yousif; Jul 28th, 2006 at 03:45 AM.
-
Jul 28th, 2006, 03:35 AM
#7
Thread Starter
Addicted Member
Re: find line #3 in each paragraph
COLOR=Blue]sample of text that should be processed
INPUT STRING: هايسث
LOOK-UP WORD: hAysv
Comment: hAysv NOT FOUND
INPUT STRING: شمس
LOOK-UP WORD: $ms
SOLUTION 1: ($amasa) [$amas-u_1] $amas/VERB_PERFECT+a/PVSUFF_SUBJ:3MS
(GLOSS): + be headstrong + he/it <verb>
SOLUTION 2: ($amisa) [$amis-a_1] $amis/VERB_PERFECT+a/PVSUFF_SUBJ:3MS
(GLOSS): + be sunny + he/it <verb>
SOLUTION 3: ($am~asa) [$am~as_1] $am~as/VERB_PERFECT+a/PVSUFF_SUBJ:3MS
(GLOSS): + expose to the sun + he/it <verb>
SOLUTION 4: ($amos) [$amos_1] $amos/NOUN
(GLOSS): + sun +
SOLUTION 5: ($amos) [$amos_2] $amos/NOUN_PROP
(GLOSS): + Shams +
INPUT STRING: البحرين
LOOK-UP WORD: AlbHryn
SOLUTION 1: (AlbaHorayoni) [baHorayoni_1] Al/DET+baHorayoni/NOUN_PROP
(GLOSS): the + Bahrain +
SOLUTION 2: (AlbaHorayoni) [baHor_1] Al/DET+baHor/NOUN+ayoni/NSUFF_MASC_DU_ACCGEN
(GLOSS): the + sea + two
INPUT STRING: تنكسف
LOOK-UP WORD: tnksf
SOLUTION 1: (tanokasif) [{inokasaf_1] ta/IV3FS+nokasif/VERB_IMPERFECT
(GLOSS): it/they/she + be eclipsed/be ashamed/blush +
SOLUTION 2: (tanokasif) [{inokasaf_1] ta/IV2MS+nokasif/VERB_IMPERFECT
(GLOSS): you [masc.sg.] + be eclipsed/be ashamed/blush +
INPUT STRING: Hello
Comment: Non-Alphabetic Data
INPUT STRING: (
Comment: Non-Alphabetic Data
Last edited by om-yousif; Jul 28th, 2006 at 03:42 AM.
-
Jul 28th, 2006, 04:42 AM
#8
Re: find line #3 in each paragraph
using the code posted by static, this will return the value you are looking for
VB Code:
If Left(tmp(x), 8) = "SOLUTION" Then
MsgBox Mid(tmp(x), InStr(1, tmp(x), "(") + 1, InStr(1, tmp(x), ")") - InStr(1, tmp(x), "(") - 1)
ElseIf Left(tmp(x), 7) = "COMMENT" Then
pete
-
Jul 28th, 2006, 07:14 AM
#9
Re: find line #3 in each paragraph
you want to display these in a popup menu???
what would you be clicking on to trigger this?? (Im confused as to how u want to display these)
the sample below would add them to a listbox
VB Code:
Private Sub GetData()
Dim tmp() As String
Dim Words() As String
Open "C:\path\to\filename.txt" For Input As #1
tmp = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For x = 0 To UBound(tmp)
If Left(tmp(x), 8) = "SOLUTION" Then
Words = Split(tmp(x), "(")
List1.AddItem Left(Words(0), InStr(Words(0), ")"))
ElseIf Left(tmp(x), 7) = "COMMENT" Then
Words = Split(tmp(x), ":")
List1.AddItem Words(1)
ElseIf Left(tmp(x), 5) = "INPUT" Then
Words = Split(tmp(x), ":")
List1.AddItem Words(1)
End If
Next
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 28th, 2006, 02:01 PM
#10
Thread Starter
Addicted Member
Re: find line #3 in each paragraph
Yes WESTCONN!
STATIC
thats it
i combined the two scripts and got what i want thanks
now how can i put them in a popup menu not all in on popup
but for each word different popup menu contains its solutions in case of arabic word
- a popup with (NOT FOUND) in case of arabic word with no meaning
- a popup with (Non-Alphabetic Data)or(not arabic word) in case of english words
etc.
as shown in the text file
Last edited by om-yousif; Jul 28th, 2006 at 03:12 PM.
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
|