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

is this bad setting in delphi ide ? or some mistake of mine ? my exe application get too long to be able to right click on it and my processor gets to hiegh if  try to move it from folder to another or even right click to copy

this issue happend with each exe project i made with Delphi even empty projects . the Antimalware execute on windows 8 takes to long and high process to verify the exe that maded with delphi

other exe on disk never hang on what could be the issue ?
0
any way to create html5 client that can connect to tidtcpserver and exchange data between it  ?

i found this component http://websockets.esegece.com/

 but dont know how to mirage it to my server application

any sample code can be provided ?
0
i currently have this parse function to parse strings inside string list


procedure admlistparse(starting: string; var Username, Access: string);
var
  P, I: Integer;
begin
  I := 0;
  repeat
    P := Pos(Sep, starting);
    if P <> 0 then
    begin
      Inc(I);
      case I of
        1: Username := Copy(starting, 1, P - 1);
        2: Access := Copy(starting, 1, P - 1);
      end;
      Delete(starting, 1, P + Length(Sep) - 1);
    end;
  until (I = 2) or (P = 0) or (starting = '') end;

procedure Tform1.gettextfromms;
    var
      I: Integer;
      starting: string;
      Username, Access: String;
      SL: TStringList;
    begin
      if Assigned(Ms) then
      begin
        SL := TStringList.Create;
        try
          SL.LoadFromStream(Ms);
          for I := 0 to SL.Count - 1 do
          begin
            starting := SL.Strings[I];
            admlistparse(starting, Username,  Access);
              memo1.Lines.Add('Username : ' + SL.Strings[I]);
          end;
        finally
          SL.Free;
        end;
      end;

    end;

Open in new window


now get text from MS procedure should get text like this

Drama#$%^&1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s1:s#$%^&

Open in new window


So i use #$%^& as separator to get this string as tow lines or maybe more if there is other string inside it

but i had on e issue that name Drama comes with second empty string any idea why ?
1
i have this code to read some strings from php file

function GetNet(strURL: string): string;
const
  bufSiz = 512;
var
  aHI, aHURL: HINTERNET;
  buf: string;
  bytesRead: cardinal;
  aBool: boolean;
  url : string;
begin
  url := strURL;
  Result := '';
  strURL := '';
  try
    ahI := InternetOpen('cLIENT', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil,
      INTERNET_FLAG_MAKE_PERSISTENT);
    if (aHI = nil) then exit;
    aHURL := InternetOpenURL(aHI, PChar(url), nil, 0,
      INTERNET_FLAG_EXISTING_CONNECT or
      INTERNET_FLAG_MAKE_PERSISTENT, 0);
    if (aHURL = nil) then exit;
    strURL := '';
    repeat
      buf := '';
      SetLength(buf, bufSiz);
      aBool := InternetReadFile(aHURL, PChar(buf), bufSiz, bytesRead);
      SetLength(buf, bytesRead);
      if (aBool and (bytesRead <> 0)) then
        strURL := strURL + buf;
    until (aBool and (bytesRead = 0)) or (not aBool);
    Result := strURL;
    Showmessage(strURL);
    InternetCloseHandle(aHURL);
    InternetCloseHandle(aHI);
  finally
    buf := '';
  end;
end;

Open in new window


sadly data comes out Chinese charters and what i have there is not Chinese charter any idea why ?

it shows result like this

[Window Title]
Project1

