Jump to content

Enter a new line after replace a string in file


MrDTeach
 Share

Recommended Posts

Hello guys,

I have two problems.

At first I try to enter a new line, but it dosn't work and I try to enter a tab and it dosn't work, too.

attatched my script. 

$vorname = InputBox ( "Vorame", "Bitte den Vorname eingeben.") ; Vorname eingeben
$nachname = InputBox ( "Nachname", "Bitte den Nachname eingeben.") ; Nachname eingeben
$kuerzel = InputBox ( "Kuerzel", "Bitte das Kuerzel eingeben.") ; Kuerzel eingeben
$position = InputBox ( "Position", "Bitte die Position eingeben.") ; Position eingeben
$durchwahl = InputBox ( "Durchwahl", "Bitte die Durchwahl eingeben.") ; Druchwahl eingeben
$handy = InputBox ( "Handynummer", "Bitte die Handynummer, im Format +49 160 1234567 eingeben. Wenn keine Handynummer vorhanden ist, eine Nein eintragen.") ; Handynummer eingeben
$email = $vorname&'.'&$nachname&'@test.de'

$file = FileOpen("path\SignaturAntwort.htm", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Ersetze Suchstring durch Eingaben
$chars = FileRead($file)
$chars=stringreplace($chars,"#Vorname#",$vorname)
$chars=stringreplace($chars,"#Nachname#",$nachname)
$chars=stringreplace($chars,"#Position#",$position)
If $handy = "Nein" Then
        $chars=stringreplace($chars,"#Durchwahl#",$durchwahl)
        $chars=stringreplace($chars,"#Handy#","")
    Else
        $chars=stringreplace($chars,"#Durchwahl#",$durchwahl@CRLF)
        $chars=stringreplace($chars,"#Handy#",'Mobil'@TAB&$handy)
EndIf
$chars=stringreplace($chars,"#Mail#",$email)
filewrite('path\'&$kuerzel&'_Antwort.htm', $chars)

FileClose($file)

Best regards

MrDTeach

Edited by Jos
Just put the code in the post in stead of attachment
Link to comment
Share on other sites

  • Developers
12 minutes ago, MrDTeach said:

$durchwahl@CRLF

should be:

$durchwahl & @CRLF

..and ...

12 minutes ago, MrDTeach said:

'Mobil'@TAB&$handy

should be:

'Mobil' & @TAB & $handy

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You mean there is a & @crlf missing after your Telefonnummer?

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Do you view your file in a browser? Maybe then you need to use html tags like <br>

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Developers

Like @Xenobiologist states: Those characters are there but won't be shown in any browser program as HTML doesn't support TAB en CRLF.
Open the file in SciTE or Notepad and you will see they are there.

Jos

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
3 minutes ago, MrDTeach said:

Do you know the characters for the tabulator? 

There is no HTML alternative for TAB. Commonly they use <Table> when things need to be aligned. 
Just play with these files manually until you have the appropriate formatted text figured out and then you make the Logic in AutoIt3 to do that automatically. ;)  

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...