AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need fragments from text

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Michael-ce



Joined: 26 Jan 2005
Posts: 8

PostPosted: Wed Apr 20, 2005 10:18 am    Post subject: Need fragments from text Reply with quote

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. Sad
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Wed Apr 20, 2005 12:32 pm    Post subject: Reply with quote

Hi Michael,
schon [hier] angemeldet ? Wink

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. ShockedVery Happy
Back to top
BoBo
Guest





PostPosted: Wed Apr 20, 2005 12:42 pm    Post subject: Reply with quote

Embarassed Ooops, and it needs to be tweaked ... Rolling Eyes
Back to top
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Wed Apr 20, 2005 1:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Wed Apr 20, 2005 6:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group