find + print text

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

Finally i got it to work to find text and print it.
But now i still have some questions:
1.) how can i print each line that starts with B51000 on a separat page ?
2.) how can i print everything that comes before B51000 as a header on each page ?
3.) and last how can i print the item "Verwendungszweck" (it is a variable text
field and it can be from 1 * 27 alphanumeric positions to 15 * 27 alphanumeric
positions. If it is only once 27 alphanumeric pos. the next item "Bankverbindung" comes after it. When it's 2 * 27 pos. long the item "
Bankverbindung: " comes behind it. and so on until 15 * 27 positions.

That's the program i have until now:
f OpenFile(1,"LPT1:")
OpenConsole()
Print ("Bitte, Dateiname eingeben: ") ; Ask for Filename
FileName$=Input()

StringToFind$ = "B51000"

If ReadFile(0, FileName$)

PrintN("")
PrintN("Starting...")

While Eof (0) = 0
UseFile(0)

Text$ = ReadString()

BLZ$ = Mid(Text$,7,8)
KontoNr$ = Mid(Text$,15,10)
Empfaenger$ = Mid(Text$,25,53)
Betrag$ = Mid(Text$,79,10)
Verwendungszweck$ = Mid(Text$,90,60) ;is variable 27 until 15*27 positions
Bankverbindung$ = Right(Text$,30) ;is at the end of the string : 30 positions

FoundPos = FindString(Text$, StringToFind$, 1)

If FoundPos 0
UseFile(1)
WriteStringN ("")
WriteStringN ("----------------------------------------")
WriteString ("Dateiname : ")
WriteStringN (FileName$)
WriteStringN ("----------------------------------------")
WriteStringN ("")
WriteString ("Bankleitzahl : ")
WriteStringN (BLZ$)
WriteString ("Konto-Nr. : ")
WriteStringN (KontoNr$)
WriteString ("Empfaenger : ")
WriteStringN (Empfaenger$)
WriteString ("Betrag : ")
WriteStringN (Betrag$)
WriteString ("Verwendungszweck : ")
WriteStringN (Verwendungszweck$)
WriteString ("Bankverbindung : ")
WriteStringN (Bankverbindung$)

UseFile (0)

EndIf

Wend
CloseFile(0)
CloseFile(1)
PrintN("")
PrintN("Fertig !")

Temp$ = Input();
CloseConsole();
EndIf
End
Else
MessageRequester("Error","Cant open LPT ",0)
EndIf
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

Problem No. 1 is fixed (each B51000 one a separat page).
So only problem nr. 2 and nr. 3. are still open.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

Problem no. 3 ist almost fixed.
So only problem nr. 2 is open.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

is nobody there to help a beginner ?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

With the questions you're asking, it's easier to just write the program for you than to try and explain how to do it.

On the plus side, you seem to be doing well by just plugging away at it on your own. :)

You use FoundPos to return the position of B51000
You could look at storing everything up to FoundPos in a variable...
heading$=mid(text$,1,FoundPos)



Edited by - paul on 20 December 2001 19:39:20
Post Reply