Menu
  • HOME
  • TAGS

How to call an ASP web api and return JSON from delphi 2007

delphi,delphi-xe5,delphi-2007

I did not find rest client solution for delphi 2007. I end up using indy for this. I use LkJson to handle json. class function TSampleApp.Hello(AModel: TModel): Integer; var idHttp: TIdHTTP; url, sjsonresponse, sjsonrequest: string; strRequest: TStrings; jsonObj: TlkJSONobject; begin Result := -1; url := 'http://localhost:49272/api/test/hello'; idHttp := TIdHTTP.Create; try...

Numeric Linear Interpolation on Delphi [closed]

r,delphi,delphi-xe5,linear-interpolation

Linear interpolation of 1D-data is very simple: Find such index in X-array, that X[i] <= Xb < X[i+1] (binary search for case of random access, linear search for case of step-by step Xb changing) Calculate Yb = Y[i] + (Y[i+1] - Y[i]) * (Xb - X[i]) / (X[i+1] - X[i])...

How to restore object repository after adding a new project type when getting “Invalid image size” error?

delphi,delphi-xe5

Two ways roll this back: 1) delete the RADStudioRepository.xml file that resides in \AppData\Roaming\Embarcadero\BDS\12.0. Delphi recreates a default file when restarted 2) edit the RADStudioRepository.xml file to remove the offending entries....

Indy sends params with GET after POST redirect

delphi,redirect,indy,delphi-xe5,indy10

Client behavior for handling the HTTP 302 reply code is ambiguous, and often treated erroneously by various clients. This is well documented in various RFCs, including 2068 and 2616. The 303 reply code was created to resolve the ambiguity, but many clients still do not support 303 yet, and many...

Why {$IFDEF MSWINDOWS} is replaced with {$IF defined(MSWINDOWS)} in Delphi XE5?

delphi,conditional-statements,delphi-xe5,conditional-compilation,defined

According to the Delphi documentation: http://docwiki.embarcadero.com/RADStudio/XE6/en/Conditional_compilation_%28Delphi%29 The conditional directives {$IFDEF}, {$IFNDEF}, {$IF}, {$ELSEIF}, {$ELSE}, {$ENDIF}, and {$IFEND} allow you to compile or suppress code based on the status of a conditional symbol. The {$IFDEF} and {$IFNDEF} only allow you to work with defines previously set by {$DEFINE ...}. However the...

How to clear a TGridPanelLayout at runtime

delphi,layout,firemonkey,delphi-xe5

It is correct to call Grid.ControlCollection.Clear to delete the items in the collection. From Help: Clear empties the Items array and destroys each TCollectionItem. Note the "destroys", which means it takes ownership and resposnibility of managing the lifetime of the image. You say: an access violation occurs when one of...

Delphi Countdown timer

delphi,timer,countdown,delphi-xe5

You did not say how (in which format) the time is to be entered in the TEdit, so here are three alternative time entry possibilities. The output is anyway formatted as H:M:S. I modified the code from yesterday to use TryStrToInt / TryStrToTime to catch errors. Also, a Seconds counter...

Is it safe to replace array of XXX with TArray

arrays,delphi,generics,delphi-xe5,dynamic-arrays

As already answered, TArray<XXX> is exactly like any other custom type defined as array of XXX. In fact, TArray<XXX> is a custom type defined as array of XXX. That said, a custom type defined as array of XXX is not equivalent to array of XXX in the context of a...

Error F2063 Could not compile used unit (of dependent package)

delphi,delphi-xe5,dcc32

Delphi IDE is far from perfect when it comes to editing/compiling packages but you should solve the problem on your side - configure your packages better and Delphi will compile them correctly. I can only give you general advices addressing the info given: If you need a common include file...

Make Chrome open on second monitor?

delphi,google-chrome,delphi-xe5

Chrome allows you to pass a position and size on the command line with --window-position and --window-size I believe. Check out this page for details.

FastReport 4 and VCL Styles bugs

delphi,delphi-xe5,fastreport,vcl-styles

Effectively both issues it seems VCL Styles bugs. 1) Q: The toolbar gets a white border around it. A: The TToolBarStyleHook Style hook in not handling the BorderWidth property. so you must create a new style hook and override the PaintNC to overcome this issue. type TToolBarStyleHookEx = class(TToolBarStyleHook) protected...

What does an asterisk in the Object Inspector mean?

