AutoHotkey Community

It is currently May 27th, 2012, 8:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 78 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: March 4th, 2006, 1:48 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear PhiLho :) ,
I want one more feature (a bit tough for me to accomplish) to be included inside the parsing loop. Can you help me?... Please.

Regards, :)

Edit: I request you to save your code as .AHK and provide me with a link that will appear in the first post

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on March 5th, 2006, 2:15 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 1:52 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
PhiLho wrote:
Well, Titan's code is short and al, but it doesn't do true Rot13, which acts only on alphabetic characters and replaces them only by alphabetic chars...
Wrong!
I updated the algorithm (see my above post).. sorry for the initial mistake.

@Goyyah, you can upload scripts for free on the AutoHotkey.net file manager.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 2:06 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Titan, :)

you wrote:
you can upload scripts for free on the AutoHotkey.net file manager.


I am aware of that, and have been uploading lot of files. Thanks to you. But I thought you would like to put your version (as .AHK) on your homepage or something, and also you might want to include some note on Version number/Author etc.

Simply put, you modify your code and update your AHK and I dont have to update the download link that shall be on the first post.

Thanks again, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 2:10 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
I see your logic, clever.. okay, here's the link: http://www.autohotkey.net/~Titan/dl/StringMod.ahk.

I'm reluctant to include this script on my page becuase it's actually your creation and I don't want to steal your due credit :) If you'd like me to promote this script however, I'd be glad to do so.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Last edited by polyethene on February 17th, 2010, 6:03 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 2:30 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Titan, :)
You wrote:
I'm reluctant to include this script on my page becuase it's actually your creation and I don't want to steal your due credit If you'd like me to promote this script however, I'd be glad to do so


:) , I don't want any credit for this. If PhiLho had not spotted this function (in the original post) and spent his valuable time enhancing, it would have faded away!. StringMod() has been lucky twice, and you have enhanced it again.

Do whatever you want to do with the code but I request you that the function name remains StringMod(). Please!

And I invite you and everybody to promote this function.

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 4:10 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
OK, I uploaded the file to AutoHotkey.net.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 6:58 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear PhiLho & Titan, :)

SCRAMBLED / JUMBLED Words

Code:
String = AUTOHOTKEY
Loop, 33
   Str = % Str Scramble(String) Chr(10)
Msgbox,0, % String,% Str

