Jump to content

Mark-

Members
  • Content Count

    328
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Mark-

  1. Mark-

    TVirtualStringTree...

    Hello, Delphi 10.2 I just started using TVirtualStringTree and all is working well (Thanks Jam Software). I need to save all the node captions to a text file with the same format as TTreeview (tab character for indent level followed by caption string) so, at a later time, the file can be loaded and parsed. Has anyone done such a thing? Cheers, Mark
  2. Mark-

    TVirtualStringTree...

    Hello, What I came up with for my needs. procedure SaveVTToFileLikeTTreeView(tree:TVirtualStringTree; const fName:string); var data:TVTABFetch; strList:TStringList; tmpNode:PVirtualNode; function CreateTabPrefix(count:integer):string; var i:integer; begin result:=''; for i:=0 to count -1 do result:=result + #09; //tab end; begin if (fName = '') then Exit; strList:=TStringList.Create; if not Assigned(strList) then Exit; try tmpNode:=tree.GetFirst; if not Assigned(tmpNode) then //if nothing, scram Exit; repeat data:=TVTABFetch(Pointer(tree.GetNodeData(tmpNode)^)); if Assigned(Data) then //safety strList.Add(CreateTabPrefix(tree.GetNodeLevel(tmpNode)) + data.caption); tmpNode:=tree.GetNext(tmpNode); until (not Assigned(tmpNode)); strList.SaveToFile(fName); finally strList.free; end; end; Cheers, Mark
  3. Hello, This might seem silly. Used a few programming languages over the years. Would you expect the code below to produce the same result? 7 Did not find a reference in the help system. procedure TestOrder; var index,finalValue:integer; function ResultIsFive(var i:integer):integer; begin result:= 3 + 2; Inc(i); end; begin index:=1; finalValue:=index + ResultIsFive(index); ShowMessage(IntToStr(finalValue)); index:=1; finalValue:=ResultIsFive(index) + index; ShowMessage(IntToStr(finalValue)); end; Thanks, Mark
  4. Mark-

    Prevent from closing when....

    Hello, Delphi 10.2.3, VCL Might seem simple but I have not run into this issue and have limits on what changes I can make. Form A is opened containing one button. The button opens a modal dialog, form B, displaying a message. Before the user can close form B, another part of the program posts a close message to form A and it closes. The user closes form B, leading to a crash. Setting a flag to indicate a modal dialog has been opened to prevent form A from closing is not possible. That would be a big change. Users design the screens and run script, etc. I can change the FormCloseQuery, FormClose and FormDestroy of form A. Finding what to check in the form properties/methods has produced no joy. Forest for the trees might be present. Any ideas? Thanks, Mark
  5. Mark-

    Prevent from closing when....

    Thanks for the response "Rollo62", interesting. "Uwe Raabe" thank you. I will check it out.
  6. Mark-

    Prevent from closing when....

    Thanks for the response "Kas Ob.". This issue is not about the application closing. These form A come and go in a 24/7 program. The possible changes are limited to the areas I mentioned, in form A. The user designs/creates/codes/uses/etc. these form A. We provide the IDE and execution of the user created form A inside the main program, like an add on, along with other user configurable features. Large changes to a huge program for one issue with the form A, that was actually found by destructive testing, a user in 14 years has never created the issue, is not prudent/practical/etc. Again, thanks for the reply.
  7. Mark-

    Prevent from closing when....

    Perhaps I can get the foreground window, check it for modal and if so prevent form A from closing in FormCloseQuery. Tomorrow.
  8. Mark-

    Return an array from a function??

    Couple of ways to accomplish it, One simple method. type TVariantArray = array of variant; function Foo(data:byte):TVariantArray; begin SetLength(result,2); result[0]:=data + 123; result[1]:='ABCD'; end; procedure FooTest; var res:TVariantArray; begin res:=Foo(1); ShowMessage(IntToStr(res[0]) + ' ' + res[1]); end;
  9. Hello, We use TMS Scripter (Pascal) to allow our customers to execute custom logic on data. Embedded editor, breakpoints, stepping, variable watches, etc. are included. Looking at providing Python and how to provide the same features. PyScripter seems to provide all or part but, I do not see any path to embed PyScripter in our application. How do you guys, using Python4Delphi, provide an IDE? Thanks, Mark
  10. Mark-

    Enbedded editor, debugging, etc...

    We are looking to add Python, not replace TMS scripter. Thanks for your opinion.
  11. Mark-

    Enbedded editor, debugging, etc...

    Thanks for the response. >Do you really need the IDE embedded in your application or could you treat it as a remote execution / debug scenario? Embedded. >Which code, Delphi or the Python script, do you need the user to be able to watch / step into? Python. Just like we do with TMS Scripter. >Could you use PY4D to host the interpreter and then remote attach to it with the IDE? I have not used PY4D. Is this different from the first question?
  12. Mark-

    Enbedded editor, debugging, etc...

    Thanks for the response. Are you saying the examples demonstrate an IDE, with debugging, breakpoints, stepping through Python code, variable examination, etc.?
  13. Negative numbers are not passed to the function. The example is perfectly legit. Exceptions do occur.
  14. I guess I am missing something. Perhaps I need more sleep. if IsInRangeEx(5,10,20) then beep;
  15. Hello, Perhaps it is late and I am not seeing the forest for all the trees. Is there a way to use TWSocket.SendTo with a dynamic array? Thanks, Mark
  16. Mark-

    TWSocket.SendTo...

    Never mind. I found the issue. A missing @buffer[0] in some packet generation code.
  17. type TMyFunkyRecord = record b:boolean; end; function Something(inB:pointer):pointer; var bRec:TMyFunkyRecord; begin bRec:=TMyFunkyRecord(inB^); if bRec.b then beep; bRec.b:=false; result:=@bRec; end; var bRec,aRec:TMyFunkyRecord; begin bRec.b:=true; aRec:=TMyFunkyRecord(Something(@bRec)^); if not aRec.b then beep; end; You can make it work with "naked" pointers. More trouble than worth to avoid declaring the pointer type. My2c.
  18. His post now show as "Guest". Did he delete his account or...
  19. Mark-

    Elevation...

    Hello, Using CreateProcess I am attempting to launch another program of mine. If the "Run this program as administrator", is enabled in the compatibility" tab. all works as expected. If not enabled, I get an OS error: "The requested operation requires elevation". Perhaps the manifest is in error. This is the manifest I am using: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity type="win32" name="Configure" version="1.0.0.0" processorArchitecture="x86"/> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/> </dependentAssembly> </dependency> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!--Windows 7--> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!--Windows 8 and Windows Server 2012--> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <!--Windows 8.1 and Windows Server 2012 R2--> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <!--Windows 10, Windows Server 2016 and Windows Server 2019--> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> </application> </compatibility> </assembly> Any ideas? Thanks, Mark
  20. Mark-

    Elevation...

    That is correct. I have used and use ShellExecute in other code and will give it a try. Thanks, Mark
  21. Mark-

    Aligning text in a rectangle...

    Hello, I have a need to align some text in a rectangle to the traditional nine locations. The user decides how to align each cell and I wanted to make one call, passing in the vertical and horizontal alignment selections. The text needs to wordbreak and may contain linefeeds. Searching the web, no joy, so I created this test project. Perhaps someone knows a better solution, and will share, and/or this will help another. Cheers, Mark TextAlign.zip
  22. Mark-

    Aligning text in a rectangle...

    It's just to show the code to process the text and alignments, the important part.😉 Your code does not support word wrap or embedded line feeds. It was/is a requirement and stated in the first post. Thanks for playing.
×