Pascal

Pascal is an influential imperative and procedural programming language, largely (but not exclusively) intended to teach students structured programming and data structuring. Pasca was implemented on a wide range of architectures, from early PCs to mainframes. Pascal derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal). Pascal is a purely procedural language and includes control statements with reserved words, but has many data structuring facilities and other abstractions like type definitions, records, pointers, enumerations, and sets.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have written a Fire Monkey (mobile phone) application that also runs on Windows. So far so good.

Although it is not recommended by Embarcadero, I also have been able to compile the Fire Monkey into a VCL project. They don't interact, apart from the VCL calling the main frame of the Fire Monkey app, and then receiving back control when all is complete.

It is a little ugly at the user interface end, in that the Fire Monkey app also appears on the windows task bar, even when it is not running.

Also when I tested it on Vista I get an exception on closing the VCL.

Therefore, following Embarcadero's recommendation, I have written a DLL interface that embodies the Fire Monkey component. However I am doing something wrong, because as soon as I carry out a task in a sub-unit referencing the main form I get a data exception.

library LangDLL;

uses
  FMX.Forms,
  System.SysUtils,
  System.Classes,
  uMMain in 'uMMain.pas',
  uMAccess in 'uMAccess.pas',
  uUnique in 'uUnique.pas';

{$R *.res}

procedure ShowMobile; stdcall export;
var
  MM: TfMMain;
  test: string;
begin
  test := 'OK';
try
  MM := TfMMain.Create(application);
  MM.FormActivate(application);
  MM.Free;
except
  test := 'Failed';
end;
end;
exports
  ShowMobile;
begin
end.

Open in new window


It passes through the above code without a worry, and in the main part of the App it works OK.

I have a couple of units that are called by the program. When the logic flows to those units in the DLL style operation the form fMMain is now nil to them. (It is OK when it runs as a stand-alone program.)

The simple work-around would be eliminate those units, but why is fMMain = nil in this situation?
0
I want to be able to restrict a license to a given network IP address, on the assumption that only one network will have that address.

If that assumption is valid, I need the Delphi code to retrieve the IP address of a given network so that I only allow access to computers that are actually on that network.

I will use that IP address to validate the license, by running an already existing routine on the Internet each time a new computer tries to get a Registration Key.
0
Back in the old-old days, I could change an application icon dynamically in the program code,

e.g. application.Icon.LoadFromResourceName(hInstance,'XIcon_Spanish');

This code now does not work; it appears that you can only set the icon through the options screen.
0
Hi, I'm using delphi and I would like to open a web page, fill a field and press submit automatically without the user intervention.

For example, I could call google, fille the search field and press search button and then I would read the results with my program, all this without the user seeing his web application open.    I'm usually using GetInetFile to perform this kind of thing but I don't know how to interact with the web form.
0
With a normal combox you can force the box to open when you enter the field. How do you make this happen with TDatePicker in combox mode?

I have tried the code shown below, but this doesn't activate.
SendMessage(cbContact.Handle, CB_SHOWDROPDOWN, 1, 0);

Open in new window

0
I have exit procedures on lots of visual controls, but when the user hits buttons with the function cancel or exit I want to stop processing on all these exit processes.

Since the program does not get to the Cancel or Exit buttons until it has it completed the exit processes, it takes two clicks to exit the form.

Is the unavoidable, or is there a way this natural processing can be circumvented?

Here is a piece of code I have written to demonstrate the problem:

