Rex Posted January 16, 2010 Posted January 16, 2010 (edited) Hi I'm using this code to split inputs into groups of 56 chars $String = "232121-232323-232323-232323-232323-232323-784512-895623-235689-784512-134679-976431-852963-362514-784596-aswert-klionm-tyghbn-yhntgb-pæøåoi-ujmtgb-edfrtg-qaswed-vfryhn-uytrfg-oiuytr-åååååå" $len = StringLen($String) if $len > "224" Then $String4 = StringRight(StringRight(StringRight(StringLeft($String, 224), 168),112),56) $String3 = StringRight(StringRight(StringLeft($String, 168), 112),56) $String2 = StringRight(StringLeft($String, 112), 56) $String1 = StringLeft($String, 56) ConsoleWrite("Strengens Længde = " & $len & @CRLF & "Strengen der bliver splittet = " & $String & @CRLF & "Streng 1 = " & $String1 & @CRLF & _ "streng 2 = " & $String2 & @CRLF & "Streng 3 = " & $String3 & @CRLF & "Streng 4 = " & $String4 & @CRLF) ElseIf $len > "168" Then $String4 = StringRight(StringRight(StringRight(StringLeft($String, 224), 168),112),56) $String3 = StringRight(StringRight(StringLeft($String, 168), 112),56) $String2 = StringRight(StringLeft($String, 112), 56) $String1 = StringLeft($String, 56) ConsoleWrite("Strengens Længde = " & $len & @CRLF & "Strengen der bliver splittet = " & $String & @CRLF & "Streng 1 = " & $String1 & @CRLF & _ "streng 2 = " & $String2 & @CRLF & "Streng 3 = " & $String3 & @CRLF & "Streng 4 = " & $String4 & @CRLF) ElseIf $len > "112" Then $String3 = StringRight(StringRight(StringLeft($String, 168), 112),56) $String2 = StringRight(StringLeft($String, 112), 56) $String1 = StringLeft($String, 56) ConsoleWrite("Strengens Længde = " & $len & @CRLF & "Strengen der bliver splittet = " & $String & @CRLF & "Streng 1 = " & $String1 & @CRLF & _ "streng 2 = " & $String2 & @CRLF & "Streng 3 = " & $String3 & @CRLF) ElseIf $len > "56" Then $TrimR = $len - 56 $String2 = StringRight($String, $TrimR) $String1 = StringLeft($String, 56) ConsoleWrite("Strengens Længde = " & $len & @CRLF & "Strengen der bliver splittet = " & $String & @CRLF & "Streng 1 = " & $String1 & @CRLF & _ "streng 2 = " & $String2 & @CRLF) EndIf But for some reason i get "doubles" when i have > 112 chars but i can't see why can any of u throw me a bone, to what's wrong with my code Cheers /Rex Edited August 22, 2010 by Rex
Xenobiologist Posted January 16, 2010 Posted January 16, 2010 Does this function help you? expandcollapse popup;~ Beispieltext von http://de.wikipedia.org/wiki/AutoIt ;$String = "Die Skripteermöglichenz.B. das Ausführen von Programmen, das Simulieren von Tastaturanschlägen bzw. Mausklicks. Es können einfache Textfunktionen der Zwischenablage oder auch Windowsfunktionen (wie z. B. minimieren, verstecken, Warten auf/Aktivieren von Fenstern) aufgerufen werden. Seit Version 3 können zudem graphische Benutzeroberflächen mit zahlreichen Controls entworfen werden. Soll es um Registrymanipulationen oder komplexere Schleifen gehen, ist AutoIt 3 inzwischen mit seiner verbesserten Syntax deutlich einfacher zu handhaben als frühere Versionen. Es ist möglich, AutoIt mit anderen Scriptsprachen wie WSH oder Kixtart zu kombinieren (AutoItX)." $String = "232121-232323-232323-232323-232323-232323-784512-895623-235689-784512-134679-976431-852963-362514-784596-aswert-klionm-tyghbn-yhntgb-pæøåoi-ujmtgb-edfrtg-qaswed-vfryhn-uytrfg-oiuytr-åååååå" MsgBox(0, "Original", $String) ; Original-Text MsgBox(0, "Softbreak", _StringInsertLF($String, 56)) ; Softbreak nach 50 Zeichen MsgBox(0, "Hardbreak", _StringInsertLF($String, 56, 1)) ; Hardbreak nach 50 Zeichen ;=============================================================================== ; ; Description: Fügt @LF in Strings ein ; Parameter(s): $strString = String der bearbeitet werden soll ; $nCount = Anzahl der Zeichen bevor @LF eingefügt werden soll ; (optional) $cBreaking = 0 (default) -> Softbreak (an Wortgrenze) ; 1 -> Hardbreak ; ist kein Leerzeichen im String enthalten wird hart ; umgebrochen ; Requirement(s): keine ; Return Value(s): String mit @LF ; Author(s): bernd670 ; ;=============================================================================== Func _StringInsertLF($strString, $nCount, $cBreaking = 0) Local $strRetString = "", $nPos Do ; If Stringlen($strString) > $nCount Then $nPos = StringInStr(StringLeft($strString, $nCount + 1), " ", 0, -1) If ($nPos And $cBreaking = 0) Then $strRetString &= StringLeft($strString, $nPos - 1) & @LF $strString = StringMid($strString, $nPos + 1) Else $strRetString &= StringLeft($strString, $nCount) & @LF $strString = StringMid($strString, $nCount + 1) EndIf ; EndIf Until StringLen($strString) < $nCount $strRetString &= $strString Return $strRetString EndFunc ;==>_StringInsertLF 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
Moderators Melba23 Posted January 16, 2010 Moderators Posted January 16, 2010 (edited) Rex,I would split the string like this:$sString = "232121-232323-232323-232323-232323-232323-784512-895623-235689-784512-134679-976431-852963-362514-784596-aswert-klionm-tyghbn-yhntgb-pæøåoi-ujmtgb-edfrtg-qaswed-vfryhn-uytrfg-oiuytr-åååååå" $nSubStrings = (StringLen($sString) + 1) / 63 ConsoleWrite("Strengens Længde = " & StringLen($sString) & @CRLF & "Strengen der bliver splittet = " & $sString & @CRLF) $iSubstrings = Ceiling($nSubStrings) Global $aCutStrings[$iSubstrings] For $i = 0 To $iSubstrings - 1 $aCutStrings[$i] = StringMid($sString, (63 * $i) + 1, 62) ConsoleWrite("Streng " & $i + 1 & " = " & $aCutStrings[$i] & @CRLF) NextI hope this helps! M23Edit: Just remembered Ceiling! Edited January 16, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jchd Posted January 16, 2010 Posted January 16, 2010 I'm using this code to split inputs into groups of 56 chars But for some reason i get "doubles" when i have > 112 chars but i can't see whyYou're making this unduly complicated. Try this: #include <Array.au3> Local Const $limit = 56 Local $String = "232121-232323-232323-232323-232323-232323-784512-895623-235689-784512-134679-976431-852963-362514-784596-aswert-klionm-tyghbn-yhntgb-pæøåoi-ujmtgb-edfrtg-qaswed-vfryhn-uytrfg-oiuytr-åååååå" Local $len = StringLen($String) Local $nbStr = Floor(($len + $limit - 1) / $limit) Local $aStrings[$nbStr] For $i = 0 To $nbStr - 1 $aStrings[$i] = StringLeft($String, $limit) $String = StringTrimLeft($String, $limit) Next _ArrayDisplay($aStrings) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Rex Posted January 16, 2010 Author Posted January 16, 2010 Wow I just posted this And already got 3 responses, Cool I'll look at em and post back (need to find out how to put it into this (http://www.autoitscript.com/forum/index.php?showtopic=108385) Cheers /Rex
Rex Posted August 22, 2010 Author Posted August 22, 2010 WowI just posted this And already got 3 responses, Cool I'll look at em and post back (need to find out how to put it into this (http://www.autoitscript.com/forum/index.php?showtopic=108385)Cheers/RexI'm a fool to write back when something works I used Jchd's version in my script THXand sry for the late replyCheers/Rex
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