[Content]
⸰楧੦〰朮晩《〰朮晩《〰⸰楧੦〰〰⸰楧੦〰〰〰朮晩《〰⸱楧੦〰⸱楧੦〰〱朮晩《㈰⸳楧੦〰㐲朮晩《㈰⸵楧੦〰㘲朮晩《㜰朮晩《ㄱ朮晩《㈱朮晩《㌱朮晩《㐱朮晩《㌲朮晩《㐲朮晩《㔲朮晩《㔲⹃楧੦㈰䐵⹣楧੦㈰⸶楧੦㈰䌶⹖楧੦㈰夶婚⹚楧੦㈰娶⹚楧੦㈰愶朮晩《㘲祹朮晩《⸳楧੦㐰朮晩《⸵楧੦㘰朮晩《⸷楧੦㤰朮晩ㄊ㔰㔵砵㌳㌳㘶㘶㘶㘶硸⹸楧੦〱㔵㔵㝸摤㑤㐵⸵楧੦㈱㐳㌵空空硸硸硸硸朮晩ㄊ㐲㘵稳空空空空硺⹸楧੦㌱朮晩㈊⸰楧੦ㄲ朮晩㈊⸲楧੦㌲朮晩㈊㌳䜲䙈呄朮晩㈊⸴楧੦㔲朮晩㌊朮晩㌊㌳㌳稳空空㘷⹢楧੦㐳㈳稱空空空空⹺楧੦⸴楧੦⸵楧੦㔵

[OK]

Open in new window

0
i want to search for nodes using Tedit , so when i type in tedit i show only matched node in the VTS i try like so

procedure Tform1.SearchForText(Sender: TBaseVirtualTree; Node: PVirtualNode; Data: Pointer; var Abort: Boolean);
var
  NodeData: PuserData; //replace by your record structure
begin
  NodeData := Sender.GetNodeData(Node);
  Abort := AnsiStartsStr(string(data), NodeData.FObject.username); //abort the search if a node with the text is found.
then i dont know what to do 
end;

procedure Tform1.txtFilterChange(Sender: TObject);
var
  foundNode : PVirtualNode;
begin

foundNode := VDT.IterateSubtree(nil, SearchForText, pointer(txtFilter.text));

  if Assigned (foundNode) then
  begin
//dont know what to do here
  end;

end;

Open in new window


I couldn't search for node or even this code do any thing
1
when i try to execute color with this code  inside my dll application after execution the form disappear any idea why ?

var
  oldHandle : THandle;
  clr : TColorDialog;
begin
  clr := TColorDialog.Create(Self);
  try
    oldHandle := Application.Handle;
    Application.Handle := Self.Handle;
    try
      if clr.Execute then
        pnlColor.Color := clr.Color;
    finally
      Application.Handle := oldHandle;
    end;
  finally
    FreeAndNil(clr);
  end;
end;

Open in new window

0
i have this function in activex application to grab ie url
function Get_URL(Servicio: string): String;
var
  Cliente_DDE: TDDEClientConv;
  S: AnsiString;
begin
  Result := '';
  Cliente_DDE := TDDEClientConv.Create(nil);
  with Cliente_DDE do
  begin
    SetLink(Servicio, 'WWW_GetWindowInfo');
    S := RequestData('0xFFFFFFFF');
    Result := string(System.AnsiStrings.StrPas(PAnsiChar(S)));
    CloseLink;
  end;
  Cliente_DDE.Free;
end;


procedure Tform1.siteurl;
var
URI: TIdURI;
LinK : String;
Temp: string;
Host,sExt: String;
Path : string;
begin
Link := Get_URL('IExplore');
Temp := Copy(Link, 1, Pos(',', Link) - 1);
Temp := StringReplace(Temp, '"', '', [rfReplaceAll]);

URI := TIdURI.Create(Temp);
try
Host := URI.Host;
Path := URI.Path;
Host := StringReplace(Host ,'www.', '',[rfReplaceAll,rfIgnoreCase]);
sExt  := ExtractFileExt(Host);
Host := Copy(Host, 1, Length(Host) - Length(sExt));
finally
  URI.Free;
end;

memo1.Lines.Add(HOST)
end;

Open in new window


this code works in exe but not working in activex , any idea why ?
0
i have this url www.google.com i want only get google from it no www. or .com

i do

Host := 'www.google.com';
Host := StringReplace(Host ,'www.', '',[rfReplaceAll,rfIgnoreCase]);
Host := StringReplace(Host ,'.com', '',[rfReplaceAll,rfIgnoreCase]);

Open in new window


could i do it better ? because what if google is .de or other
1
Simple SQL Query usuing ADO in Delphi connected to Access Database:

