cyanidemonkey

How to stop string delimiter in _ArrayAdd?

13 posts in this topic

This is probably a very simple thing to resolve, but I could not figure it out from the AutoIt Help, or find it on the forums.

I want to use _ArrayAdd with delimiter feature off. I have an issue where a randomly generated string sometimes contains a pipe and is splitting the string. Because it is random string generation (not controlled by me) I can not simply switch the delimiter to another character without the probability it would also randomly break the string.


My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could probably use something like ChrW(63743) for the delimiter. How many characters are in the random selection? How is the random string generated?

_ArrayAdd ($aArray, $vValue, $iStart, ChrW(63743))

 

Edited by czardas

Share this post


Link to post
Share on other sites

cyanidemonkey,

Are you adding a single item each time to a 1D array?

If so, use the $ARRAYFILL_FORCE_SINGLEITEM parameter as explained in the Help file.

If not, then you need to do as czardas has suggested and force the delimiter to a character which is not going to be used - 0xEF0F is from the user-defined set and should pose no problems with normal characters in any language.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

czardas,

I added that after the last round of complaints.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Cannot you just do some replacement (substitution) method in the randomly generated string, before the array is made, which gets restored during a read of the array. For example, use an uncommon ASC II character or combination.


TheSaints' Robust Chat

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox

userbar.png

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Not really because the problem still remains and you would also have to loop through the array to make the replacements. The characters me and M23 suggested do not exist in any language. In fact this Unicode range is intended for private use, and this is an example of where such characters can come into play. If they do happen to occur within the string (highly unlikely), then you can simply loop through the range until one is found that is not contained within the string. The likelihood of a string containing all Unicode characters (being generated randomly) is so remote that it's hardly worth consideration at all.* On the other hand if the string can contain these private range characters, you should loop through as I suggested. This is actually implemented in my CSV UDF, but I very much doubt the loop ever ran more than once before a suitable delimiter was found

* To try and create such a string using AutoIt would actually be quite difficult.

Edited by czardas

Share this post


Link to post
Share on other sites

Thank You Guys.


It is part of an automated test script that is retrieving the random generated password (sent from our server) from our test email account using POP3 etc.

I could not find $ARRAYFILL_FORCE_SINGLEITEM in the Help file. I am currently running on v3.3.12.0 so I suspect I am needing to update to the latest version.
 


My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Share this post


Link to post
Share on other sites

Not really because the problem still remains and you would also have to loop through the array to make the replacements.

* To try and create such a string using AutoIt would actually be quite difficult.

Why would you not do the replacement before the string gets added to the array? In other words you test each string for your delimiter first. When you extract (or read) a string from the array, you apply the reverse treatment.

Now that we know it is a password, that gives quite a few replacement characters for use outside the norm, but just to be sure, you could also use a combination of two or three characters that just would never appear together.


TheSaints' Robust Chat

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox

userbar.png

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Why would you not do the replacement before the string gets added to the array? In other words you test each string for your delimiter first. When you extract (or read) a string from the array, you apply the reverse treatment.

The reason is that it is a slow process. You need to first run a check. Then you replace the characters. At the end you loop through the array and undo all the replacements. Instead of all that - simply add the string and be done (in this case). I think this should be the default behaviour of the function _ArrayAdd(). Further delimiters can be included - depending on the number of dimensions in the array* ...2, 3, 4 etc. I don't think default delimiters should be used, but rather specified by the developer. If no delimiter is specified, I would put everything in the first element created - but that's just my own take on it.

* or the number of additions.

Edited by czardas

Share this post


Link to post
Share on other sites

I could not find $ARRAYFILL_FORCE_SINGLEITEM in the Help file. I am currently running on v3.3.12.0 so I suspect I am needing to update to the latest version.

Yep!

Share this post


Link to post
Share on other sites

v3.3.14.0 or above to be exact.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

The reason is that it is a slow process. You need to first run a check. Then you replace the characters.

It seemed to me that we were most likely looking at a fraction of a second here, so I guess "slow" is relative, dependent on the number of passwords to be processed at any one time, and I would not actually do a separate check or test, just apply the StringReplace to every string before adding it to the array. I don't see where looping through the array comes into it. Replacements occur before add and then only again (the reverse) when reading an entry in the array (loop method or otherwise).

The real question I guess, is whether the array is an array full of passwords or just a single password with some other user data, and if that last is so, then it is likely that slowness is not relevant at all, unless you are processing a whole database of passwords at one time, and they are numbered in the hundreds etc.

Anyway this is a mote point now, seeing as it is not necessary, due to the string being a password, any ASC II character that will not be in the password (if all passwords are standard keyboard based) would be suitable as the delimiter. Then again, perhaps not, if the password is being stored encrypted, which means it could contain any character.

P.S. Obviously I always opt for the simplest approach, but you and Melba23 seem to have the solution well in hand, and the OP seems to understand, so really I'm not arguing against that, just continuing for my own enlightenment and or offering what seems a suitable alternative, just in case. In any case, we lack full knowledge of the complete scenario ... number of passwords, etc.

Edited by TheSaint

TheSaints' Robust Chat

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox

userbar.png

Share this post


Link to post
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