delphi,delphi-xe5,delphi-ide,object-inspector

You have appeared to have reverse engineered the meaning of the asterisk. Since I guess you have no source for the design time component code you'll need to rely on such reverse engineering, or any documentation that you can find. In the comments you wonder how the component could cause...

Delphi. Firemonkey. TListbox. Is scrollbar visible?

delphi,listbox,firemonkey,delphi-xe5

To adjust form's height or width to accommodate some content you should use ClientWidth and ClientHeight properties of the form rather that Width and Height ClientWidth and ClientHeight hold dimension of form without border, caption and menu area....

Is “Word” from Delphi an equivalent variable to “Char” on Java?

java,delphi,pascal,delphi-xe5,modbus

As you said, a Delphi Word is an unsigned 16 bit type. The Java char likewise is an unsigned 16 bit type. However, you mention Word in the question, but it doesn't appear in the code. Well, you use Word in ReadHoldRegisters but nowhere in Add_CRC16 is the Word type...

How to use TCharHelper?

delphi,char,delphi-xe5

You're not using TCharHelper; you're using the old System.Character IsDigit function instead. The way to use TCharHelper.IsDigit is: if c.IsDigit then ... ...

Call Web Service and Return Error in Delphi 7

web-services,delphi,wsdl,delphi-7,delphi-xe5

I have use THTTPRIO.OnBeforeExecute for change SOAPResponse.Then delete unnecessary attribute and type in XML source and packing again and assign it to SOAPResponse and send it. In this method the problem was solved....

TJSONObject Memory Leak in complex json Object

json,delphi,delphi-xe5

You are never releasing TORDEN variable, hence the memory leak, and error you get when you do try to release it is caused by following lines: for LValue in d do if (LValue as TJSONOBJECT).GetValue('ss').Value = '0' then dlnew.AddElement(LValue); LValue is owned by d and will be released when d...

Can I create GPL licensed software with Delphi? [closed]

delphi,gpl,delphi-xe5

Disclaimer: I am not a lawyer. Assumption: You want to use foreign code in your application that is licensed as GPLv2 only. The only legal way to write software against such code is to make your own source code available as GPLv2 (or a compatible license) as well. You can...

The listviewer not change select in onshow

delphi,delphi-xe5,items

I created a simple application with a list view, set it into report mode, added some items, and added this OnShow event: procedure TForm1.FormShow(Sender: TObject); begin ListView1.Items[1].Selected := True; end; The specified item was indeed selected. The conclusion that I draw from this is that the Selected property can be...

How I can configure firedac to relative path to database firebird in DesignTime

delphi,delphi-xe5,firedac

I'm not sure if it's possible. Even if it were, it doesn't sound like a reliable solution. FireDAC would need to have some explicit option to define a working directory for its design time part. Otherwise it would be tied to the IDE's working directory. Instead I would make a...

Save current windows theme to vsf file

delphi,delphi-xe5,vcl-styles

You cannot save it, that is theme that is not drawn with help of VCL Styles, but by Windows itself.

Using GetLastAutoGenValue

delphi,informix,delphi-xe5,firedac

I made it work out using following query in my stored proc: SELECT DBINFO('sqlca.sqlerrd1') FROM SYSTABLES WHERE tabname = '<tablename>' and return the same value in Stored Proc....

SQLite insert on android works only once

sqlite,delphi,delphi-xe5

Try this method it works for me procedure TData.InsertItem(someObject: TSomeObjectClass); var qry: TFDQuery; begin qry := CreateQry( 'insert into SomeObject(id, description, something)'+ ' values (:id, :description, :something);', false); qry.Params.ParamByName('id').AsInteger := someObject.id; qry.Params.ParamByName('description').asstring := someObject.description; qry.Params.ParamByName('something').asstring := someObject.something; qry.Prepare; qry.execsql; qry.Free; end; I've put and object in the parameter but you...

How to send email using gmail app in Delphi XE5?

android,delphi,gmail,firemonkey,delphi-xe5

Found it: procedure TfrmSendMail.CreateEmail(const Recipient, Subject, Content, Attachment, Attachment2: string); var Intent: JIntent; Uri: Jnet_Uri; AttachmentFile: JFile; begin Intent := TJIntent.Create; Intent.setAction(TJIntent.JavaClass.ACTION_SEND_MULTIPLE); Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); Intent.putExtra(TJIntent.JavaClass.EXTRA_EMAIL, StringToJString(Recipient)); Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString(Subject)); Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT,...