procedure TForm1.Button1Click(Sender: TObject);
begin
With AdoQuery1 do begin
  Open;
  SQL.Clear;
  SQL.Add('SELECT * FROM Table1');
  SQL.Add('WHERE Number='+SpinEdit1.value);
  ExecSql;
end;
end;

Keeps throwing up the error: E2010 Incompatible types: 'string' and 'Integer'

Used to work fine in earlier version of Windows but every time an integer or double is used I get the same error. Thought it might have something to do with Access, but I ran the query just on Access and it worked fine. Have tried with both OLEDB 4.0 and 12.0 connections,
0
i have dll that loaded as library in acivex application i want to give it  premession off administrator  to copy files and so on

here what i did

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.1.1.1"
   processorArchitecture="X86"
   name="apploadform.exe"
   type="win32"/>
  <description>elevate execution level</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  <security>
   <requestedPrivileges>
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
   </requestedPrivileges>
  </security>
  </trustInfo>
</assembly>

Open in new window


and i called the rc file like this

{$R apploadform.res' apploadform.rc'}


but iam still unable to use dll as requestedExecutionLevel any idea why

this is my dll looks like

{$R apploadform.res' apploadform.rc'}
var
  mHandle: THandle;    // Mutexhandle
  DLLHandle: Longint = 0; { this var will hold the DLL's Handle }
  ApplicationClosed: Boolean = False;
  pOldApp: TApplication = nil; //**

function createApplication(Width: Integer; Height: Integer; hw:HWnd; app: TApplication): boolean; stdcall;  //**
begin


    mHandle := CreateMutex(nil, True, 'Appnameda-Inst');
    if GetLastError = ERROR_ALREADY_EXISTS then
    begin
      ShowMessage('app already opened');
      Halt;
    end;

    Application := app; //**
    ApplicationClosed := False; //**
  try
    

Open in new window

0
i am trying to compy files from location with dll here is my code

CopyFile(PChar(AppFolder +'\needed.dll'),Pchar(anotherfolder+'\needed.dll'), False);
memo1.Lines.Add(SysErrorMessage(GetLastError()))

Open in new window


i got The operation completed successfully , but sadly no files has been copied why this working in exe  application and not working in dll application ?

i try to copy file to CSIDL_COMMON_APPDATA path which is  ProgramData folder
0
when i try to load my activex application from website it gives me

---------------------------
Iexplore
---------------------------
System Error.  Code: 5.

Access is denied.
---------------------------
OK  
---------------------------

but if i run my application locally not from website its wrok normal may i know why ?
0
i have this activex form

type
  Tmainform = class(TForm, Imainform)
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }

  protected
    
    { Protected declarations }

  public
    { Public declarations }

       procedure callme;
  end;

Open in new window


i want to call this call me procedure from another form inside the application for example

form2 call mainform.callme; i tried to set global variable like mainform: Tmainform; and then call the procedure from another form sadly procedure did not called .
0
when even i pack my dll file with upx  the resource inside the dll got corrupted any idea why ?
0
i have client application i want to see how can i write it best way as thread safe , please if you found the code is miss help me to write it better !

here we go here is my client thread

type
  TClientThread = class(TThread)
  private
   FTCP: TIdTCPClient;
    procedure ProcessCommands(Command: string);
    procedure SendCommand(Command: string);
    procedure SendStream(Ms: TMemoryStream);
    procedure SendCommandAndStream(Command: String; Ms: TMemoryStream);
    procedure SendBuffer(Buffer: TIdBytes; BufferSize: Cardinal);
   //
  protected
  procedure Execute; override;

  Public
   constructor Create(CreateSuspended: Boolean; TCPClient: TIdTCPClient);
   destructor Destroy;
   procedure SendCommandWithParams(Command, Params: String);

  end;

Open in new window



Thread Create \ Destroy


constructor TClientThread.Create(CreateSuspended: Boolean;
  TCPClient: TIdTCPClient);
