litlmike Posted September 13, 2006 Posted September 13, 2006 Goal:Take a string that has "; The" in it and put the "; The" at the beginning of the string. For Instance, "Gordon's Guide; The" should turn into "The Gordon's Guide".Problem:I can only get "Gordon's Guide; The" to turn into " The Gordon's Guide" (note the space before The).Solution:Let me know if there is a way to make the delimiter be 2 characters like "; ". Or if there is an entirely different way to approach this problem. My sample code is below.Thanks in Advance.Func Split() $string ="Gordon's Guide; The" $delim = ";" $stringsplit = StringSplit ($string, $delim) $newstring = $stringsplit[2] & " " & $stringsplit[1] ToolTip ($newstring) EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Xenobiologist Posted September 13, 2006 Posted September 13, 2006 HI, for this example it works $string = "Gordon's Guide; The" MsgBox(0, "", Split($string)) Func Split($string) If StringInStr($string, "; The") <> 0 Then Return StringReplace(StringRight(StringMid($string, StringInStr($string, "; The"), 5), 3) & " " & StringLeft($string, StringInStr($string, "; The")),';', '') Else Return - 1 EndIf EndFunc ;==>Split So long, Mega 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
blademonkey Posted September 13, 2006 Posted September 13, 2006 litlmike said: Goal: Take a string that has "; The" in it and put the "; The" at the beginning of the string. For Instance, "Gordon's Guide; The" should turn into "The Gordon's Guide". Problem: I can only get "Gordon's Guide; The" to turn into " The Gordon's Guide" (note the space before The). Solution: Let me know if there is a way to make the delimiter be 2 characters like "; ". Or if there is an entirely different way to approach this problem. My sample code is below. Thanks in Advance. Func Split() $string ="Gordon's Guide; The" $delim = ";" $stringsplit = StringSplit ($string, $delim) $newstring = $stringsplit[2] & " " & $stringsplit[1] ToolTip ($newstring) EndFunc from the help Quote Splits up a string into substrings depending on the given delimiters. StringSplit ( "string", "delimiters" [, flag ]) Parameters string The string to evaluate. delimiters One or more characters to use as delimiters. flag [optional] If flag is 0 (the default), then each character in the delimiter string will mark where to split the string. If flag is 1, then the entire delimiter string is needed to mark the split. so try $delim = "; " $stringsplit = StringSplit ($string, $delim,1) ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung
Moderators SmOke_N Posted September 13, 2006 Moderators Posted September 13, 2006 The below could be made with a loop to return all the delimeters, it's just a proof of concept with StringInStr()$String = "Gordon's Guide; The" MsgBox(0, '', _StringSplit2Chars($String, '; ')) Func _StringSplit2Chars($sString, $vDelim) Local $nSns = StringInStr($sString, $vDelim) Local $sTemp = StringLeft($sString, $nSns - 1) Return StringTrimLeft($sString, $nSns + 1) & ' ' & $sTemp EndFuncoÝ÷ Ù8^méh·¡ë'ßÛ]¡©ò¶§»Âʰj{ZºÚ"µÍÌÍÔÝ[ÈH ][ÝÑÛÜÛÌÎNÜÈÝZYNÈI][ÝÂÙÐÞ ÌÎNÉÌÎNËÔÝ[ÔÝÚ]Ú ÌÍÔÝ[Ë ÌÎNÎÉÌÎNÊJB[ÈÔÝ[ÔÝÚ]Ú ÌÍÜÔÝ[Ë ÌÍÝ[[JBSØØ[ ÌÍØTÜ]BRY ÌÍÝ[[HHÔ[BIÌÍØTÜ]HÝ[ÔÜ] Ý[ÔÝÔ ÌÍÜÔÝ[ÊKBBRY ÌÍØTÜ]ÌH È[]Ù]ÜK BBT]Ý[ÔÝÔÊ ÌÍØTÜ]ÌK ÊH [È ÌÎNÈ ÌÎNÈ [È ÌÍØTÜ]ÌWBQ[YBIÌÍØTÜ]HÝ[ÔÜ] ÌÍÜÔÝ[Ë ÌÍÝ[[JBRY ÌÍØTÜ]ÌH È[]Ù]Ü BT]Ý[ÔÝÔÊ ÌÍØTÜ]ÌK ÊH [È ÌÎNÈ ÌÎNÈ [È ÌÍØTÜ]ÌWB[[ Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Moderators SmOke_N Posted September 13, 2006 Moderators Posted September 13, 2006 (edited) Here, this should do like what StringSplit() does, but for mulltiple chars:$String = "Gordon's Guide; silly; The" $aSplit = _StringSplitEx($String, '; ') If IsArray($aSplit) Then For $iCC = 1 To UBound($aSplit) - 1 MsgBox(0, 'Element ' & $iCC, $aSplit[$iCC]) Next EndIf Func _StringSplitEx($sString, $vDelim, $iCase = Default, $vSSDelim = '') If $iCase = Default Or $iCase = -1 Then $iCase = 0 Local $nSnS, $sHold If Not StringInStr($sString, $vDelim, $iCase) Then Return SetError(1, 0, 0) While StringLen($sString) > 0 $nSnS = StringInStr($sString, $vDelim, $iCase) If Not $nSnS Then ExitLoop $sHold &= StringLeft($sString, $nSnS - 1) & $vSSDelim $sString = StringTrimLeft($sString, $nSnS + 1) WEnd $sHold &= $sString Return SetError(0, 0, StringSplit($sHold, $vSSDelim)) EndFunc Edit: Added case sense and an error check. Edited September 13, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
litlmike Posted September 13, 2006 Author Posted September 13, 2006 Well thanks everyone for the great help! It always amazes me how far advanced some of you are, I wouldn't have even thought of taking the route some of you did. I came up with a suitable solution by using some of the code from each of your suggestions. This mini-script is going into my all-encompassing script, and I had a little difficulty mering it in. But by using a bit of a hybrid from your suggestions here is what I came up with, and it works. Let me know if there is a more efficient way to do it. THanks again! Func Split_Company_Names () $string = $company $delim = "; " If StringInStr($string, "; The") <> 0 Then $stringsplit = StringSplit ($string, $delim, 1) $newstring = $stringsplit[2] & " " & $stringsplit[1] ToolTip ($newstring) $company = $newstring EndIf ToolTip ("") EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Xenobiologist Posted September 13, 2006 Posted September 13, 2006 HI, what about : $company = "Gordon's Guide; The" MsgBox(0, "", Split_Company_Names($company, "; ")) Func Split_Company_Names($string, $delim) If StringInStr($string, $delim) <> 0 Then $stringsplit = StringSplit($string, $delim, 1) Return $stringsplit[2] & " " & $stringsplit[1] EndIf Return -1 EndFunc ;==>Split_Company_Names So long, Mega 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
MHz Posted September 14, 2006 Posted September 14, 2006 litlmike said: Func Split() $string ="Gordon's Guide; The" $delim = ";" $stringsplit = StringSplit ($string, $delim) $newstring = $stringsplit[2] & " " & $stringsplit[1] ToolTip ($newstring) EndFuncoÝ÷ Ûú®¢×¥u©pk+.±ç«®Üç$x-¢Æ¯yجjh{fz{^²©eË^ë"®)àJb´âµê뢻!z·éò¢ì"[-Y`zܨºº+§j[-®)àën®wjëh×6 $company = "Gordon's Guide; The" $return = Delim_Company_Names($company, "; ") If Not @error Then MsgBox(0, 'Result', $return) Else MsgBox(0, 'Oh No', 'We have a problem') EndIf Func Delim_Company_Names($string, $delim) $stringsplit = StringSplit($string, $delim, 1) If Not @error And $stringsplit[0] = 2 Then Return $stringsplit[2] & " " & $stringsplit[1] Else Return SetError(1, 0, $string) EndIf EndFunc oÝ÷ Øíë-®)àˬi¹^Â+a¢¼"¶.µê뢺¶¬x%y×¥hz»az|¨¹Ê.×(Èz°rEçèØ^²Úâ-¢·v¯j¸nWºÚ"µÍÌÍØÛÛ[HH ][ÝÑÛÜÛÌÎNÜÈÝZYNÈI][ÝÂ[[WÐÛÛ[WÓ[YÊ ÌÍØÛÛ[K ][ÝÎÈ ][ÝÊBÙÐÞ ÌÎNÉÌÎNË ÌÍØÛÛ[JB[È[[WÐÛÛ[WÓ[YÊTY ÌÍÜÝ[Ë ÌÍÙ[[JBIÌÍÜÝ[ÜÜ]HÝ[ÔÜ] ÌÍÜÝ[Ë ÌÍÙ[[KJBRYÝÜ[ ÌÍÜÝ[ÜÜ]ÌHH[BIÌÍÜÝ[ÈH ÌÍÜÝ[ÜÜ]ÌH [È ][ÝÈ ][ÝÈ [È ÌÍÜÝ[ÜÜ]ÌWB[Y[[Â
litlmike Posted September 14, 2006 Author Posted September 14, 2006 First, let me say many thanks for taking a look at this.@Mega & @MHZI really like what the both of you put together, but I am having quite some trouble importing your scripts into my script. And I have no clue what I am missing. So, I am going to post the scripts involed and hopefully you can help me crack the case.The 3 sections of code are on 3 separate .au3 filesThanks in Advance.Calling Script (file 1)expandcollapse popup#include <EmailCat_Date.au3> #include <ACT_Copy_For_Email.au3> #include <Eudora_Change.au3> #include <GUI_Assistant_Me.au3> #include <Splitting_Strings.au3> HotKeySet ("+!^y", "BasicEmail") Func BasicEmail() ;Func to add in basic info for emails EmailCat_Date () Activate_ACT () ACT_Copy_For_Email () ; [color=#CC0000]this is where $company comes from, it is a Global Variable[/color]Split_Company_Names () Activate_Eudora () Eudora_Change () GUI_Assistant_Me () ;Return EndFuncoÝ÷ ÚæÌzßè¬ÁÙßÛr¸©· .Ø(êÞý¿îzeiǨ~lªiÊÇ+_W¶jëh×6Func Split_Company_Names () $string = $company $delim = "; " If StringInStr($string, "; The") <> 0 Then $stringsplit = StringSplit ($string, $delim, 1) $newstring = $stringsplit[2] & " " & $stringsplit[1] ToolTip ($newstring) $company = $newstring EndIf ToolTip ("") EndFuncoÝ÷ ÚæÅv¥IÊâ¦ßÛþçâíÚºÚ"µÍÛØ[ ÌÍØØ]ÌK ÌÍÙ]WØK ÌÍÙ[XZ[ ÌÍØÛÛXÝ ÌÍØÛÛ[K ÌÍÙ[XZ[[È]YÜWÐÚ[ÙH BÑØÝÈÛÛÛXÐÞÚ] ÛÛIÝËÜÚÝ[ÑÂÌÍØØ]ÌPHHÕRPÝXY ÌÍØØ]ÌJBÌÍÙ]WØWÐHHÕRPÝXY ÌÍÙ]WØJBÛÛÛÛÛ[X[ ][ÝÑ]YÜI][ÝË ][ÝÉ][ÝË ][ÝÐÛÛXÐÞÉ][ÝË ][ÝÔÙ]Ý[Ù[XÝ[Û][ÝË BÛÛÛÙ]^ ][ÝÑ]YÜI][ÝË ][ÝÉ][ÝË ][ÝÑY]I][ÝË ÌÍÙ[XZ[ BÛÛÛÙ]^ ][ÝÑ]YÜI][ÝË ][ÝÉ][ÝË ][ÝÑY]É][ÝË ][ÝÐU ][ÝÈ [È ÌÍØÛÛXÝ BÛÛÛØÝÊ ][ÝÑ]YÜI][ÝË ][ÝÉ][ÝË ][ÝÑ]YÜQY]I][ÝÊBÌÍÙ[XZ[ØÙHHÛÛÛÙ]^ ][ÝÑ]YÜI][ÝË ][ÝÉ][ÝË ][ÝÑ]YÜQY]I][ÝÈ BÌÍÐYÝ×Ó]ÈHÝ[ÔXÙH ÌÍÙ[XZ[ØÙK ][ÝÓ][ÝË ÌÍØÛÛXÝ BÌÍÐYÝ×Ó]ÐHHÝ[ÔXÙH ÌÍÐYÝ×Ó]Ë ][ÝÖ ][ÝË ÌÍØÛÛ[JBÌÍÐYÝ×Ó]ÐHÝ[ÔXÙH ÌÍÐYÝ×Ó]ÐK ][ÝÖ][ÝË ÌÍØØ]ÌPJHÔ]Ø]YÛÜH[[XZ[ÌÍÐYÝ×Ó]ÐÈHÝ[ÔXÙH ÌÍÐYÝ×Ó]Ð ][ÝÖÐTÒSQSUWI][ÝË ÌÍÙ]WØWÐJHÔ]Ø]YÛÜH[YÝÂÛÛÛÙ]^ ][ÝÑ]YÜI][ÝË ][ÝÉ][ÝË ][ÝÑ]YÜQY]I][ÝË ÌÍÐYÝ×Ó]ÐÈ BÔ][[ _ArrayPermute()_ArrayUnique()Excel.au3 UDF
litlmike Posted September 14, 2006 Author Posted September 14, 2006 Anyone have an idea, why I can't merge these successfully? _ArrayPermute()_ArrayUnique()Excel.au3 UDF
MHz Posted September 15, 2006 Posted September 15, 2006 Not sure of a common link to merge your scripts, but I will suggest xomething similar to what you already have. Call the function from where you called your previous function. Split_Company_Names($company) oÝ÷ Ù8b³ .ÖÞÊ«~)^Ù«¢+Ø)Õ¹MÁ±¥Ñ} ½µÁ¹å}9µÌ¡ åIÀÌØíÍÑÉ¥¹°ÀÌØí±¥´ôÌäììÌäì¤(%Q½½±Q¥À ÅÕ½ÐìÅÕ½Ðì¤(1½°ÀÌØíÍÁ±¥ÐôMÑÉ¥¹MÁ±¥Ð ÀÌØíÍÑÉ¥¹°ÀÌØí±¥´¤(%9½ÐÉɽȹÀÌØíÍÁ±¥ÑlÁtôÈQ¡¸(ÀÌØíÍÑÉ¥¹ôMÑÉ¥¹MÑÉ¥Á]L ÀÌØíÍÁ±¥ÑlÉtµÀìÅÕ½ÐìÅÕ½ÐìµÀìÀÌØíÍÁ±¥ÑlÅt°Ì¤(¹%)¹Õ¹
litlmike Posted September 15, 2006 Author Posted September 15, 2006 MHz said: Not sure of a common link to merge your scripts, but I will suggest xomething similar to what you already have.Shoots...he scores!Thanks MHZ that did it! Not sure how I missed that, but thanks! _ArrayPermute()_ArrayUnique()Excel.au3 UDF
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