Scramble(String)
{
Loop, Parse,String
 ReturnString = % ReturnString A_LoopField Chr(10)
Sort,ReturnString,Random
Null:= ""
StringReplace, String, ReturnString, `n, %Null%,All
return String
}


Sample output of above code for word "AUTOHOTKEY"

    OTUYTHOAEK
    KYOAETTOUH
    AETTOYUKHO
    TEYUOTAOHK
    HKTATYEOOU
    OYKATHEOTU
    KETOYTOHUA
    AEHTOOYUTK
    TTOYEKOHUA
    UAOEHKTYTO
    ETTHOOKAUY
    HOTUAYOTEK
    TOTUAOHYKE
    HOKYETTUOA
    OTEHOATKUY
    UOTYHEKOAT
    HAUTTOOYEK
    HOYATEOTKU
    OTKEOAYHUT
    KAOYHEUTOT
    UTHKEOTOYA
    UTHOTKYOEA
    TOYAUHETOK
    TTYAOKEHOU
    ETTUOHYKOA
    EAOUKTTOHY
    KHATYOUOTE
    UOOHAETKYT
    YOHEUOATKT
    TOYKAUETOH
    AOOHTETYKU
    YHTOTKAEUO
    OTAHTKEOUY


Can Scramble() be optimised & fit into StringMod() ? :roll:

like StringMod("AUTOHOTKEY","Scramble")

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 7:42 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Goyyah wrote:
Can Scramble() be optimised & fit into StringMod() ? :roll:
Done (http://www.autohotkey.net/~Titan/dl/StringMod.ahk)

_________________
GitHubScriptsIronAHK Contact by email not private message.


Last edited by polyethene on February 17th, 2010, 6:04 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 7:47 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
These are the functions I am using.
Code:
CharDrop(String,Chars) {
   Loop Parse, Chars
      StringReplace String, String, %A_LoopField%,,All
   Return String
}

CharKeep(String,Chars) {
   Loop Parse, String
      IfInString Chars, %A_LoopField%
         out = %out%%A_LoopField%
   Return out
}
They are simpler, but there are no branches with parameter comparison inside, so they must be faster. Most of the time, they are sufficient. They are so short that you normally just inline them, whithout the function wrapper around. Test them with
Code:
Text = *asd,f./?x
MsgBox % CharDrop(Text,"*,?")
MsgBox % CharDrop(Text,".,?/x")
MsgBox % CharKeep(Text,"dsa")
MsgBox % CharKeep(Text,"x,?f")
Creating a monster function, which does everything, might not be a very good idea. It will be slow, and if you only need one of its functionality, why would you include a large function and inflate your code?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 8:01 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Laszlo wrote:
Creating a monster function, which does everything, might not be a very good idea. It will be slow, and if you only need one of its functionality, why would you include a large function and inflate your code?
StringMod() is quite efficient (at least my version anyway) as it skips code that would not be needed to perform a given action. As the name itself implies, it's a fairly large combined collection of different string manipulation features that can be useful for numerous purposes. I do agree that it's large in code size, but it's easy to chop off the bits of code you don't need.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2006, 8:17 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Titan wrote:
StringMod() is quite efficient (at least my version anyway) ... it's easy to chop off the bits of code you don't need.
Inside the parse loop, you check at each character if the command is Rot, Flip, Replace, Only or something else. It is a bunch of comparisons, branches for each character. This way you save a few lines of code, but the function would be several times slower than necessary. Until AHK has no optimizing compiler, cutting up large functions is faster and easier to maintain. Also, deleting unnecessary functions would require the user to understand, edit and test the code.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2006, 8:16 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Titan, :D

You wrote:
Goyyah wrote:
Can Scramble() be optimised & fit into StringMod() ? :roll:
Done (http://www.autohotkey.net/~Titan/dl/StringMod.ahk)


Thanks a lot! :) :)
So quick!.. You are a Wizard!

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on March 5th, 2006, 9:11 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2006, 8:36 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Laszlo, :)

You wrote:
Creating a monster function, which does everything, might not be a very good idea. It will be slow, and if you only need one of its functionality, why would you include a large function and inflate your code?


Well, I need this function for a word game, in which I will be using most of the functionality of StrMod(). I will be posting the word game here.

You further wrote:
Until AHK has no optimizing compiler, cutting up large functions is faster and easier to maintain. Also, deleting unnecessary functions would require the user to understand, edit and test the code


Maybe, its a valid point. I will put on the first post the breakdown of StringMod() functionality.
Omit()
Only()
Flip()
Replace()
Scramble()


Titan may have to help me with Rot13() and Rot47() I guess.

and, let the users decide what they want to have.
IMHO, StringMod() is a good example of adding more power into one single Function. Also an example for Team work

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2006, 10:38 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Laszlo has a point that I wanted to make myself...
I played with the code given by Goyyah (and his algorithm) because it was fun, and the functions were, at start, kind of closely related.
Introducing the Rot functions was borderline...
Pushing functionnalities like scramble seems out of the scope of the function (despite the very generic function name), outside the initial algorithm because it no longer acts on individual characters, choosing what to do on them, but it changes char order, operating at global string scope. (Same for flip, but it is simple enough to be similar to the other functions.)

Having spent quite some time in both the Unix and the Windows, I am sometime splitted between Unix philosophy - make small programs doing little things, but powerful when combined using shell scripting, pipes, redirections etc., and the Windows philosophy - see MS Office or the UltraEdit juggernaut that seems to seduce many users: combining the base text editor with an hex editor, a FTP program, a diff, replacing in files and what's not.

It is seducing indeed: install one program and get most of the tools you need at once, under a consistent interface.
But it is limiting: what if you don't need the FTP? It takes disk space and inteface real estate for nothing. What if the diff doesn't offer all the features you need? You can use another diff tool (WinMerge is good :-)) but then you have a feature that is unused again.
Using separate tools has the advantage of offering flexibility: you get the right tools for you, and if you find a better one, you can switch.
And if you want a unique install program, use NSIS or some other install program (not InstallShield, better suited for monster programs like Office than to install small freewares, creating install programs twice the size of the installed binaries...).

Back to the topic, you can combine the best of both worlds: create several small, efficient satellite functions, and if really you like/need a consistent interface, create a StringMod function that calls these little functions depending on the asked task.
This way, it is easier to pick only the functions you need without having to hack the big function.

Now, Goyyah has a point too: making this function was fun and allowed to exchange points of view on coding! :-)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2006, 12:59 pm 
Beside the fact that from a(n old fashioned) users point of view - not to waste disk space/memory (regardless that his become cheap) is something I'm still attracted to - I've swapped from the "one script fits all" fshioned scripting to a more modulized form, using #Includes as much as possible. It has decreased the time I wasted to identify a piece of code and its dependencies within a huge script. And maintenance aka an Upgrade/Update/Replacement has become definitely more easiely.

JM2€C. 8)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 78 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, Aravind, Bing [Bot], Google Feedfetcher, Stigg and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group