begin
inherited Create(CreateSuspended);
FreeOnTerminate := True;
FTCP := TCPClient.Create(nil);
FTCP.Host := TCPClient.Host;
FTCP.Port := TCPClient.Port;
FTCp.ConnectTimeout := TCPClient.ConnectTimeout;
FTCP.IPVersion := TCPClient.IPVersion;
FTCP.ReadTimeout := TCPClient.ReadTimeout;
FTCP.ReuseSocket := TCPClient.ReuseSocket;
FTCP.UseNagle := TCPClient.UseNagle;
end;

destructor TClientThread.Destroy;
begin
FTCP.Disconnect;
FTCP.Free;

end;

Open in new window



here is my client execute

procedure TClientThread.Execute;
var
Command : string;
begin
SendCommandWithParams('ENT', name + sep);
  while not Terminated do
    begin
        Command := FTCP.Socket.ReadLn;
      if Command <> '' then
      ProcessCommands(Command);
end;
end;

Open in new window



process command


Open in new window

0
i have tstring list that iam trying to custom sort data inside it here is my code

 function SortChannelConnections(List: TStringList; Index1, Index2: Integer): Integer;
var
  Conn1, Conn2: TConnection;
begin
  Conn1 := TConnection(List.Objects[Index1]);
  Conn2 := TConnection(List.Objects[Index2]);
if (conn1.booname = True) and (conn2.booname= False) then
      Result := 1
    else if (conn1.booname= False) and (conn2.booname= False) then
      Result := -1
    else
      Result := CompareStr(conn1.Name, conn2.Name);
end;





procedure Tconnection.SendClientsList;
var
  I: Integer;
  SL: TStringList;
  MS: TMemoryStream;
  Connection : TConnection;
  List: TList; // or TIdContextList if using a modern Indy version
begin
  MS := TMemoryStream.Create;
  try
    List := Server.Contexts.LockList;
    try
      SL := TStringList.Create;
      try
        for I := 0 to List.Count - 1 do
        begin
          Connection := TConnection(List.Items[I]);
           SL.AddObject(Connection.Name + Sep, connection);
        end;
        if (SL.Count > 0) then
        begin
          SL.CustomSort(SortChannelConnections);
          SL.SaveToStream(MS);
          MS.Position := 0;
        end;
      finally
        SL.Free;
      end;
    finally
      Server.Contexts.UnlockList;
    end;
    SendCommandAndStream('GETLIST', MS);
  finally
    MS.Free;
  end;
end;

Open in new window


and here is my tconnection
TConnection = class(TIdServerContext)
  private
  public
    Name: String;
    booname: Boolean;

Open in new window


when i try to do SL.CustomSort(SortChannelConnections); i got this
raised exception class EStringListError with message 'List index out of bounds (2)'.

what iam doing wrong exactly ?
0
i see an applications using Tvirtualstringtree to draw animated progressbar but i dont know how to do the same in coding here is an example image of what iam trying to achieve

http://www.mediafire.com/convkey/016a/zeezjy9mksh44qrzg.jpg?size_id=2

the approach needed is when node  on  Tvirtualstringtree has record with show progress set to True the progress bar showing beside the node name
0
Have been getting trained from DavidI's 'Mobile Summer School' 6 lessons.
I registered and got email with links but this one is not available.

Mobile Summer School - Lesson 4 Object Pascal - Building Multi-tier Apps with Datasnap REST_JSON

Mobile Summer School 2014/Projects/DatasnapREST/OP/DataSnapOpProjectGroup.groupproj
0
i have activex application that runs on webpage how do i get website address that run the activex application inside it ?
0
i have dll dynamic library application it has a form inside it . i am trying to load that dll inside  and ActiveX application that runs in IE, problem is i cannot show parent form inside it . here is my  complete code

Activex code

unit loader;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ActiveX, AxCtrls, activapp_TLB, StdVcl, Vcl.ExtCtrls, ShlObj, Vcl.StdCtrls;

type
  Tactivappform = class(TForm, Iactivappform)
    mpanl: TPanel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }

  protected
       { Protected declarations }

  public
    { Public declarations }
  end;

  type
  TcreaFunc = function (Width: Integer; Height: Integer; hw:HWnd): boolean; stdcall;
  TDisFunc = procedure stdcall;
  TSetProp = procedure (Param: string; Values: string); stdcall;