How to have a list of options when clicking a TButton on Firemonkey?

delphi,firemonkey,delphi-xe5

Look here: http://blogs.embarcadero.com/sarinadupont/2013/10/17/463/ Is an example for mobile, but you use in desktop too....

Recover code after crash

delphi,crash,delphi-xe5

Apart from time travel which is already mentioned in the comments I think there is no other way to recover your code. But you can avoid this in the future by installing DDevExtensions. This extension creates backups of your files after every successful compile. Or you can check Autosave in...

TRestClient/TRestRequest incorrectly decodes gzip response

delphi,rest,utf-8,gzip,delphi-xe5

Remy Lebeau's input in his answer to this question as well as his comment to the answer in the question Automatically Decode GZIP In TRESTResponse? put me on the right track. Like he said, setting AcceptEncoding doesn't suffice, because the TIdHTTP that performs the actual request doesn't have a decompressor...

Making Auto-Typer In Delphi?

delphi,delphi-xe5

The supported way to fake input is not to use SendMessage and PostMessage. Instead call SendInput which places input events into the message queue of the foreground window. This is how the .net SendKeys method is implemented. In the comments you say that you used keybd_event. This is not advisable....

What control should I use to create this UI in Delphi Firemonkey

delphi,grid,delphi-xe,firemonkey,delphi-xe5

The style here is so different from a standard TListBoxItem style that is probably makes sense to start from scratch, in which case the issues with accessing the default styles become immaterial. Add a TStyleBook to your form. Set the StyleBook property of the form to point to it. Double...

Application taking a really long time to synch threads ( or not at all )

multithreading,delphi,delphi-xe5

The problem is that TThread.Synchronize() is broken in FireMonkey. See this QC report: Report #123579: TThread.Synchronize() and TThread.Queue() do not work correctly in FireMonkey This has only just recently been discovered, but it has been broken since FireMonkey was first introduced and nobody apparently noticed until now. Until Embarcadero fixes...

How can I save the thread results in a Database

android,database,multithreading,delphi,delphi-xe5

Problem The problem is that the TImageLoader.LoadImage loads the data from the net asynchronously. Because of that the data is not yet available at the time when you're loading the data. Simple solution In order to stop TImageLoader from doing that you can add an extra method to it and...

Need to read a file, of any extension one byte at a time XE5 into dynamic array

delphi,delphi-xe5,dynamic-arrays,tfilestream

Is the file large ? Can it fit into RAM all at once ? You basically have two simple options to create a DynArray out of the file, but they are only recommended for small to middle files. 1: http://www.freepascal.org/docs-html/rtl/classes/tbytesstream.html var BS: TBytesStream; b: byte; L, i: integer; begin BS...

In Delphi, what's the keyword for the maximal value for a floating point type?

delphi,delphi-xe5

System.Math unit contains Infinity constant to represent IEEE754 Inf pseudovalue(1.0/0.0). There are also a lot of MaxDouble, MaxExtended etc constants in this unit (look at Variables section here). This short test works as needed, so I suspect your component may have some kind of range checking or have property editor...

Why is the captured parameter reset in this anonymous method?

delphi,delphi-xe5,anonymous-methods

You're seeing undefined behavior. The article you cite mentions that the method reference needs to remain alive for the lifetime of the method pointer, but your code breaks that rule. The object associated with the method reference may get destroyed, so the dbGrid variable that held the captured value no...

SOAP request created with RTTI not completely parsed to XML

delphi,soap,delphi-xe5,rtti

As @J... suggested the problem was that (somehow) the dynamic arrays were falling out of scope when sending the request. To solve the problem we are assigning to each dynamic array property of the request a copy of the same dynamic array after creating the request but before sending it...

Corrupted data after saving and loading VirtualStringTree

delphi,delphi-xe5,virtualtreeview

I found this Link and changed the awnser to fit my code. Data.Symbol[1] //Simply points to a char. So I changed it to 'char' Read: Stream.Read(Len, SizeOf(Len)); SetLength(Data.Column0, Len); Stream.Read(PChar(Data.Column0)^, Len * SizeOf(Char)); //Copy/Paste this code for all Columns Write: Len := Length(Data.Column0); Stream.Write(Len, SizeOf(Len)); Stream.Write(PChar(Data.Column0)^, Length(Data.Column0) * SizeOf(Char)); //Copy/Paste...