procedure TForm1.Button1Exit(Sender: TObject);
begin
  MessageDlg('I am here', mtInformation, [mbOK], 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  ActiveControl := Button1;
end;

Open in new window


In this program, it starts with the focus on Button1, so when I click Button2, I still get the message from Button1. This is the type of action I want to avoid.
0
I have a URL that delivers a page response that I can interrogate.

In VCL this is (relatively) simple, using a TWebBrowser component: WebBrowser1.Navigate(RequestURL), and then interrogating the response in a WebBrowser1NavigateComplete2 function

How do you do this in FireMonkey?
0
My environment is Delphi 2006 using dbGo components connected to SQL Server 2008 R2 Express.

I am trying to insert a new record into a table using a standard INSERT as below
ALTER TABLE LoggerPrice DISABLE TRIGGER ALL;

INSERT INTO LoggerPrice (LoggerCode, GangCode, ForestCode, Compartment, Stand, LogQuality, Market, LogGrade, LogLength, Price)
VALUES ('BLACK', 'G1', 'HARBOU', '1', '1', 'EPULP', 'Domestic', 'ALL', 'ALL', 1.00);

ALTER TABLE LoggerPrice ENABLE TRIGGER ALL

Open in new window

This works fine from SQL Management Studio, but running the same code from Delphi produces an error stating "Field LoggerCode must contain a valid value" Despite the error the record is added correctly.

The code used is as follows
 if not (DataSet.State in [dsInsert]) then
     exit;
 LoggerCode:= DataSet.FieldByName('LoggerCode').AsString;
 GangCode:= DataSet.FieldByName('GangCode').AsString;
 ForestCode:= DataSet.FieldByName('ForestCode').AsString;
 Compartment:= DataSet.FieldByName('Compartment').AsString;
 Stand:= DataSet.FieldByName('Stand').AsString;
 LogQuality:= DataSet.FieldByName('LogQuality').AsString;
 Market:= DataSet.FieldByName('Market').AsString;
 LogGrade:= DataSet.FieldByName('LogGrade').AsString;
 LogLength:= DataSet.FieldByName('LogLength').AsString;
 Price:= DataSet.FieldByName('Price').AsFloat;
 DataSet.Cancel;
 DataSet.Close;
 DataModule1.tblLoggerPrice.MasterSource:= nil;
 DataModule1.ADOCommand1.CommandText:= 'ALTER TABLE LoggerPrice DISABLE TRIGGER ALL';
 

Open in new window

0
I'm using Delphi XE6 plus the Mobile add-on. I'm new to mobile app development and just doing a little testing on my iPhone 5s. I'm trying to replicate the functionality found in the iPhone Contacts app for IOS 7.1 when you click the plus (+) sign to add a new contact. The form (?) or TabItem slides up from the bottom of the screen. Using the Gestures I can slide side to side, tabitem to tabitem, but I would like to know how to mimic the sliding up and down.

Thanks for any useful suggestions.
0
In Delphi VCL, I am reading a cds file into a TclientDataSet, and I don't want anyone else to be able to open it.

If I use this code, I cannot even open the file - it gives an error:

  result := true;
  try
    StreamWords := TFileStream.create(fMMain.cdsWords.FileName,
      fmOpenReadWrite or fmShareExclusive);
    fMMain.cdsWords.LoadFromStream(streamWords);
  except
    StreamWords.Free;
    ShowMessage('Cannot open Words.cds file - may be already being used.');
    result := false;
    exit;
  end;

Open in new window


If I use this code, it opens it OK, but it doesn't stop the same code re-opening the file.

  result := true;
  try
    StreamWords := TFileStream.create(fMMain.cdsWords.FileName,
      fmOpenRead or fmShareDenyWrite);
    fMMain.cdsWords.LoadFromStream(streamWords);
  except
    StreamWords.Free;
    ShowMessage('Cannot open Words.cds file - may be already being used.');
    result := false;
    exit;
  end;

Open in new window


It should be simple, but I seem to be making hard work of it.

Help please!
0
Hello Experts,

C++Builder XE5, Windows 7 64bit

When I run C++Builder Form Application on command prompt, it returns immediately without waiting its termination.
I want to show some messages with fprintf(stderr or stdout) in my form application, but I don't know how to setup my form application.

Any hints welcome,
Nobuo Miwa
0
Hello,
I need to format in 'hh:nn:ss' values bigger than 24h using Delphi.

FormatDateTime('hh:nn:ss', FloatToDateTime(2));

Open in new window


I'm expecting '48:00:00' but resulting value is '00:00:00' because days part isn't shown.
How can I get '48:00:00'?
Thanks for your willingness.
0
i'll trying to create tsqlconnection at runtime, but i get this error :
SQLConnectionProperty required for this operation.
what i am doing wrong?


procedure grid_select();
var
  fotabla_grid_conn_msh   : TSQLConnection;
  MSHQuery_fotabla_grid : TSQLQuery;

begin
create_connection( fotabla_grid_conn_msh, f_foablak );
MSHQuery_fotabla_grid:= TSQLQuery.Create(self);
MSHQuery_fotabla_grid.SQLConnection := fotabla_grid_conn_msh;
MSHQuery_fotabla_grid.Name := 'MSHQuery_fotabla_grid';
end;

procedure Tf_foablak.create_connection ( P_CONNECTION_NAME : TSQLConnection; P_FORM : TForm );
begin
    P_CONNECTION_NAME:= TSQLConnection.Create(P_FORM);
            P_CONNECTION_NAME.ConnectionName := P_CONNECTION_NAME.ConnectionName;
            P_CONNECTION_NAME.DriverName := 'MySQL';
    P_CONNECTION_NAME.Params.Clear;
            P_CONNECTION_NAME.LoginPrompt := False;
            P_CONNECTION_NAME.Params.Add('DriverName=MySQL');
            P_CONNECTION_NAME.Params.Add('HostName='+f_foablak.ComboBox1.Text);
            P_CONNECTION_NAME.Params.Add('Database=microshop');
            P_CONNECTION_NAME.Params.Add('User_Name=rt');
            P_CONNECTION_NAME.Params.Add('Password=MiC85HarV01');
            P_CONNECTION_NAME.Params.Add('BlobSize=-1');
            P_CONNECTION_NAME.Params.Add('ErrorResourceFile=');
            P_CONNECTION_NAME.Params.Add('LocaleCode=0000');
            P_CONNECTION_NAME.Params.Add('Compressed=False');
            P_CONNECTION_NAME.Params.Add('Encrypted=False');
            P_CONNECTION_NAME.Params.Add('Use Procedure Bodies=False');
            …
0
I need to use a dll developed in Delphi in my VB.NET application.  The Delphi developer has given me the function definition in Delphi:
function GenRegCode(
	RegStr : Widestring; 
	RegOptions, 
	SerialExpireDays,
        RegExpire, 
	RegExpireDays, 
	RegExpireMonths, 
	RegExpireYears : Integer;
        var Serial : Widestring) : LongBool; stdcall;

Open in new window

I'm attempting to call the entry point using the following VB definition:
    <DllImport("C:\Windows\SysWOW64\xxx.dll", EntryPoint:="GenRegCode", SetLastError:=True, _
        CharSet:=CharSet.Auto, ExactSpelling:=True, _
        CallingConvention:=CallingConvention.StdCall)> _
    Public Shared Function fGenRegCodeVB( _
        ByVal RegPassword As String, _
        ByVal RegOptions As Long, _
        ByVal SerialExpireDays As Long, _
        ByVal RegExpire As Long, _
        ByVal RegExpireDay As Long, _
        ByVal RegExpireMonth As Long, _
        ByVal RegExpireYear As Long, _
        ByRef Serial As String) As Boolean
    End Function

Open in new window

I'm getting an AccessViolationException error.  The string Serial is set to 1024 spaces -- much longer than the maximum string length that will be returned, which is 24.  Do I have the VB data types defined correctly?  Could this have something to do with a pointer to a string, versus the string itself?
0
Hi

After a LONG break from development I am trying my hand for a simple project. I used to write in pascal/delphi so switched to using Lazarus. I am very very rusty almost a beginner again.

My project is a single form with a grid, and potentially 3 drop down boxes which filter the grid. I have the DBGrid displaying the SQL Query I want, but I can't get the DBComboDropDown to populate with the SQL in the SQLQuery component, despite it returning good example results. I suspect the reason the dropdown isn't populating is that I can't set the SQLquery as "active". When I try it won't change to active but I get no error. When I compile the application I either get an error when I start or when I click the button to close the project, The error I get is :

"The RollBack Transaction request has no corresponding Begin Transaction"

A quick google suggested I could stop that by setting the SQLtransaction Component "action" property to caNone, but that didn't help.

I am fairly new back to this so simple explanations would definitely help thanks.
0
I want my Delphi DataSnap server to listen on a specific IP address.  (My internet server has 8 IP addresses.)

How do I assign or bind one IP address to the server in Delphi XE6?
0
HI,
Something that I thought would be simple thing...
I  execute a Thread.  OnThreadReady event make call to move focus, Edit2.SetFocus;
When the thread is finished, the original Active Control (Edit1) still have focus ...
Other things does work fine, but SetFocus.
What's  that causes trouble?
0
I'm trying to build a small delphi (XE5) application which use embedded Mysql. Everywork fine when the application is installed in a folder without a dot, but can't get it to work in a folder like "C:\MyApp 1.0".  

I'm using FireDac , MySLQDriverLink "MySQLEmbedded"  with embeddedArgs :
--basedir=./embedded/
--datadir=./embedded/data/
--innodb_data_home_dir=./embedded/data/
--skip-networking

I'm using MySQL 5.6, and tried it on different OS with the same result..

Am I missing something or should I report this a bug ?
0
rather than using the TOR default Firefox, i would like to use Delphi Tembedded web browser to resolve and display onion pages.
0
After a recent auto update to Delphi 2010, I got the following message on recompile: F1026 File not Found: 'UITypes.dcu'.
0
I've just created my first service.  I would think that when you ran the application the tservice would fire either serviceexecute or servicestart but neither happens.  I need something to catch my code so I can perform some work.  If I put a ttimer on the service form it will only fire if I set the timer down to a millisecond.  It appears that when you run a tservice it just runs briefly and then finishes, so you can't put a ttimer on it and there are no handlers that I can find that are firing when it's run.  What am I missing?  (See attached code)
PROBLEM-WITH-SERVICE.txt
0
I want to go through a FMX grid and first check if a cell has a check box and then if it does what is the state :-

var
  R,C:Integer;
begin
  for R :=1 to TMSFMXGrid1.RowCount do
     for C :=1 to TMSFMXGrid1.ColumnCount do
        if TMSFMXGrid1.IsCheckBox(C,R)=True then
           if TMSFMXGrid1.Cells[C,R] = TMSFMXGrid1.CheckTrue then
              ListBox2.Items.Add(TMSFMXGrid1.Cells[C,0]+TMSFMXGrid1.Cells[0,R]);


The ischeckbox works but the if TMSFMXGrid1.Cells[C,R] = TMSFMXGrid1.CheckTrue does not and I can not see what is wrong as I have taken straight from the manual ?

Thanks

Tim
0
I have an old program in delphi 5. The reports are made with qrdesign and although I can preview them and then manually save them as a pdf, I would like to have a code that directly creates a pdf file from the report without making the user have to type anything at all.
0
Hello,
Is it possible to open a query - get some data make some changes and select data with the same query with changes as filtration values.

for example:
i`ve got 4 cols:
numb int
code string
c1 int
c2 int

First:  i open query like: select numb,code,c1,c2 where numb is not null
second: make my stuff with c1 and c2 like add c1 to c2 as c3 in delphi
third: filtrate data like select * from mytab where c3>0

Above example is just for explanation.
0
Hi
I`ve got a query with 5 columns
I need to add additional field which is the summary of 2 columns. So as result i should receive 6 columns.
I want to add it to my dataset becouse i want to use it further as fast report dataset.
0

Pascal

Pascal is an influential imperative and procedural programming language, largely (but not exclusively) intended to teach students structured programming and data structuring. Pasca was implemented on a wide range of architectures, from early PCs to mainframes. Pascal derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal). Pascal is a purely procedural language and includes control statements with reserved words, but has many data structuring facilities and other abstractions like type definitions, records, pointers, enumerations, and sets.

Top Experts In
Pascal
<
Monthly
>

No Top Experts for this time period. Answer questions to earn the title!