longedge
01-31-2008, 09:01 AM
Can someone cast an eye over this code.I've looked and looked at it and can't understand why I have a problem namely that the first time the application runs I get an error -
"On Show, Line 10: attempt to call a nil value".
The second and subsequent times I run the app it works fine and does exactly what it's supposed to.
The problem ONLY arises when the "enc" folder is being created.
The confusing thing is that it is enumerating the files in Autoplay\docs folder that appears to fail. I have tried putting a 'sleep' in after creating the folder but that makes no difference.
1 --create folder in users temp directory if it doesn't already exist
2 chk_folder = Folder.DoesExist(_TempFolder.."\\enc");
3 if (chk_folder==false) then
4 Folder.Create(_TempFolder.."\\enc");
5 end
6
7 --decrypt the files
8 while not cryp_files do
9 cryp_files = File.Find("AutoPlay\\Docs", "*", false, false, nil, nil);
10 for index in cryp_files do -- FAILS HERE BUT ONLY ON FIRST RUN!!
11 split_path = String.SplitPath(cryp_files[index]);
12 file_name=split_path.Filename
13 ext=split_path.Extension
14 file=file_name..ext
15 Crypto.BlowfishDecrypt(cryp_files[index], _TempFolder.."\\enc\\"..file, "qdd")
16 end
17 end
18
19 --get the files from temp folder
20 while not decryp_files do
21 decryp_files = File.Find(_TempFolder.."\\enc", "*", false, false, nil, nil);
22 for index in decryp_files do
23 split_path = String.SplitPath(decryp_files[index]);
24 file_name=split_path.Filename
25 add_list = ListBox.AddItem("ListBox1", file_name, decryp_files[index]);
26 end
27 end
Not sure why but the code tag makes backslashes appear as an odd character on this system - don't know if that's the same for everyone else?
"On Show, Line 10: attempt to call a nil value".
The second and subsequent times I run the app it works fine and does exactly what it's supposed to.
The problem ONLY arises when the "enc" folder is being created.
The confusing thing is that it is enumerating the files in Autoplay\docs folder that appears to fail. I have tried putting a 'sleep' in after creating the folder but that makes no difference.
1 --create folder in users temp directory if it doesn't already exist
2 chk_folder = Folder.DoesExist(_TempFolder.."\\enc");
3 if (chk_folder==false) then
4 Folder.Create(_TempFolder.."\\enc");
5 end
6
7 --decrypt the files
8 while not cryp_files do
9 cryp_files = File.Find("AutoPlay\\Docs", "*", false, false, nil, nil);
10 for index in cryp_files do -- FAILS HERE BUT ONLY ON FIRST RUN!!
11 split_path = String.SplitPath(cryp_files[index]);
12 file_name=split_path.Filename
13 ext=split_path.Extension
14 file=file_name..ext
15 Crypto.BlowfishDecrypt(cryp_files[index], _TempFolder.."\\enc\\"..file, "qdd")
16 end
17 end
18
19 --get the files from temp folder
20 while not decryp_files do
21 decryp_files = File.Find(_TempFolder.."\\enc", "*", false, false, nil, nil);
22 for index in decryp_files do
23 split_path = String.SplitPath(decryp_files[index]);
24 file_name=split_path.Filename
25 add_list = ListBox.AddItem("ListBox1", file_name, decryp_files[index]);
26 end
27 end
Not sure why but the code tag makes backslashes appear as an odd character on this system - don't know if that's the same for everyone else?