Pat Foley
Members-
Content Count
403 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Pat Foley
-
I to use this on a show modal class procedure Taboutbox.showme; begin aboutbox := Taboutbox.Create(nil); and this on other form now I pass the sender so that the Sender is the owner. The owner has a list of controls that it frees on closing. Class procedure TSCSForm.showme(const AText:string; const ATime:integer); begin if not assigned(SCSForm) then SCSForm := TSCSForm.Create(nil); // should have used sender for the owner with SCSForm do begin if ATime > 0 then TimedStop := True; timer1.Interval:= Atime; Label1.caption:=Label1.caption + CR + AText; if not SCSForm.Showing then begin Show; Are you using a DataModule?
-
How about reducing the number of ifs needed. Or Less ifs = less need for else ifs ending with an else 😞! The need for formatting to get "readable" code is reduced. Debugging is readily done if or when needed. I used on jobs in XL on a Mac in the eighties and consider the flyover case copyrighted in the Excel realm. Set each Boolean state first with assignments then use these "Uwe's" or Explainer variables in the if assignments. Assignments with a Nil state implementing default short circuit are more visible. Example case statement repeatedly steps though an enumerated Type setting states in the order of the Enum. /// <summary> Beep when A and B are true</summary> /// <remarks> /// Or allows R to retain true result of each lines test; /// Set R to False start of logic and apply the braces as and/or if needed in the assignments! /// </remarks> procedure latchingLogic(A,B: Boolean); var R: Boolean; begin R := False; R := R or A and B; R := R or A and not B; R := R or not A and B; R := R or not A and not B; if R then // One if and zero elses = readable +++ Beep; //needs expanded to beep(freq, MS) IDE compiles anyway end; Type // <-- more true precedent inversion to allow fitting to OP example TabTrueFalse = (abTrueTrue, abTrueFalse,abFalseTrue, abFalseFalse); var A: Boolean = False; //example only these become class variables plus typed constants in 11.3 B: Boolean = True; procedure SetAThenBtoTrue(var A, B: Boolean); var I: Integer; abTest: TabTrueFalse; begin repeat // could be reentrant I := ord(not A) * 2 + ord(not B); // not allows present enumtype order abTest := TabTrueFalse(I); case abTest of // abTrueTrue: 'yaa'; abTrueFalse: B := True; // since A is True Ok to set B to True abFalseTrue: B := False; // We want A True first abFalseFalse: A := True; // set A true first end; until abTest = abTrueTrue; latchingLogic(A,B); // use for UI output end;
-
So, in short you could use Toprow first visible row. The example adds an event to allow a progress bar to move with the grid as rows are used. The example sets the rowcount at 3600 then "adds" commatext. But I will admit I was thinking about a stringlist. procedure SGAdjustView(Sender: TObject; const AIndex: Integer; PB: TProgressBar); begin if Sender is TStringGrid and (AIndex > 4) then with (Sender as TStringGrid) do begin TopRow := AIndex - 4; end; PB.Position := AIndex; end; procedure TbaseMainForm.AddrowClick(Sender: TObject); begin var LIndex := 0; var pastTick := GetTickCount64; SG.Rows[0].CommaText:= ('RowCount,Index,Time'); SG.RowCount := 60 * 60;//seconds in minutes per hour ProgressBar1.Max := SG.RowCount; while LIndex < (120 * 30) do begin Inc(LIndex); SG.rows[Lindex].CommaText :=(SG.RowCount.ToString +',' + LIndex.ToString +',' + (GetTickCount64 - pastTick).ToString); SGAdjustView(SG, Lindex, ProgressBar1); // moves the view each by calling event outside begin..end end; end;
-
I was thinking about Fixing BDSLauncher topic I followed this topic and my launcher started working. I was just saying the last IDE worked in should the one getting the file.
-
Sure. Go to the IDE you want the file loaded to and give last focus to it then do your double click business. Most users would want IDE last worked in to get incoming files. Note not tested across Desktops!
-
Retaining precision when copying and pasting numeric data (floating point) from Excel to a StringGrid
Pat Foley replied to Gord P's topic in Tips / Blogs / Tutorials / Videos
My concern is this about every 15 years https://interestingengineering.com/science/genes-renamed-to-stop-microsoft-excel-from-mistaking-them-for-dates Well, that is a deep subject ~possible reply in conversation when "Well?" is asked. In XL use the extended paste methods value, ref, blah, transpose from the ribbon, or a right click when over the target cell or range to get the number and not the text. Like a well you would dig deep into subject matter (floats integers strings) to get "water" from copy/paste schemes. -
Why are you changing the rowcount it's done for you when you add a row? Here's an example of updating/overwriting all the cell's each UI update in case old information became stale! The SG column count is the Magic number 16 or the number of double fields in "atom". When the atom count is increased the SG Row count is bumped if needed. There's a Conway's game of life in the /samples that may yield better results. procedure TForm1.updateSG; var ii, R, C: integer; fPointer: Pdouble; //was^ not P begin for ii := 0 to Atoms.Count - 1 do begin C := 2 + ii mod 16; R := 3 + ii div 16; fPointer := Pdouble(Atoms.Objects[ii]); Screen2.StringGrid1.Cells[C, R] := format('%2.1f',[FPointer^]); end; Here's more modern example in a customized generic class (TList<PApp>) that has a SG assigned to it. Here the SG in a form some where gets its rowcount touched when needed. In the UI clicking on SG causes that row's app to surface even on a different desktop. procedure TptrApps.updateSG(inTool: ptrApp; inRow: Integer); begin if sgGrid.RowCount < inRow then sgGrid.RowCount := inRow + 1; var i := InRow; sgGrid.Cells[0, i] := inTool.Name;//sFirstTime; sgGrid.Cells[1, i] := inTool.Title; sgGrid.Cells[2, i] := inTool.ClassName; sgGrid.Cells[3, i] := inTool.Used.ToString; ///sgGrid.Cells[4, i] := inTool.sTime; sgGrid.Cells[5, i] := inTool.sVersion; end;
-
CategoryPanel or Tabsheets in pagecontrol with tabs left side. Or try the samples in /Samples for ideas. Ray K site https://delphibydesign.com/ has a few samples under downloads. I look at his generics samples from time to refresh how generics and even how to set earlier object list code.
-
Retaining precision when copying and pasting numeric data (floating point) from Excel to a StringGrid
Pat Foley replied to Gord P's topic in Tips / Blogs / Tutorials / Videos
My concern is this about every 15 years https://interestingengineering.com/science/genes-renamed-to-stop-microsoft-excel-from-mistaking-them-for-dates -
TMemo - loading a file but keeping last screen layout
Pat Foley replied to JohnLM's topic in General Help
The trouble with memo need to set word wrap to false to track lines. Here's a way to simply output to image or Paintbox. Painting StringGrid is above my paygrade. To call it pass self and a canvas when the view or the data is changed. procedure DrawCanvasPat(Sender: Tobject; Canvas: TCanvas); begin with Canvas do begin Pen.Width := 3; for var C in [0 .. 9] do // := Low to High do FAD here begin var R := 0; var fields := ['First', '', '', '', 'Mid', '', '', 'H', '', 'Last', 'Ten']; // ShowMessage(fields[0]); TextOut(C * 45 + 45, R + 23, fields[C]); for R in [CSVHeaderTopLine .. 9] do begin var value := (Random(20) - 10); if value > 0 then Pen.Color := clGreen else Pen.Color := clRed; Rectangle(C * 45 + 60, R * 23 + 30, C * 45 + 64, R * 23 + 33); TextOut(C * 45 + 45, R * 23 + 23, value.ToString); // ColorDrawItem2(sgUI, sgUI.Canvas,cellValue.tostring,Lrect,TRue); end; end; end; end; -
chiefly for the WSL stuff, that would allow learning/running Linux faster than running a Linux box? That was two days ago now I want buy a box to run win pro 11 on it to learn if remote debugging on windows 64 machine using a windows 32 machine would allow faster recompiling. Still there is regret that I didn't jump on the 20% discount(When I bought the D10.2 with mobile on sale 2000 days ago. In a month found a newer computer to install it on by then 10.3 was available.) Raspberry Pi it's just another mouth to feed not in the money involved but in time used in learning curve of what works and how it works. Learning Python first maybe best for Linux development getting the Pi aspect for free that's my new plan. For windows I think I deserve a p16 or even an HP.
-
I thinking to 'upgrade' to Enterprise I been able to debug over one screen vs two screens, 11.3 is as lithe and cat quick like D3.
-
When will we have a 64-bit IDE version ?
Pat Foley replied to luciano_f's topic in Delphi IDE and APIs
So uncheck save manually then compile or build for a 'line count'. -
When will we have a 64-bit IDE version ?
Pat Foley replied to luciano_f's topic in Delphi IDE and APIs
Is the IDE set to save files on a compile? Does the error change to corrupted memory when compiling in 64 bit. I have 1.4 Compressed memory even with 8.2 available so I may reboot the machine to clear the Compressed or swap pages out this week. MS fixed some issues doing away with recently used file time line but putting the swap file back in is maddening -
Migrate an old app in Delphi 2009 to modren C++
Pat Foley replied to Alkanium's topic in General Help
Start with a plan then! Good luck comes from months of careful planning. What about the database, the servers etc. For now, log the bugs to determine if the problem is data entry, codebase, or database design and queries used. Only should then you recompile the hpp files made in Delphi into C++. -
When will we have a 64-bit IDE version ?
Pat Foley replied to luciano_f's topic in Delphi IDE and APIs
Just because a large number of people do something (Windows/MSDOS), does not make it right (MAC OS crew view). Legacy support is lost in the Mac world a publishing program upgraded to the new flavor of Mac would happily wreck any book at page 65 or so. Android Studio needs to run on Linux for good connection to google when it's working your phone over. It does have a Web app option now. Visual Studio issues warning do not set root to internet on Linux. plus learning javascript. Boo! Lazarus I been unable to load on Linux for one, plus it's just a bunch of windows like D1-7. -
When will we have a 64-bit IDE version ?
Pat Foley replied to luciano_f's topic in Delphi IDE and APIs
Simply reinstalling a reworked package before compiling the program using it is a must! -
Delphi has stopping on break points and exceptions
Pat Foley replied to PiedSoftware's topic in Delphi IDE and APIs
I am using 11.3 a big improvement over 10.4 until the blue moon last month. Then the IDE began doing disappearing act like 10.3, after "upgrading" an event in a control in a package. In short recompiling my package of custom controls fixed the issue(s). Looking at the output messages after a compile I may shut down the OneDrive business if the IDE crashes while hovering over the Search menu again. -
Streams - Writing and Reading data or text from
Pat Foley replied to JohnLM's topic in Algorithms, Data Structures and Class Design
One way to learn Stream is: Add a TMemo to a form in the Designer. Add lines of text to Memo1 in ObjectInspector usings Lines property editor. Select the Memo1 in design and cut/paste into notepad. Tinker with property settings streamed out in notepad. Stream the adjusted Memo1 back into the designer by pasting notepad text. Wow. Next lesson Place cut out of design window into code by pasting inside a buttonclick. modify the pasted so the runtime creates the memo at runtime.🙂 ... Database can use record with fixed string size on one hand and can use JSON for streaming needs. TStream used like TStrings in procedure arguments. MS is passed as a TStream in the TreeView.SavetoStream. procedure TForm3.Button5Click(Sender: TObject); var MS: TmemoryStream; begin MS := TMemoryStream.Create; Try TV.SaveToStream(MS); // TV isa TreeView MS.Position := 0; Memo1.Lines.LoadFromStream(MS); Finally MS.Free; End; end; -
Here's a pascal example that simply replaces ProcessMessages with custom "message" calls to allow the sleep delays. assign this ClickEvent to several buttons onclick Event. I would look media player source for dealing with updating several buttons state. implementation {$R *.dfm} const Clickable = True; // alias for enabled = True procedure ButtonEnable(button: TButton; const aCaption: string; const isEnabled: Boolean); //inline; begin if button.Enabled <> isEnabled then button.Enabled := isEnabled; if button.Caption <> aCaption then button.Caption := aCaption; // button.Enabled := isEnabled; order matters //Button.Repaint; // end; procedure SnoozedButton(button: TButton; MS: Integer); //inline; begin ButtonEnable(button, 'Snoozed', not Clickable); Sleep(MS); end; var inUse: Boolean = False; procedure TForm15.DealButtonClick(Sender: TObject); begin if inUse = not False then exit; inUse := True;//Sender as TButton; SnoozedButton(Sender as TButton, 3000); ButtonEnable(Sender as TButton, 'Hit me', not Clickable); Sleep(1500); (Sender as TButton).Caption := 'Hitted'; sleep(1500); sleepControl(Sender, 2000); // Event driven call ButtonEnable(Sender as TButton, 'Deal', Clickable); inUse := False;//nil; end; procedure TForm15.sleepControl(Sender: TObject; const MS: Integer); begin var button := Sender as TButton; ButtonEnable(button, 'Sleeping', not Clickable); Sleep(MS); ButtonEnable(button, 'Stay', not Clickable); Sleep(MS); end; I think that's a feature🙂. I would like the showhint to work when the button is disabled.
-
Delphi has stopping on break points and exceptions
Pat Foley replied to PiedSoftware's topic in Delphi IDE and APIs
More checks The provenance (path) of used units found in hint box showing when mousing over tabs over unit tabs in code window or control tabs on the component bar. Then the transactions in .proj.local can be looked at. These transactions log when units renamed or who knows. Try syntax check or build all from time to time can't hurt! -
Delphi has stopping on break points and exceptions
Pat Foley replied to PiedSoftware's topic in Delphi IDE and APIs
Try clicking Debug in Project manager, first. Be sure the compiled lines have blue dot in left gutter. You may be able to click on lines in the call stack in in debug layout. This backs up the procedure calls in the code window. -
D11.3, Search, Whole words only - randomly checked
Pat Foley replied to mvanrijnen's topic in Delphi IDE and APIs
Does the control Find settings (bottom of Code window) have precedence over control shift Find settings? -
Enlarging the font in code view inside Delphi Alexandria 11.2 Professional
Pat Foley replied to JohnLM's topic in Delphi IDE and APIs
Use Windows magnifier invoked with the windows button with + - keys. The code window font appears not to alias under magnifier. Under 195 mag. 195% screen copy though copying may not show the actual screen output. -
From the help, the Startup layout hides the "saddle bags." The edges of the embedded form designer use some screen for accessing slide outs but huge improvement over default layout for layout and text editing too! I added a second icon with this switch dpunaware for different resolutions. FMX has sizable viewer and shows the background of window behind in form window thumbnail. Either designer doesn't position the design in the thumbnail as designed.