Jump to content

repeat sentence nr. 7


Recommended Posts

hey is there a way to repeat a sentence, without writing the whole stuff again ?

like on sentence nr 7. i have send("TEXT")

and i want to repeat the same on nr 40.

next time it needs to send("TEXT1") and i dont want to edit everything again and again

tnks for any help :mellow:

Link to comment
Share on other sites

That's what functions are for.

But in your case it wouldn't save you a lot.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If you have to repeat lines of code at different places of your script a function is definitely the way to go.

If the text changes pass the whole text or just the changing part to the function and do what processing it needs in the function.

If you can provide a code snippet then it's much easier to help :mellow:

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If you have to repeat lines of code at different places of your script a function is definitely the way to go.

If the text changes pass the whole text or just the changing part to the function and do what processing it needs in the function.

If you can provide a code snippet then it's much easier to help :mellow:

ok here is a part of the cod

Run("C:\Programme\uTorrent\uTorrent.exe")
sleep(1000)
send("^n")
sleep(500)
[b]
 send("C:\Dokumente und Einstellungen\All Users\Dokumente\Eigene Musik\Beispielmusik")
[/b]
...........
send("{tab}")
    send("{enter 2}") 
WinWaitActive("Speicherort für .torrent wählen.")
winactive("Speicherort für .torrent wählen.")
send("{enter}")

the thing is i need the

send("C:\Dokumente und Einstellungen\All Users\Dokumente\Eigene Musik\Beispielmusik")

several times now. an next time its maybe : D:\dontknow\here\...

( thats y i want to repeat it, because so i just need to edit it once and not several times )

Link to comment
Share on other sites

Ok, in this case I would use variables.

Global $Loc_BM = "C:\Dokumente und Einstellungen\All Users\Dokumente\Eigene Musik\Beispielmusik"
Global $Loc_DK = "D:\dontknow\here\..."

send($Loc_BM) ; <== Line 7
...........
send($Loc_BM) ; <== Line 40

So there is only one place in your script for the strings. You change it only once.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...