implementation

uses ComObj, ComServ;

{$R *.DFM}

{ Tactivappform }



procedure Tactivappform.Button1Click(Sender: TObject);
var
  dllHandle : THandle;
  creaFunc : TcreaFunc;
  DisFunc : TDisFunc;
  SetProp : TSetProp;
  S: widestring;
  PW: PWideChar;
begin
  S := 'load.dll';
  pw:=pwidechar(widestring(s));
  dllHandle := LoadLibrary(pw);
  if dllHandle <> 0 then
  begin
    @creaFunc := GetProcAddress(dllHandle, 'createApplication');
    @DisFunc := GetProcAddress(dllHandle, 'displayClient');
    @SetProp := GetProcAddress(dllHandle, 'SetProperties');
    if Assigned 

Open in new window

0
i have this exe application that load dll

unit loader;

interface

uses
  Winapi.Windows,  Winapi.ShlObj, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
appdllname = 'load.dll';

var
  Form1: TForm1;


function createApplication(Width: Integer; Height: Integer; hw:HWnd): boolean; stdcall; external appdllname;

implementation




{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

createApplication(Panel1.Width, Panel1.Height, Panel1.Handle);
end;




end.

Open in new window


this load and call function inside dll that store in application folder . but what about if i want to make specif external folder ?  i mean if dll stored in specific path how do i set the external to the specific path i am using delphi xe7
0
i have this thread that running the  client of indy

  type
  TClientThread = class(TThread)
  private
   //
  protected
    procedure Execute; override;
  end;


// thats how i create the client 

procedure TChatFo.TCPClientConnected(Sender: TObject);
begin
ClientThread := TClientThread.Create(False);
end;


procedure TChatFo.TCPClientDisconnected(Sender: TObject);
begin
if ClientThread <> nil then
  begin
    ClientThread.Terminate;
    ClientThread.WaitFor;
    FreeAndNil(ClientThread);
  end;
end;


// thats how i execute 

procedure TClientThread.Execute;
var
Command : string;
begin
form1.SendCommandWithParams(form1.TcpClient, 'LOGIN', 'name' + sep);
  while not Terminated do
    begin
        Command := form1.TCPClient.Socket.ReadLn;
      if Command <> '' then
          form1.ProcessCommands(Command);
end;
end;


//and here how i receive command parsing 


procedure Tform1.ProcessCommands(Command: string);
var
  Params: array [1 .. 10] of String;
  ParamsCount, P: Integer;
  ReceiveParams, ReceiveStream: Boolean;
  AudioData: Pointer;
  AudioDataSize: Cardinal;
  S : string;
begin
  ReceiveParams := False;
  ReceiveStream := False;

  if Command[1] = '1'  then //command with params
  begin
    Command := Copy(Command, 2, MaxInt);
    ReceiveParams := True;
  end
  else if Command[1] = '2' then //command + memorystream
  begin
    Command := Copy(Command, 2, MaxInt);
    ReceiveStream := True;
  end
  else if Command[1] = '3' then //command with params + 

Open in new window

0
In my application I should run invalidate within timer for as long as my application running because I draw some animated gifs inside nodes but after hour or so invalidate caused crash to my application is this a bug ?
0
How do I create a RTD Client using Delphi Pascal? My app needs to RTD connect with another app running in the same PC to obtain real-time stock market data. I have thoroughly researched this but have yet to find the information I need. Note that this is the first time for me to use RTD and the first time to use a Delphi interface. I used Component/Install Component to create a type library. I know that implementation of each member is up to me, but what do I put in these? What do I put in my ServerStart function? In ConnectData? And so on...
0
i wanted to update my activex application i have activex form that catch params from webpage and then load the forms i want to separate my ocx that catches params and make it like preloader to main application .dll and make that ocx with params check for updates to update the main application dll that stored in my computer any idea how to do that in coding ?
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!