IDE Insight quit working

delphi,delphi-xe5,delphi-xe6

The IDE Insight window was removed in XE5. Instead, there's an edit box top right of the screen (Ctrl+. gives it the focus) that you type into and get a dropdown list of commands to pick from in response. This is documented in What's New in Delphi and C++Builder XE5....

Can't open project: “One or more lines were too long and have been truncated”

delphi,delphi-xe5

From the comments, you have Dropbox, and the Restore functionality is available, but using it would cost you a week's worth of work. If I was in that situation, here's what I would do: Copy the current file to somewhere else (My Documents, for example). Use Dropbox Restore to get...

How to make my own dialog component from Firemonkey TPopUp?

delphi,firemonkey,delphi-xe5,firemonkey-fm3

When you create the TPopupTest in your form you have to set the creator's owner to your Form, as well as the Parent. Changing the Unit to something like this will make it appear but it's not exactly as you picture it, you will have to refine it a bit....

Form border color and thickness on Firemonkey

delphi,firemonkey,delphi-xe5

As stated on the top of the question there is a generic answer for this question. There is a need of the style windowborderstyle be present and all these descendant stuff. However the Firemonley Styles MetropolisUI that comes with Delphi XE2 - XE5 do not have that style defined. If...

Delphi XE5 Android problems locating file

android,delphi,delphi-xe5,file-location

I finally found out how to solve this. By using TPath.GetSharedDocumentsPath I could see the file saved from the app on the pc if the device NOT was connected as a drive when saving (mentioned on this page). E.i. When using the app, the pc can't be using the sdcard...

Delphi Stopwatch time format

delphi,time,format,delphi-xe5,stopwatch

See http://docwiki.embarcadero.com/Libraries/en/System.SysUtils.Format labelSW.Text := Format('%2.2u:%2.2u:%2.2u:%3.3u',[Hour,Min,Sec,MSec]); The precision specifier makes left padding with zeroes. Using the RTL TStopwatch advanced record in System.Diagnostics, it gets a little easier: uses System.SysUtils, System.Diagnostics; var sw: TStopwatch; ... sw := TStopwatch.StartNew; // Start measuring time ... procedure TForm1.TimerSWTimer(Sender: TObject); begin LabelSW.Text := FormatDateTime('hh:nn:ss:zzz',sw.ElapsedMilliseconds/MSecsPerDay);...

How to install Cindy Component on Delphi XE5?

windows,delphi,installation,components,delphi-xe5

It's likely that you are trying to load the 64 bit version of the package. This should not be loaded at design time. The instructions for building the Cindy library include building both the 32 bit packages and 64 bit packages. Make sure that you build both but only the...

Delphi ADO: save DBEdit changes

excel,delphi,ado,delphi-xe5

Post is automatically called when the user navigates to another record. The only time you need to call Post is if the currently selected record has pending changes at the time you close the form. But even then, you don't have to call Post explicitly: there's a helper function CheckBrowseMode...

Making a scrollable app for Android?

android,delphi,scroll,delphi-xe5

You need to place a control such as a TLayout as the immediate child of the TScrollBox. Set it's Position at (0,0) and Height/Width as necessary for your controls. This size is what is used by the scroll box for it's scroll bars. Then place your actual controls onto the...

The TEdit.Height is fixed on Firemonkey Style, How to change it?

delphi,firemonkey,delphi-xe5

As a last resource I have decided to open the MetropolisUI.Style on notepad and take a look on what is inside. I have found that "editstyle" that is the default for TEdit has the following structure: object TLayout StyleName = 'editstyle' Height = 50.000000000000000000 Width = 50.000000000000000000 FixedHeight = 32...

Storing reference to object in TeeChart

delphi,vcl,delphi-xe5,teechart

You can exploit unused AXLabel argument like this: for DevIndex := 0 to DeviceCount - 1 do begin Device := FDevices[DevIndex]; BubbleSeries.AddBubble(Device.CalculateXVal,Device.CalculateYVal, Device.CalculateRadius, IntToStr(DevIndex)); end; // to avoid labels' text ox X-Axis: Chart1.BottomAxis.LabelStyle := talValue; //in Clicked: DeviceIndex := StrToInt(BubbleSeries.Labels[Index]); ...