Creating an array through a loop
Posted: Tue Aug 06, 2013 1:36 pm
Hi all,
I am very very new to programming and have found the forums here to be an enormous source of help for me. So thank you so much!
I have been trying to program an application for some weeks now with the help of the forums but I have run into some problems that i am struggling to resolve. I hope maybe you guys could help shed some light on it.
The essence of what I am trying to do is take in a folder, create a loop to md5 the files in it and then store the names and md5 sums into a variable. Next I will duplicate the folder and repeat the process to md5 and store the information into a second variable. Then I will compare both the variables to verify that they are the same. I will also be displaying the contents of the variable into a log file.
This is my current code. Somehow I am unable to include the file name into the variable and it also takes very long time (30-40 seconds..) to display the output and the screen freezes as well. Please take a look and tell me how I may resolve this. Thank you.
-------------------------------
global gLogData
global HashValue
on mouseUp
answer folder ("Select your folder containing the Database")
put it into fld 1
put logData(fld 1) into tLog[1] -------- logData is a function that will timestamp the content in fld 1 and store into an array
answer "Create a duplicate of selected folder"
answer folder ("Select destination to copy the Database to")
put it into fld 2
put cr & logData(fld 2) into tLog[2]
combine tLog using return
put tLog into fld 3
local tDefault, tItems
set the defaultFolder to fld 1
put empty into field 4
put the files into tItems
filter tItems without "."
repeat for each line xLine in tItems
put cr & "name=" & quote & xLine & quote into HashValue[xLine]
put cr & "checksum=" & quote & fileDigest(the defaultFolder & "/" & xLine) & quote & return into HashValue[xLine]
end repeat
combine HashValue using return
put HashValue into fld 4
end mouseUp
I am very very new to programming and have found the forums here to be an enormous source of help for me. So thank you so much!
I have been trying to program an application for some weeks now with the help of the forums but I have run into some problems that i am struggling to resolve. I hope maybe you guys could help shed some light on it.
The essence of what I am trying to do is take in a folder, create a loop to md5 the files in it and then store the names and md5 sums into a variable. Next I will duplicate the folder and repeat the process to md5 and store the information into a second variable. Then I will compare both the variables to verify that they are the same. I will also be displaying the contents of the variable into a log file.
This is my current code. Somehow I am unable to include the file name into the variable and it also takes very long time (30-40 seconds..) to display the output and the screen freezes as well. Please take a look and tell me how I may resolve this. Thank you.
-------------------------------
global gLogData
global HashValue
on mouseUp
answer folder ("Select your folder containing the Database")
put it into fld 1
put logData(fld 1) into tLog[1] -------- logData is a function that will timestamp the content in fld 1 and store into an array
answer "Create a duplicate of selected folder"
answer folder ("Select destination to copy the Database to")
put it into fld 2
put cr & logData(fld 2) into tLog[2]
combine tLog using return
put tLog into fld 3
local tDefault, tItems
set the defaultFolder to fld 1
put empty into field 4
put the files into tItems
filter tItems without "."
repeat for each line xLine in tItems
put cr & "name=" & quote & xLine & quote into HashValue[xLine]
put cr & "checksum=" & quote & fileDigest(the defaultFolder & "/" & xLine) & quote & return into HashValue[xLine]
end repeat
combine HashValue using return
put HashValue into fld 4
end mouseUp