Sign in to follow this  
Followers 0
se7enGBSk

repeat sentence nr. 7

6 posts in this topic

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:

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

the text is much longer and all together i have 2 repeat the sentence about 10 times .

and i dont want to edit 10 sentence next time .

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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 )

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0