Jump to content

Issue with _StringInsert


charon
 Share

Recommended Posts

I need to insert a quote at the end of a string so I thought I could use _StringInsert with a negative value for last position but doesn't seem to work. I suppose I could use stringlen to get the length of each string and insert it that way.  Output is:

setup channel1 input "V:MediaTVAbott-CostelloMoviesAbbott & Costello -- Meet Frankenstein (1948).div"x
 

$sInsertString = 'setup channel' & $channel & ' input "' & $dir & '\'
$sInsertString2 = '"'

   Local $aArray = _FileListToArrayRec($dir, "*.avi;*.mkv;*.mp4;*.divx||*.*", 13, 1, 1, 1)
    ConsoleWrite("Error: " & @error & " - " & " Extended: " & @extended & @CRLF)
    _ArrayDisplay($aArray, "Sorted tree")

;extract artist from first index and compare with previous value to see if it changes and update channel
    local $sString[2]
    $iPosition = StringInStr($aArray[2], "\")
    $sString[0] = StringLeft($aArray[2], $iPosition -1) ; Retrieve 5 characters from the left of the string.
    $sString[1] = StringLeft($aArray[2], $iPosition -1)
    ;MsgBox(0, "", "string: " & $sString[0])

 For $i = 2 To $aArray[0] +1
    $iPosition = StringInStr($aArray[$i], "\")
    $sString[1] = StringLeft($aArray[$i], $iPosition -1) ; Retrieve 5 characters from the left of the string.
    If $sString[0] <> $sString[1] Then
        ;MsgBox(0, "", "change found string: " & $sString[1])
        $sString[0] = $sString[1]
        $channel = $channel +1
        ;$sInsertString = 'setup channel' & $channel & ' input "v:\Media\Music-MP3\Music-Master\'
        $sInsertString = 'setup channel' & $channel & ' input "' & $dir & '\'
        ;_ArrayInsert($aArray[$i], $i, "new channel" & $channel & " broadcast enabled loop")
    EndIf
    $aArray[$i] = _StringInsert ( $aArray[$i], $sInsertString, 0)  ;left side so we are inserting  at the beginning of line
    $aArray[$i] = _StringInsert ( $aArray[$i], $sInsertString2, -1) ;right side insert a quote at end
    ;$aArray[$i] = StringTrimRight($aArray[$i], 1) ;
Next
_ArrayDisplay($aArray, "Sorted tree")
EndFunc
Link to comment
Share on other sites

It doesn't exist probably because you can just

$aArray[$i]&=$sInsertString2

Welp you got it :P I gave you the short-handed version of what you put.

Edited by Mechaflash
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

Good to see you're adopting new function charon.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...