Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2003
    Posts
    2,427

    Grin Check this code for me please.

    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.

    Code:
    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?
    Last edited by longedge; 01-31-2008 at 08:05 AM.

  2. #2
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    longedge

    It worked fine for me.

    I copied your code as is:
    Placed a txt document in the Docs folder, and a ListBox on the page.
    no error message - encrypted file in \temp\enc
    ...using Win XP Sp2

  3. #3
    Join Date
    Aug 2003
    Posts
    2,427
    Thanks for that Holtgrewe but it still causes the same problem for me.

    I emailed the project to myself at home and just tried it with the same error.

    So I've abandoned the _TempFolder strategy and have just gone for C:\enc and that now works OK but I don't know why???

    Just one thing - do you mean that you were getting an encrypted file from a non-encrypted one using that code?
    I was starting with encrypted files in Autoplay\Docs and decrypting them to the enc folder.
    Last edited by longedge; 01-31-2008 at 11:35 AM.

  4. #4
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    Yea, that's exactly how I tested it. At the time I wasn't concerned about the decrypting aspect. I was thinking it was a timing issue with the folder being created and trying to write to it, but I couldn't get it to fail. So I tested it kind of bass-ackwards. It would be interesting to see if you could duplicate my shenanigans on your system and see if it works for you that way.

    You say it worked when you changed the path, so there's nothing wrong with the code. Strange...

  5. #5
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    longedge

    Forget my previous test. It was on AMS 7 and it worked fine.

    On AMS 6 I was able to duplicate your exact problem.
    There's an apparent problem in how AMS6 handles this...

    Very sorry to mislead you. mea culpa.

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    Its because you have a relative file path


    Try This: (Tested in AMS 6.0.5.0)
    Code:
    --create folder in users temp directory if it doesn't already exist
    chk_folder = Folder.DoesExist(_TempFolder.."\\enc");
    if (chk_folder==false) then
    	Folder.Create(_TempFolder.."\\enc");
    end
    
    --decrypt the files
    while not cryp_files do
    	cryp_files = File.Find(_SourceFolder.."\\AutoPlay\\Docs", "*", false, false, nil, nil);
    	for index in cryp_files do   -- FAILS HERE BUT ONLY ON FIRST RUN!!
    		split_path = String.SplitPath(cryp_files[index]);
    		file_name=split_path.Filename	
    		ext=split_path.Extension
    		file=file_name..ext
    		Crypto.BlowfishDecrypt(cryp_files[index], _TempFolder.."\\enc\\"..file, "qdd")
    	end
    end
    
    --get the files from temp folder
    while not decryp_files do
    	decryp_files = File.Find(_TempFolder.."\\enc", "*", false, false, nil, nil);
    	for index in decryp_files do
    		split_path = String.SplitPath(decryp_files[index]);
    		file_name=split_path.Filename
    		add_list = ListBox.AddItem("ListBox1", file_name, decryp_files[index]);
    	end
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    Aug 2003
    Posts
    2,427
    Rizla and Holtgrewe - Many thanks for your time.

    I haven't got time to try it out today but I'll make the change you suggest Rizla .

    I got it working by changing to C:\enc but I *also* made the application as an exe whereas before I had been using the standard build. It was probably the change of build type that did it and not the destination. Still can't understand it but that doesn't matter as long as I find a reliable solution

Similar Threads

  1. Article: Using Authenticode Code Signing Certificates
    By Ted Sullivan in forum Setup Factory 8.0 Examples
    Replies: 4
    Last Post: 10-31-2007, 09:03 AM
  2. Code check please... (ends)
    By Bruce in forum AutoPlay Media Studio 6.0
    Replies: 3
    Last Post: 08-30-2007, 10:33 PM
  3. New Check Boxes on Preload code
    By civil78 in forum Setup Factory 7.0
    Replies: 3
    Last Post: 03-16-2006, 09:57 AM
  4. Need a code that will check for installed programs.
    By Quantrac in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 02-07-2005, 12:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts