Vadim021X
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Этот сценарий работает так: (На странице слева объект tree, справа объект pdf) В объекте tree выводятся файлы в папке C:\\Line, файлы формата pdf, при нажатии (выделении) одного из файла в объекте tree, его содержимое появляется в объекте pdf, т.е. Просмотр. Как его переделать так, чтобы вместо pdf файлов были txt файлы и при выделении txt файла в объекте tree, его содержимое выводилось в объекте rich.text, а имя текстового файла выводилось в объект imput. ??? (если названия объектов введены некоректны, извините точные названия непомню, комп не рядом). Буду очень очень очень очень признателен за помощь!!! Когда пытаюсь переделовать пишет ошибку с строке 77... On Preload Код: -- PDF Root Folder Defined in Global Functions -- Variable: sPDFRootFolder sFirstPDFToLoad = ""; function AddToTree(sFullPath) if (sFirstPDFToLoad == '') then sFirstPDFToLoad = sFullPath; end -- Split the path tPathParts = String.SplitPath(sFullPath); -- Get length of root folder (so we know how many chars to skip) nRootLength = String.Length(sPDFRootFolder); -- sFullPath minus last character sFullFolderPath = tPathParts.Drive .. tPathParts.Folder; nFullFolderPathLength = String.Length(sFullFolderPath); sFullFolderPath = String.Mid(sFullFolderPath, 1, nFullFolderPathLength - 1); -- Check of PDF should be inserted into root of tree if(String.Compare(sPDFRootFolder, sFullFolderPath) == 0) then -- We're inserting this PDF into the root, configure node values tNodeData = {}; tNodeData['Text']=tPathParts.Filename; tNodeData['Data']=sFullPath; tNodeData['ImageIndex']="0"; -- Insert the node Tree.InsertNode("Tree1", Tree.GetChildCount("Tree1", "0") + 1, tNodeData); else -- We need to search for an existing node by 'folder' value (ie sub folder) ... so let's create the search string -- Initialize sSearchString = tPathParts.Folder; -- Strip the last slash off sSearchString = String.TrimRight(sSearchString, '\\'); -- Find the last occuring slash (will be before the final folder name nPosLastSlash = String.ReverseFind(sSearchString, '\\'); -- Get rid of all the stuff before the last occuring slash sSearchString = String.Mid(sSearchString, nPosLastSlash + 1, -1); -- Search the tree by node name (folder name) sFoundNodeIndex = Tree.FindNodeByText("Tree1", "0", sSearchString); if sFoundNodeIndex == "" then -- Node wasn't found, create it -- Create node data (data part is left blank ... this is a 'category', not a document) tNodeData = {}; tNodeData['Text']=sSearchString; tNodeData['Data']=""; tNodeData['ImageIndex']="1"; sParentIndex = Tree.GetChildCount("Tree1", "0") + 1; Tree.InsertNode("Tree1", sParentIndex, tNodeData); else sParentIndex = sFoundNodeIndex; end -- Insert actual file tNodeData = {}; tNodeData['Text']=tPathParts.Filename; tNodeData['Data']=sFullPath; tNodeData['ImageIndex']="0"; Tree.InsertNode("Tree1", sParentIndex .. "." .. (Tree.GetChildCount("Tree1", sParentIndex) + 1), tNodeData); end return true; end -- Find all PDF's in the folder File.Find(sPDFRootFolder, "*.pdf", true, false, nil, AddToTree); -- Load the first PDF PDF.LoadFile("PDF1", sFirstPDFToLoad); -- Test for error error = Application.GetLastError(); if (error ~= 0) then Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); end | On Show Код: sPDFRootFolder = "C:\\Line"; | |