DarkBoost Posted April 15, 2009 Share Posted April 15, 2009 I am sorry for such a simple query but I am struggling to find the answer "LetterCount()" obviously does not exist: ;Example $word = "hello" MsgBox(0,"",$word & " has (" & LetterCount($word) & ") letters") Link to comment Share on other sites More sharing options...
KaFu Posted April 15, 2009 Share Posted April 15, 2009 This will do. MsgBox(0,"",ubound(stringsplit("hello",""))-1) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
herewasplato Posted April 15, 2009 Share Posted April 15, 2009 (edited) StringLenor here http://www.autoitscript.com/forum/index.ph...st&p=322262 Edited April 15, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
DarkBoost Posted April 15, 2009 Author Share Posted April 15, 2009 @herewasplato... champion!!! Link to comment Share on other sites More sharing options...
DarkBoost Posted April 15, 2009 Author Share Posted April 15, 2009 thanks for the quick responses. i have a text document with 500+ employee's names and trying to create a script which will scramble the words... like a game... and output to another text document for staff to play. original text document (correct names): bruce wayne peter parker bruce banner ... new text document (scrambled): eurbc neywa = eetpr rkrape = bceur nneabr = ... I am unsure which approach to take to achieve this and if their may already be a simple String command which may easily achieve this. Link to comment Share on other sites More sharing options...
youknowwho4eva Posted April 15, 2009 Share Posted April 15, 2009 first you want to separate the first and last name so they don't get mixed. So you want to use string split Next you want to split up the letters using a for loop and stringtrimleft or right. Then use random to scramble them up. The For loop to get the letters will probably take some work, just look up the functions in the help file Giggity Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 15, 2009 Share Posted April 15, 2009 Why do random when you can have fun? #include <INet.au3> #include <String.au3> #include <Array.au3> _Main() Exit Func _Main() Local $aNames[3][2] = [["bruce wayne", ""], ["peter parker", ""], ["bruce banner", ""]], $i For $i = 0 To 2 $aNames[$i][1] = _GetAnagram($aNames[$i][0]) Next _ArrayDisplay($aNames) EndFunc Func _GetAnagram($sString) $sString = StringReplace($sString, " ", "+") Local $sURL = "http://www.anagramgenius.com/server.php?source_text=" & $sString & "&emphasis=1&gender=2&vulgar=0&seen=true" Local $sSource = _INetGetSource($sURL) If @error Then Return SetError(1, 0, "") Local $aResults = StringRegExp($sSource, "(?U)<span class=""black-18"">.*</span>", 3) If @error Then Return SetError(2, 0, "") Local $aAnagrams = _StringBetween($aResults[1], "<span class=""black-18"">'", ".'</span>") If @error Then Return SetError(3, 0, "") Return SetError(0, 0, StringLower($aAnagrams[0])) EndFunc WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
zorphnog Posted April 15, 2009 Share Posted April 15, 2009 I was bored, so... expandcollapse popup#include <Array.au3> Dim $aResult[1] $sInfile = @ScriptDir & "\names.txt" $sOutfile = @ScriptDir & "\scramble.txt" $hInfile = FileOpen($sInfile, 0) $hOutfile = FileOpen($sOutfile, 2) If $hInfile <> -1 And $hOutfile <> -1 Then While 1 $sFullname = FileReadLine($hInfile) If @error Then ExitLoop $aFullname = StringSplit($sFullname, " ") If IsArray($aFullname) Then ReDim $aResult[$aFullname[0]] For $i=1 To $aFullname[0] $aResult[$i - 1] = _ScrambleWord($aFullname[$i]) Next FileWriteLine($hOutfile, _ArrayToString($aResult, " ")) EndIf WEnd FileClose($hInfile) FileClose($hOutfile) EndIf Func _ScrambleWord($sWord) Local $aScramble[1] Local $aWord = StringSplit($sWord, "", 2) If IsArray($aWord) Then While UBound($aWord) > 1 $iIdx = Random(0, UBound($aWord) - 1, 1) _ArrayAdd($aScramble, $aWord[$iIdx]) _ArrayDelete($aWord, $iIdx) WEnd _ArrayAdd($aScramble, $aWord[0]) _ArrayDelete($aScramble, 0) Return _ArrayToString($aScramble, "") EndIf Return "" EndFunc Link to comment Share on other sites More sharing options...
Mat Posted April 15, 2009 Share Posted April 15, 2009 @WBD LOL!!!! what happens if an anagram cannot be found? you should use a backup standard (boring...) scrambler. PS. added all that password stuff to the UDF of yours, a bit off topic but ah well AutoIt Project Listing Link to comment Share on other sites More sharing options...
spudw2k Posted April 15, 2009 Share Posted April 15, 2009 StringLenThat's along the lines of what I was thinkin. StringLen(StringRegExpReplace($str,"[^A-z]","")) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
herewasplato Posted April 16, 2009 Share Posted April 16, 2009 ... trying to create a script which will scramble the words... like a game...Just be sure that you do not generate some "not safe for work" words :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now