Search Results

Search found 4237 results on 170 pages for 'delphi 2009'.

Page 38/170 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • Delphi 6: How to search a dynamic array for sub-string quickly?

    - by Robert Oschler
    How can I search a dynamic array of char in Delphi 6 for a sub-string and get back an index to a match, not a pointer? I've seen functions in Delphi 6 that do this for strings but not for dynamic char arrays. There is a function called SearchBuf but that function returns a PChar pointer to the match location when what I need is the array index of the match. Thanks.

    Read the article

  • Which bug in the Delphi IDE / VCL do you despise the most?

    - by Ben Daniel
    I've been working in Delphi 7 for the last 6 years now and have learnt to merely submit to the instablity of the IDE. For example, there are particular projects I've inherited which, when working on, I cannot use the CTRL+SPACE dropdown symbol list in the Delphi editor without getting an Access Violation error, this would easily top my list but there are many more. I'd like to know which bugs frustrate you the most.

    Read the article

  • delphi remove . and .. from path

    - by user80003
    Hello everyone. How can I remove the . and .. from a path in Delphi (not using .NET). I need a function, so I can pass it something like 'c:\program files..\program files...', and I want the function to return to me 'c:\'. Can Delphi do that on its own? Or do I need to do it myself?

    Read the article

  • How to pass multiple different records (not class due to delphi limitations) to a function?

    - by mingo
    Hi to all. I have a number of records I cannot convert to classes due to Delphi limitation (all of them uses class operators to implement comparisons). But I have to pass to store them in a class not knowing which record type I'm using. Something like this: type R1 = record begin x :Mytype; class operator Equal(a,b:R1) end; type R2 = record begin y :Mytype; class operator Equal(a,b:R2) end; type Rn = record begin z :Mytype; class operator Equal(a,b:Rn) end; type TC = class begin x : TObject; y : Mytype; function payload (n:TObject) end; function TC.payload(n:TObject) begin x := n; end; program: c : TC; x : R1; y : R2; ... c := TC.Create(): n:=TOBject(x); c.payload(n); Now, Delphi do not accept typecast from record to TObject, and I cannot make them classes due to Delphi limitation. Anyone knows a way to pass different records to a function and recognize their type when needed, as we do with class: if x is TMyClass then TMyClass(x) ... ???

    Read the article

  • Why is Delphi unable to infer the type for a parameter TEnumerable<T>?

    - by deepc
    Consider the following declaration of a generic utility class in Delphi 2010: TEnumerableUtils = class public class function InferenceTest<T>(Param: T): T; class function Count<T>(Enumerable: TEnumerable<T>): Integer; overload; class function Count<T>(Enumerable: TEnumerable<T>; Filter: TPredicate<T>): Integer; overload; end; Somehow the compiler type inference seems to have problems here: var I: Integer; L: TList<Integer>; begin TEnumerableUtils.InferenceTest(I); // no problem here TEnumerableUtils.Count(L); // does not compile: E2250 There is no overloaded version of 'Count' that can be called with these arguments TEnumerableUtils.Count<Integer>(L); // compiles fine end; The first call works as expected and T is correctly inferred as Integer. The second call does not work, unless I also add <Integer -- then it works, as can be seen in the third call. Am I doing something wrong or is the type inference in Delphi just not supporting this (I don't think it is a problem in Java which is why expected it to work in Delphi, too).

    Read the article

  • Is there a way to log every gui event in Delphi?

    - by awmross
    The Delphi debugger is great for debugging linear code, where one function calls other functions in a predictable, linear manner, and we can step through the program line by line. I find the debugger less useful when dealing with event driven gui code, where a single line of code can cause new events to be trigerred, which may in turn trigger other events. In this situation, the 'step through the code' approach doesn't let me see everything that is going on. The way I usually solve this is to 1) guess which events might be part of the problem, then 2) add breakpoints or logging to each of those events. The problem is that this approach is haphazard and time consuming. Is there a switch I can flick in the debugger to say 'log all gui events'? Or is there some code I can add to trap events, something like procedure GuiEventCalled(ev:Event) begin log(ev); ev.call(); end The end result I'm looking for is something like this (for example): FieldA.KeyDown FieldA.KeyPress FieldA.OnChange FieldA.OnExit FieldB.OnEnter This would take all the guesswork out of Delphi gui debugging. I am using Delphi 2010

    Read the article

  • Unicode To ASCII Conversion [closed]

    - by Yuvaraj
    Hi all, i creating an small application in Delphi 2009. here i got problem that when i run my application in WindowsXP its working but it is not working in Windows95. i know the problem that 95 will not support Unicode. if anyone knows the solution please tell me. and also i have one more idea that converting Unicode to ASCII. is it possible please tell how to do that. Thanks in Advance Worm Regards, Yuvaraj

    Read the article

  • Can't get the new 2009 XAML primitives working, why?

    - by Will
    What I'd like to use: 2009 XAML primitives How it would be nice to use them: <sapv:ExpressionTextBox xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ExpressionType="x:String" /> What actually happens: "Type reference cannot find the public type named String" The examples I see don't have updated namespaces. I tried 2009 and 2010, but to no avail. This is in VS 2010 RTM. What am I doing wrong?

    Read the article

  • interesting Delphi open-source applications/projects (not components/component packs!)

    - by vic
    Hi, I'd like to know what interesting open-source projects written in Delphi (or FreePascal) you know? I'm not asking for components/components packs, I know there were questions for that. Please do not duplicate answers, vote them up instead ;) Please do not point components/packs/closed-source projects. Please provide at least word of description ;) Two examples from me: PyScripter - Python IDE written in Delphi - hosted at google code (*) HeidiSQL - MySQL Frontend - http://www.heidisql.com/ (*)sorry, as a new user I can't post more than one link :(

    Read the article

  • In Delphi 7, why can I assign a value to a const?

    - by Blorgbeard
    I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this: procedure TForm1.CalculateGP(..) const Price : money = 0; begin ... Price := 1.0; ... end; So in the new project, Delphi complains that "left side cannot be assigned to" - understandable! But this code compiles in the old project. So my question is, why? Is there a compiler switch to allow consts to be reassigned? How does that even work? I thought consts were replaced by their values at compile time?

    Read the article

  • C# - calling ext. DLL function containing Delphi "variant record" parameter

    - by CaldonCZE
    Hello, In external (Delphi-created) DLL I've got the following function that I need to call from C# application. function ReadMsg(handle: longword; var Msg: TRxMsg): longword; stdcall; external 'MyDll.dll' name 'ReadMsg'; The "TRxMsg" type is variant record, defined as follows: TRxMsg = record case TypeMsg: byte of 1: (accept, mask: longword); 2: (SN: string[6]); 3: (rx_rate, tx_rate: word); 4: (rx_status, tx_status, ctl0, ctl1, rflg: byte); end; In order to call the function from C#, I declared auxiliary structure "my9Bytes" containing array of bytes and defined that it should be marshalled as 9 bytes long array (which is exactly the size of the Delphi record). private struct my9Bytes { [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.U1, SizeConst = 9)] public byte[] data; } Then I declared the imported "ReadMsg" function, using the "my9bytes" struct. [DllImport("MyDll.dll")] private static extern uint ReadMsg(uint handle, ref my9Bytes myMsg); I can call the function with no problem... Then I need to create structure corresponding to the original "TRxMsg" variant record and convert my auxiliary "myMsg" array into this structure. I don't know any C# equivalent of Delphi variant array, so I used inheritance and created the following classes. public abstract class TRxMsg { public byte typeMsg; } public class TRxMsgAcceptMask:TRxMsg { public uint accept, mask; //... } public class TRxMsgSN:TRxMsg { public string SN; //... } public class TRxMsgMRate:TRxMsg { public ushort rx_rate, tx_rate; //... } public class TRxMsgStatus:TRxMsg { public byte rx_status, tx_status, ctl0, ctl1, rflg; //... } Finally I create the appropriate object and initialize it with values manually converted from "myMsg" array (I used BitConverter for this). This does work fine, this solution seems to me a little too complicated, and that it should be possible to do this somehow more directly, without the auxiliary "my9bytes" structures or the inheritance and manual converting of individual values. So I'd like to ask you for a suggestions for the best way to do this. Thanks a lot!

    Read the article

  • What is the difference between a constructor and a procedure in Delphi records?

    - by HMcG
    Is there difference in behavior between a constructor call and a procedure call in Delphi records? I have a D2010 code sample I want to convert to D2009 (which I am using). The sample uses a parameterless constructor, which is not permitted in Delphi 2009. If I substitute a simple parameterless procedure call, is there any functional difference for records? I.E. TVector = record private FImpl: IVector; public constructor Create; // not allowed in D2009 end; becomes TVector = record private FImpl: IVector; public procedure Create; // so change to procedure end; As far as I can see this should work, but I may be missing something.

    Read the article

  • How to disable a warning in Delphi about "return value ... might be undefined"?

    - by Lasse V. Karlsen
    I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function is: Result := ''; and there is no local variable or parameter called Result either. Is there any kind of pragma-like directive I can surround this method with to remove this warning? This is Delphi 2007. Unfortunately, the help system on this Delphi installation is shot, so I can't pop up the help for that warning right now. Anyone know off the top of their head what I can do?

    Read the article

  • Need to allocate memory before a Delphi string copy?

    - by Duncan
    Do I need to allocate memory when performing a Delphi string copy? I've a function which posts a Windows message to another form in my application. It looks something like this: // Note: PThreadMessage = ^TThreadMessage; TThreadMessage = String; function PostMyMessage( aStr : string ); var gMsgPtr : PThreadMessage; gStrLen : Integer; begin New(gMsgPtr); gStrLen := StrLen(PWideChar(aMsg)); gMsgPtr^ := Copy(aMsg, 0, gStrLen); PostMessage(ParentHandle, WM_LOGFILE, aLevel, Integer(gMsgPtr)); // Prevent Delphi from freeing this memory before consumed. LParam(gMsgPtr) := 0; end;

    Read the article

  • Bug in Delphi XE RegularExpressions Unit

    - by Jan Goyvaerts
    Using the new RegularExpressions unit in Delphi XE, you can iterate over all the matches that a regex finds in a string like this: procedure TForm1.Button1Click(Sender: TObject); var RegEx: TRegEx; Match: TMatch; begin RegEx := TRegex.Create('\w+'); Match := RegEx.Match('One two three four'); while Match.Success do begin Memo1.Lines.Add(Match.Value); Match := Match.NextMatch; end end; Or you could save yourself two lines of code by using the static TRegEx.Match call: procedure TForm1.Button2Click(Sender: TObject); var Match: TMatch; begin Match := TRegEx.Match('One two three four', '\w+'); while Match.Success do begin Memo1.Lines.Add(Match.Value); Match := Match.NextMatch; end end; Unfortunately, due to a bug in the RegularExpressions unit, the static call doesn’t work. Depending on your exact code, you may get fewer matches or blank matches than you should, or your application may crash with an access violation. The RegularExpressions unit defines TRegEx and TMatch as records. That way you don’t have to explicitly create and destroy them. Internally, TRegEx uses TPerlRegEx to do the heavy lifting. TPerlRegEx is a class that needs to be created and destroyed like any other class. If you look at the TRegEx source code, you’ll notice that it uses an interface to destroy the TPerlRegEx instance when TRegEx goes out of scope. Interfaces are reference counted in Delphi, making them usable for automatic memory management. The bug is that TMatch and TGroupCollection also need the TPerlRegEx instance to do their work. TRegEx passes its TPerlRegEx instance to TMatch and TGroupCollection, but it does not pass the instance of the interface that is responsible for destroying TPerlRegEx. This is not a problem in our first code sample. TRegEx stays in scope until we’re done with TMatch. The interface is destroyed when Button1Click exits. In the second code sample, the static TRegEx.Match call creates a local variable of type TRegEx. This local variable goes out of scope when TRegEx.Match returns. Thus the reference count on the interface reaches zero and TPerlRegEx is destroyed when TRegEx.Match returns. When we call MatchAgain the TMatch record tries to use a TPerlRegEx instance that has already been destroyed. To fix this bug, delete or rename the two RegularExpressions.dcu files and copy RegularExpressions.pas into your source code folder. Make these changes to both the TMatch and TGroupCollection records in this unit: Declare FNotifier: IInterface; in the private section. Add the parameter ANotifier: IInterface; to the Create constructor. Assign FNotifier := ANotifier; in the constructor’s implementation. You also need to add the ANotifier: IInterface; parameter to the TMatchCollection.Create constructor. Now try to compile some code that uses the RegularExpressions unit. The compiler will flag all calls to TMatch.Create, TGroupCollection.Create and TMatchCollection.Create. Fix them by adding the ANotifier or FNotifier parameter, depending on whether ARegEx or FRegEx is being passed. With these fixes, the TPerlRegEx instance won’t be destroyed until the last TRegEx, TMatch, or TGroupCollection that uses it goes out of scope or is used with a different regular expression.

    Read the article

  • Switching Programming Languages

    - by no spoon
    Hi I'm a senior level Delphi developer looking for move into either C# or possibly Java roles. I have around 8 years of development experience of which pretty much all of it is in Delphi, I have very little commercial experience in C# and no commercial experience in Java. I have about 6 months worth of academic experience in both Java and C# from some University papers I took a 4 years ago and use these languages for hobby projects, so I know the languages I just don't have the commercial experience to back it up. Given that I'm too over qualified for a junior role but do not have the commercial experience for even an intermediate role how does one go about changing jobs?

    Read the article

  • Generate lags R

    - by Btibert3
    Hi All, I hope this is basic; just need a nudge in the right direction. I have read in a database table from MS Access into a data frame using RODBC. Here is a basic structure of what I read in: PRODID PROD Year Week QTY SALES INVOICE Here is the structure: str(data) 'data.frame': 8270 obs. of 7 variables: $ PRODID : int 20001 20001 20001 100001 100001 100001 100001 100001 100001 100001 ... $ PROD : Factor w/ 1239 levels "1% 20qt Box",..: 335 335 335 128 128 128 128 128 128 128 ... $ Year : int 2010 2010 2010 2009 2009 2009 2009 2009 2009 2010 ... $ Week : int 12 18 19 14 15 16 17 18 19 9 ... $ QTY : num 1 1 0 135 300 270 300 270 315 315 ... $ SALES : num 15.5 0 -13.9 243 540 ... $ INVOICES: num 1 1 2 5 11 11 10 11 11 12 ... Here are the top few rows: head(data, n=10) PRODID PROD Year Week QTY SALES INVOICES 1 20001 Dolie 12" 2010 12 1 15.46 1 2 20001 Dolie 12" 2010 18 1 0.00 1 3 20001 Dolie 12" 2010 19 0 -13.88 2 4 100001 Cage Free Eggs 2009 14 135 243.00 5 5 100001 Cage Free Eggs 2009 15 300 540.00 11 6 100001 Cage Free Eggs 2009 16 270 486.00 11 7 100001 Cage Free Eggs 2009 17 300 540.00 10 8 100001 Cage Free Eggs 2009 18 270 486.00 11 9 100001 Cage Free Eggs 2009 19 315 567.00 11 10 100001 Cage Free Eggs 2010 9 315 569.25 12 I simply want to generate lags for QTY, SALES, INVOICE for each product but I am not sure where to start. I know R is great with Time Series, but I am not sure where to start. I have two questions: 1- I have the raw invoice data but have aggregated it for reporting purposes. Would it be easier if I didn't aggregate the data? 2- Regardless of aggregation or not, what functions will I need to loop over each product and generate the lags as I need them? In short, I want to loop over a set of records, calculate lags for a product (if possible), append the lags (as they apply) to the current record for each product, and write the results back to a table in my database for my reporting software to use. Any help you can provide will be greatly appreciated! Many thanks in advance, Brock

    Read the article

  • How do i convert a string to a JSON object in JQuery?

    - by Rob
    I have a string in my db I want to pull into my page and convert to a json object. [ {id: 1,title: "Long Event", start: new Date(2009, 5, 6, 14, 0),end: new Date(2009, 5, 11)}, {id: 2,title: "Repeating Event", start: new Date(2009, 5, 2)}, {id: 3,title: "Meeting", start: new Date(2009, 5, 20, 9, 0)}, {id: 4,title: "Click for Facebook", start: new Date(2009, 5, 27, 16),end: new Date(2009, 5, 29), url: "http://facebook.com/"} ] How can I do this using JQuery?

    Read the article

  • Oracle date / order by question

    - by user561793
    I want to select a date from oracle table formatted like select (to_char(req_date,'MM/YYYY')) but I also want to order the result set on this date format. I want them to be ordered like dates not strings. Like this 09/2009 10/2009 11/2009 12/2009 01/2010 02/2010 03/2010 04/2010 05/2010 06/2010 07/2010 08/2010 09/2010 10/2010 11/2010 12/2010 Not like 01/2010 02/2010 03/2010 04/2010 05/2010 06/2010 07/2010 08/2010 09/2009 09/2010 10/2009 10/2010 11/2009 11/2010 12/2009 12/2010 Any way to do this in sql? full sql is select (to_char(req_date,'MM/YYYY')) as monthYear,count(req_id) as count from REQUISITION_CURRENT t group by to_char(req_date,'MM/YYYY') Thanks

    Read the article

  • Why does my Delphi program's memory continue to grow?

    - by lkessler
    I am using Delphi 2009 which has the FastMM4 memory manager built into it. My program reads in and processes a large dataset. All memory is freed correctly whenever I clear the dataset or exit the program. It has no memory leaks at all. Using the CurrentMemoryUsage routine given in spenwarr's answer to: http://stackoverflow.com/questions/437683/how-to-get-the-memory-used-by-a-delphi-program, I have displayed the memory used by FastMM4 during processing. What seems to be happening is that memory is use is growing after every process and release cycle. e.g.: 1,456 KB used after starting my program with no dataset. 218,455 KB used after loading a large dataset. 71,994 KB after clearing the dataset completely. If I exit at this point (or any point in my example), no memory leaks are reported. 271,905 KB used after loading the same dataset again. 125,443 KB after clearing the dataset completely. 325,519 KB used after loading the same dataset again. 179,059 KB after clearing the dataset completely. 378,752 KB used after loading the same dataset again. It seems that my program's memory use is growing by about 53,400 KB upon each load/clear cycle. Task Manager confirms that this is actually happening. I have heard that FastMM4 does not always release all of the program's memory back to the Operating system when objects are freed so that it can keep some memory around when it needs more. But this continual growing bothers me. Since no memory leaks are reported, I can't identify a problem. Does anyone know why this is happening, if it is bad, and if there is anything I can or should do about it?

    Read the article

  • How to create an instance of object with RTTI in Delphi 2010?

    - by Paul
    As we all known, when we call a constructor of a class like this: instance := TSomeClass.Create; The Delphi compiler actually do the following things: Call the static NewInstance method to allocate memory and initialize the memory layout. Call the constructor method to perform the initialization of the class Call the AfterConstruction method It's simple and easy to understand. but I'm not very sure how the compiler handle exceptions in the second and the third step. It seems there are no explicit way to create an instance using a RTTI constructor method in D2010. so I wrote a simple function in the Spring Framework for Delphi to reproduce the process of the creation. class function TActivator.CreateInstance(instanceType: TRttiInstanceType; constructorMethod: TRttiMethod; const arguments: array of TValue): TObject; var classType: TClass; begin TArgument.CheckNotNull(instanceType, 'instanceType'); TArgument.CheckNotNull(constructorMethod, 'constructorMethod'); classType := instanceType.MetaclassType; Result := classType.NewInstance; try constructorMethod.Invoke(Result, arguments); except on Exception do begin if Result is TInterfacedObject then begin Dec(TInterfacedObjectHack(Result).FRefCount); end; Result.Free; raise; end; end; try Result.AfterConstruction; except on Exception do begin Result.Free; raise; end; end; end; I feel it maybe not 100% right. so please show me the way. Thanks!

    Read the article

  • How to build the SysUtils.Format string function in Delphi?

    - by Sam
    If I have the following Delphi code type TFormatArgs = array of TVarRec; procedure DelphiGodsGiveMeTheAnswerPrettyPlease; var iMyAge: integer; iMyIQ: integer; sCode: string; sText: string; begin iMyAge := 5; iMyIQ := -5; sCode := 'Format(''My age is %d and my IQ is %d'', [iMyAge, iMyIQ])'; sText := FormatThis(sCode, iMyAge, iMyIQ); end; function FormatThis(sFormatCode: string; iVar1: integer; iVar2: integer): string; var sFormatString: string; arFormatArgs: TFormatArgs; begin sFormatString := GetFormatString(sFormatCode); // I can implement this function arFormatArgs := ConstructFormatArgs(iVar1, iVar2); // NEED HELP HERE! result := SysUtils.Format(sFormatString, arFormatArgs); end; How can I implement my ConstructFormatArgs function in Delphi (not Assembly)? I'm afraid the assembly code in SysUtils.WideFormatBuf is just a little bit beyond my comprehension skills! Any ideas? I'm seeking divine assistance. Even if you can contribute just a little hint here and there on how to improve it or help me progress with this exercise. TIA.

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >