bahjat Posted May 3, 2015 Posted May 3, 2015 the code that i have written is extremely long so i will post only the part i am having trouble with. I am trying to make the function "_EncryptionProcess" take the arrays 1 by 1 and then process them. Unfortunately after much reading on this forum i have realised that you cant have functions inside For loops. The location in which the arrays need to be taken is where the "$aArray" is typed, the arrays are stored in this value. The other variable defines the key size being used and the key value being used. ;Cuts the input up into piece; $VariableToBeCut = "12345678" $aArray = StringRegExp($VariableToBeCut, ".{2}", 3) MsgBox(0, "die", $aArray[0]) ; personal check to make sure array works $DataToBeEncrypted=_EncryptionProcess($aArray, $keyvalue, $keysize, 1) ;$aArray needs to be where the different arrays are processed MsgBox(0, "Encrypted data", $DataToBeEncrypted)
Moderators Melba23 Posted May 4, 2015 Moderators Posted May 4, 2015 bahjat,Unfortunately after much reading on this forum i have realised that you cant have functions inside For loopsReally? You cannot define functions inside loops, but there is nothing to prevent you from calling them. And the code you posted should run - although you will need to extract the elements from the array you pass as a parameter within the _EncryptionProcess function. This shows the how you might do it:expandcollapse popup#include <Array.au3> #include <MsgBoxConstants.au3> Global $keysize, $keyvalue = "-simulate-encrypted" $VariableToBeCut = "12345678" $DataToBeEncrypted = StringRegExp($VariableToBeCut, ".{2}", 3) ; Display original data _ArrayDisplay($DataToBeEncrypted, "Before", Default, 8) ; Pass array to encryption process $aDataAfterEncryption = _EncryptionProcess($DataToBeEncrypted, $keyvalue, $keysize, 1) ;$aArray needs to be where the different arrays are processed ; Display returned data _ArrayDisplay($aDataAfterEncryption, "After", Default, 8) Func _EncryptionProcess($aArray, $keyvalue, $keysize, $iVal) For $i = 0 To UBound($aArray) - 1 ; Display each element MsgBox($MB_SYSTEMMODAL, "Unencrypted data", $aArray[$i]) ; Call a function from inside the loop to encrypt the value $aArray[$i] = _Encrypt($aArray[$i]) Next ; Return amended array Return $aArray EndFunc Func _Encrypt($sString) ; Simulate encryption $sString = $sString & $keyvalue ; Return encrupted value Return $sString EndFuncDoes that help explain how to do what you require? M23 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
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