 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Michael-ce
Joined: 26 Jan 2005 Posts: 8
|
Posted: Wed Apr 20, 2005 10:18 am Post subject: Need fragments from text |
|
|
Hello,
from text in the clipboard, I need only fragments.
For example the text in the clipboard is:
| Code: | <ABFRAGEN-SBCSU:TLNNU=4252,TYP=BUS;
ABFRAGEN-SBCSU:TLNNU=4252,TYP=BUS;
H500: AMO SBCSU GESTARTET
+-------------------------------------------------+
| KONSTELLATION: OPTI |
+-------------------------------------------------+
| ANSCHLUSS: DIR |
| |
| ANSCHLUSSLAGE: 1- 2- 91- 17 |
+=================================================+
| TLNNU GERKON TSI |
+-------------------------------------------------+
| 4252 OPTIP500 1 |
+-------------------------------------------------+
AMO-SBCSU-111 ENDGERAETE- UND S0-BUS-KONFIGURATION IN SWU
ABFRAGEN DURCHGEFUEHRT;
<ABFRAGEN-SBCSU:TLNNU=4019,TYP=BUS;
ABFRAGEN-SBCSU:TLNNU=4019,TYP=BUS;
H500: AMO SBCSU GESTARTET
+-------------------------------------------------+
| KONSTELLATION: OPTI |
+-------------------------------------------------+
| ANSCHLUSS: DIR |
| |
| ANSCHLUSSLAGE: 1- 1- 67- 8 |
+=================================================+
| TLNNU GERKON TSI |
+-------------------------------------------------+
| 4019 OPTISET 1 |
+-------------------------------------------------+
AMO-SBCSU-111 ENDGERAETE- UND S0-BUS-KONFIGURATION IN SWU
ABFRAGEN DURCHGEFUEHRT; |
1. Now I need every deposits from the substrings like 1-??-???-??? in a variable.
For example:
1- 2- 91- 17
1- 1- 67- 8
2. I need these substrings combined with the number standing before "OPTISET".
For example:
4252: 1- 2- 91- 17
4019: 1- 1- 67- 8
The values standing always at the same position in the line. The data blocks have always the same format, only the number of blocks can vary.
Who can help me? I have no idea, how to solve these problem.  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Apr 20, 2005 12:32 pm Post subject: |
|
|
Hi Michael,
schon [hier] angemeldet ?
| Code: | Loop, parse, CLIPBOARD, `n, `r
{
IfInString, A_LoopField, ANSCHLUSSLAGE:
{
StringSplit, AAField, A_LoopField, :
StringReplace, ANSCHLL, AAField2,%A_Space%,,All
StringReplace, ANSCHLL, ANSCHLL,|,,All
}
If A_LoopField contains OPTI
StringSplit, OPTIField, A_LoopField, %A_Space%
MsgBox, %OPTIField9%: %ANSCHLL%
FileAppend, %OPTIField9%: %ANSCHLL%`n, Output.txt
} |
Tested.   |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Apr 20, 2005 12:42 pm Post subject: |
|
|
Ooops, and it needs to be tweaked ...  |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Wed Apr 20, 2005 1:24 pm Post subject: |
|
|
I would offer this | Code: | Loop, parse, CLIPBOARD, `n, `r
{
IfInString, A_LoopField, ANSCHLUSSLAGE:
{
StringSplit, ANSCHLL, A_LoopField, :
StringReplace, ANSCHLL, ANSCHLL2,|,,All
ANSCHLL = %ANSCHLL% ; remove spaces
}
If A_LoopField contains OPTI
{
StringReplace, OPTI, A_LoopField, OPTI,|,All
StringSplit, OPTI, OPTI, |
OPTI = %OPTI%
If OPTI is number
OPTIFound := True
}
If OPTIFound
MsgBox, %OPTI%: %ANSCHLL%
} | Just a tweak of BoBos code. *not tested* _________________ Ciao
toralf  |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1186 Location: switzerland
|
Posted: Wed Apr 20, 2005 6:17 pm Post subject: |
|
|
Hi Michael-ce
it's not from clipboard, store to orig.txt
| Code: |
F1=ORIG.TXT
F2=new.txt
filedelete,%F2%
formattime,TS,,longdate
formattime,TT,T12,time
FileAppend, printed at %TS% %TT%`r`n,%F2%
i = 0
A1:
Loop
{
I += 1
FileReadLine, line, %F1%, %i%
if ErrorLevel <> 0
exitApp
IfInString, line, ANSCHLUSSLAGE
{
stringmid,A,LINE,26,13
GOTO A2
}
}
A2:
{
FileReadLine, line, %F1%, %i%
I +=1
FileReadLine, line, %F1%, %i%
I +=1
FileReadLine, line, %F1%, %i%
I +=1
FileReadLine, line, %F1%, %i%
I +=1
FileReadLine, line, %F1%, %i%
I +=1
{
stringmid,B,LINE,10,4
FileAppend, %B%: %A%`r`n,%F2%
GOTO A1
}
}
ExitApp
|
| Code: |
printed at Mittwoch, 20. April 2005 20:17:05
4252: 1- 2- 91- 17
4019: 1- 1- 67- 8
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|