Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 15 of 15
  1. #1
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175

    Finction Help Please!!!

    ok, I have saved files which are blowfish encrypted. To open them, I populate them from the saved folder in a tree object. All that works, I'm just having a problem actually opening them. On my tree objects "On Double Click" event, I have this fuction (well, the actual function is in the GLOBALS)

    Code:
    function RunNodeFile()
    sel_node = Tree.GetSelectedNode("Tree1");
    node = Tree.GetNode("Tree1", sel_node);
    node_data = node.Data
    Crypto.BlowfishDecrypt(node_data, _TempFolder..node_data..".txt", "trustno1withthispassword");                                           --trustno1withthispassword
    OPEN_TXT = TextFile.ReadToString(_TempFolder..node_data..".txt");
    Page.Jump("forms");
    --File.Open(node_data, "", SW_SHOWNORMAL);
    end
    Page jumps, but there is no text file created in the Temp Folder, and thus no text displayed in the paragraph object. I think it's just how I have the file concatenated.

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    you need to add a backslash to the filepaths

    Code:
    function RunNodeFile()
    sel_node = Tree.GetSelectedNode("Tree1");
    node = Tree.GetNode("Tree1", sel_node);
    node_data = node.Data
    Crypto.BlowfishDecrypt(node_data, _TempFolder.."\\"..node_data..".txt", "trustno1withthispassword");                                           --trustno1withthispassword
    OPEN_TXT = TextFile.ReadToString(_TempFolder.."\\"..node_data..".txt");
    Page.Jump("forms");
    --File.Open(node_data, "", SW_SHOWNORMAL);
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    I tried it, still no text displayed in paragraph object. Also, no text file created in the temp folder. Any other thoughts? Oh.. thanks for looking.
    Last edited by thetford; 02-09-2008 at 08:38 AM. Reason: left out some info

  4. #4
    Join Date
    May 2006
    Posts
    5,380
    sorry, i was in a rush and dident even read the code properly

    if the file is already encrypted then no need to create a decrypted version, just use the decrypted string

    heres how i would have done it

    fill the tree node data with the full path to the file
    Code:
    put the function in globals
    function RunNodeFile()
    	sel_node = Tree.GetSelectedNode("Tree1");
    	node = Tree.GetNode("Tree1", sel_node);
    	EncryptedString = TextFile.ReadToString(node.Data);
    	OPEN_TXT = Crypto.BlowfishDecryptString(EncryptedString, "trustno1withthispassword");--trustno1withthispassword
    	return OPEN_TXT
    end
    
    and call like this, so it will only jump if the global "OPEN_TXT" contains some text
    
    if RunNodeFile() ~= "" then then
    	Page.Jump("forms");
    end
    as long as "node_data" holds the full path to the file then the above should work
    Open your eyes to Narcissism, Don't let her destroy your life!!

  5. #5
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    nothing happens........................

    here is my tree object population code (GLOBAL):
    Code:
    function GetFolderContents()
    ENC = File.Find(_ProgramFilesFolder.."\\Credit Mechanic\\Saved", "*.enc", true, false, ShowSearchProgress, nil);
    	if ENC then
    		for i,v in ENC do
    		tbSplit = String.SplitPath(v);
    		name = tbSplit.Filename
    			tblNodeData = {};
    			tblNodeData.Text = name;
    			tblNodeData.Data = v;
    		Tree.InsertNode("Tree_files", "3", tblNodeData);
    		end
    	end
    end
    here is the on double click function (GLOBAL):
    Code:
    function RunNodeFile()
    	sel_node = Tree.GetSelectedNode("Tree_files");
    	node = Tree.GetNode("Tree_files", sel_node);
    	EncryptedString = TextFile.ReadToString(node.Data);
    	OPEN_TXT = Crypto.BlowfishDecryptString(EncryptedString, "trustno1withthispassword");--trustno1withthispassword
    	return OPEN_TXT
    end
    here is my evaluation statement on the forms page:
    Code:
    if OPEN_TXT == "" then
    
    else
    Paragraph.SetText("form", OPEN_TXT);
    end
    I'm stupted dean.......... also, how can I keep the tree object from duplicate population when the user re-visits the OPEN page?

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    mmm, i cant see any problem with the code

    is "RunNodeFile()" being called from the global area if it is then "OPEN_TXT" would contain the decrypted text

    well, i put you code in a example and i couldent get it to work either, it seems the tree functions was causeing some weird erros coz when i moved them to the listbox it worked

    so heres a version of the above that works

    put this in your global functions
    Code:
    function GetFolderContents()
    --ENC = File.Find(_ProgramFilesFolder.."\\Credit Mechanic\\Saved", "*.enc", true, false, ShowSearchProgress, nil);
    ENC = File.Find("AutoPlay\\Docs\\Saved", "*.enc", true, false, nil, nil);
    	if ENC then
    		for i,v in ENC do
    		tbSplit = String.SplitPath(v);
    		name = tbSplit.Filename
    			tblNodeData = {};
    			tblNodeData.Text = name;
    			tblNodeData.Data = v;
    		Tree.InsertNode("Tree_files", "3", tblNodeData);
    		end
    	end
    	-- set a variable here so the tree dose not fill everytime we enter the page
    	blnTreeFilled=true
    end
    
    
    function RunNodeFile(strFilePath)
    	-- this var is local
    	local EncryptedString = TextFile.ReadToString(strFilePath);
    	-- leave this var global for use on the next page
    	strText = Crypto.BlowfishDecryptString(EncryptedString, "trustno1withthispassword");--trustno1withthispassword
    	-- now jump to page
    	Page.Jump("Page2")
    end
    page on show (tree page)
    Code:
    -- if tree has not been filled then fill it now
    if not blnTreeFilled then
    	GetFolderContents()
    end
    page on show (text page)
    Code:
    -- check the the var has some value
    if strText ~= "" then
    	Paragraph.SetText("Paragraph1", strText);
    else
    	Paragraph.SetText("Paragraph1", "No File Found");
    end
    heres a example of it working
    Last edited by RizlaUK; 02-01-2009 at 11:34 AM.
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    OK it's working!!!! thanks......

  8. #8
    Join Date
    May 2006
    Posts
    5,380
    no problem, glad to help
    Open your eyes to Narcissism, Don't let her destroy your life!!

  9. #9
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    one more quick question......... how are you encrypting your text? Your text files open in the example, but mine do not.

    Here is my original "Save" code:
    Code:
    save_text = Paragraph.GetText("form");
    SA_NAME = Dialog.Input("Save As", "File Name:", "", MB_ICONQUESTION);
    if SA_NAME == "" then
    result = Dialog.Message("Notice", "You must enter a name.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
    elseif SA_NAME == "CANCEL" then
    result = Dialog.Message("Cancelled", "File save cancelled.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    else
    TextFile.WriteFromString(_TempFolder.."\\cmsave.txt", save_text, false);
    Crypto.BlowfishEncrypt(_TempFolder.."\\cmsave.txt", _ProgramFilesFolder.."\\Credit Mechanic\\Saved\\"..SA_NAME..".enc", "trustno1withthispassword");
    File.Delete(_TempFolder.."\\cmsave.txt", false, false, true, nil);
    end
    
    
    Found = File.Find(_ProgramFilesFolder.."\\Credit Mechanic\\Saved\\", SA_NAME..".enc", false, false, nil, nil);
      if Found == true then
      result = Dialog.Message("File Saved", "Your file has been successfully saved!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        else -- file not found
        --do something here
    end
    The above code worked.... well it did save files. I changed my "Save" code to this, put it does not work:
    Code:
    save_text = Paragraph.GetText("form");
    SA_NAME = Dialog.Input("Save As", "File Name:", "", MB_ICONQUESTION);
    
    if SA_NAME == "" then
    result = Dialog.Message("Notice", "You must enter a name.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
    elseif SA_NAME == "CANCEL" then
    result = Dialog.Message("Cancelled", "File save cancelled.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    else
    
    Crypto.BlowfishEncrypt(save_text, _ProgramFilesFolder.."\\Credit Mechanic\\Saved\\"..SA_NAME..".enc", "trustno1withthispassword");
    end
    
    
    Found = File.Find(_ProgramFilesFolder.."\\Credit Mechanic\\Saved\\", SA_NAME..".enc", false, false, nil, nil);
      if Found == true then
      result = Dialog.Message("File Saved", "Your file has been successfully saved!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        else -- file not found
        --do something here
    end
    What am I missing here?

    --EDIT nevermind, I got it........
    Last edited by thetford; 02-16-2008 at 05:44 PM. Reason: problem solved

  10. #10
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    ok, ok, ONE more thing....... (yeah right - LOL)

    Your function works for only populating the tree once per session, but what if you save a file and want to open it in the same session. I think the answer is to clear the tree every time the Open page (where the tree object is locted) is navigated away from, that way it popultes fresh everytime the Open page is accessed.

    But I don't even know how to start writing a function to clear a tree object?

  11. #11
    Join Date
    May 2006
    Posts
    5,380
    no problem, after your save code make the tree populate again and put this in the top of the populate code
    Code:
    Tree.RemoveNode("Tree1", "0");

    Code:
    function GetFolderContents()
    Tree.RemoveNode("Tree_files", "0");
    --ENC = File.Find(_ProgramFilesFolder.."\\Credit Mechanic\\Saved", "*.enc", true, false, ShowSearchProgress, nil);
    ENC = File.Find("AutoPlay\\Docs\\Saved", "*.enc", true, false, nil, nil);
    	if ENC then
    		for i,v in ENC do
    		tbSplit = String.SplitPath(v);
    		name = tbSplit.Filename
    			tblNodeData = {};
    			tblNodeData.Text = name;
    			tblNodeData.Data = v;
    		Tree.InsertNode("Tree_files", "3", tblNodeData);
    		end
    	end
    	-- set a variable here so the tree dose not fill everytime we enter the page
    	blnTreeFilled=true
    end
    that way the tree will only populate only when it needs to, i always do this with trees and list/combo box, no need to waist time and cpu/memory running functions that have no current use or do not need to be run, on small projects it dosent really matter but on big projects.....boy......it matters, lol

    EDIT: if saving the file on another page then all you need to do is set "blnTreeFilled=true" to "blnTreeFilled=false" and the tree will update when the page next shows
    Last edited by RizlaUK; 02-16-2008 at 06:46 PM.
    Open your eyes to Narcissism, Don't let her destroy your life!!

  12. #12
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    Well, i'm not sure why, but the "saved" files always open as the last saved file, reguardless of the file selected in the tree object.

    Do you want to demo what I'm doing?

  13. #13
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    If you want to download the demo - and it's just a work in progress.... not near completion, but you will see what I'm talking about the saved files.

    Anyway, go to my website http://www.mtplans.com

    Login, Username - irforums
    Password - password

    GO to software, Beta Testing & download credit mechanic 3.0
    Last edited by thetford; 02-17-2008 at 09:22 AM. Reason: error in password

  14. #14
    Join Date
    May 2006
    Posts
    5,380
    sure ill take a look


    EDIT:

    cant login, incorrect username or passowrd
    Open your eyes to Narcissism, Don't let her destroy your life!!

  15. #15
    Join Date
    Feb 2005
    Location
    Birmingham, Alabama
    Posts
    175
    ok, try this:

    username - irforum
    password - password

    Both are lower case.............. I just tried it, it works.

Posting Permissions

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