Re: [fpc-pascal] Getting Shift key with PTCCRT

2022-09-10 Thread wkitty42--- via fpc-pascal
On 9/9/22 5:54 PM, James Richters via fpc-pascal wrote: I have some key sequences with PTCCRT.READKEY where I use a lower case letter to do one thing and an uppercase to do another, but if the Capslock is on, they do the wrong things. Is there a way I can check the condition of the shift key to

Re: [fpc-pascal] Getting Shift key with PTCCRT

2022-09-10 Thread James Richters via fpc-pascal
Thanks for the suggestion I think the syntax should be: type myKeyEvent = IPTCKeyEvent; Var myShiftStatus : boolean; myShiftStatus := myKeyEvent.Shift; but I get IPTCKeyEvent not found. I wonder if it's only designated as internal.. or if I need to use something other than PTCGraph and PTCCRT

[fpc-pascal] Get highest element of a StringList

2022-09-10 Thread James Richters via fpc-pascal
I thought I would try: For Loop := 0 to High(MyStringList) do But I get "Error: Type mismatch" Is there a way to get the highest element of a stringlist other than: For Loop := 0 to MyStringList.Count-1 do It would be nice to not have the -1 Could High() be made to work if the argument was a s

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Bart via fpc-pascal
On Sat, Sep 10, 2022 at 6:01 PM James Richters via fpc-pascal wrote: > Is there a way to get the highest element of a stringlist other than: > > For Loop := 0 to MyStringList.Count-1 do You can use the for .. in loop. > It would be nice to not have the -1 > Could High() be made to work if the

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Thomas Kurz via fpc-pascal
Another alternative would be declaring a helper: type TStringListHelper = class helper for TStringList function High: NativeInt; end; function TStringListHelper.High: NativeInt; begin Exit (Self.Count-1); end; - Original Message - From: James Richters via fpc-pascal To: 'FPC-Pascal

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread James Richters via fpc-pascal
This Helper sounds like a nice way to do it. I need the numerical index of the loop so this would be more straight forward. Would I then do something like : For I:= 0 to MyStringList.High Do ? When I try to add the Type statement: type TStringListHelper = class helper for TStringList function Hi

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Thomas Kurz via fpc-pascal
Try this (note the "modeswitch"): program Project1; {$modeswitch typehelpers} uses Classes, SysUtils; type TStringListHelper = class helper for TStringList function High: NativeInt; end; function TStringListHelper.High: NativeInt; begin Exit (Self.Count-1); end; var f: TStringList =

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Thomas Kurz via fpc-pascal
If you just don't like the "-1" for readability, you might also wan't to consider using for i := 0 to Pred(f.Count) do ... - Original Message - From: Thomas Kurz via fpc-pascal To: 'FPC-Pascal users discussions' Sent: Saturday, September 10, 2022, 21:37:34 Subject: [fpc-pascal] Get h

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread James Richters via fpc-pascal
Thank you for the example! I also needed {$Mode OBJFPC} to get it working. I am normally in {$Mode FPC} Or {$Mode TP} But I found that if I just put this in a unit that is {$Mode OBJFPC} and include that unit in my {$Mode TP} Unit it works just great! I have a useless unit that is just a who

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Martin Wynne via fpc-pascal
On 10/09/2022 17:01, James Richters via fpc-pascal wrote: For Loop := 0 to MyStringList.Count-1 do It would be nice to not have the -1 I don't understand what is wrong with Count-1, but you can get the highest index like this if you wish: high_index:=Length(Trim(MyStringList.Text))-Length(

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Travis Siegel via fpc-pascal
But, if that (eventually) leads to the highest one, and that's all that's desired, why not just use the whole expression variable := pred(f.Count) instead of the whole loop? Wouldn't that accomplish the same thing? Why the loop? On 9/10/2022 3:44 PM, Thomas Kurz via fpc-pascal wrote: If you