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

Hi,

if I want to stock an hexadecimal value (for example: $00000040) into a variable, what kind of variable should I use?

like

begin
var
  containshexa: ????;

I have to stock it into the right data type because after, I will use it into a message box, such as
MessageBox(0, PChar('Title'), pchar('Message'), containshexa);

500 points for this one, thx a lot!
0
I have added an item to the windows context menu (right click on any file);
When clicked, my application opens so this is ok.

I need to know how to display the path and filename of the file that was right clicked on, so my application can deal with it.

Eg:      I have added 'Your File Path is '     to the right click context menu from my application,  This works fine.

           When I click on the context menu item 'Your File Path is'    it opens my application.  

           I want a procedure/ Function to do the following:

          ShowMessage (YourFilePath);

Please can someone show me how to get the filepath [eg:]  ('c:\test.txt')  from the file that was clicked in windows and return it to my program ?

Now here is the longer version :

When right clicking on any file in windows explorer the context menu has a choice that is ''Your File Path is'.   // I have achieved this.

When you click on it, my application is started //  I have achieved this

Here is where I need help !

I need to know how my application will know WHICH file was clicked on ?
It should return the full filepath including filename so my application can work with it.

The registry key I have added for context menu is......

C:\Documents and Settings\Spider\Desktop\program test\maxenc.exe "%1"

What does the "%1" mean and how can I modify this to open the file that was clicked ?

Thanks in advance.

Elvin

0
Ok, the reason for the low point count on this is that I am just looking for information(although working code would allow me to up the point count).

What I'm trying to do is code a server program that interacts with a bunch of clients(500+). That I am pretty sure I can do, what I can't do is the following:

*Get a list of all active connections on a certain port
*Get rid of(Disconnect) the ones that are not connected with the server as well.

You might understand if I provide an example(Actually what it's going to be used for):

A game server has 500 people on it, the client programs have a hack protection system and I want to make sure it's running. What happens is the active connections on the server(on the game port specifically) are compared with the server hack protection which maintains a list of clients that are running the hack protection. If they are not I want to close the winsock connection that they have made.

For now all I am asking is for information that I can figure out. If someone wants to point out that they have working code I will up the point value depending on how much work I have left to do.

Thanks in advance.
0
Hi,

I want to add XP manifest to a compiled exe,

I'm using this code:

-----------------------------------------------------------
function ReadFilePoke(FileName: string): widestring;
var
  F:      file;
  Buffer: widestring;
  Size:   integer;
  ReadBytes: integer;
  DefaultFileMode: byte;
begin
  Result := '';

  DefaultFileMode := FileMode;

  FileMode := 0;
  AssignFile(F, FileName);
  Reset(F, 1);

  if (IOResult = 0) then
  begin
    Size := FileSize(F);

    while (Size > 1024) do
    begin
      SetLength(Buffer, 1024);
      BlockRead(F, Buffer[1], 1024, ReadBytes);
      Result := Result + Buffer;
      Dec(Size, ReadBytes);
    end;

    SetLength(Buffer, Size);
    BlockRead(F, Buffer[1], Size);
    Result := Result + Buffer;

    CloseFile(F);
  end;

  FileMode := DefaultFileMode;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
buffer: widestring;
update : dword;
begin

  buffer := readfilepoke('C:\man.txt');
   update := BeginUpdateResource('C:\man.exe', false);
  if update <> 0 then
    try
      UpdateResource(update, MAKEINTRESOURCE(24), '1', 0, @buffer[1], length(buffer));
    finally
      EndUpdateResource(update, false);
    end;

end;
-----------------------------------------------------------

man.exe is the file without manifest,
man.txt is my file containing manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly …
0
Hi all,

My version of Delphi is in french, but I want to have error message in english,

if I use windows API, if a error message pop up, it will be shown in the language of the computer where it is executed, but when I use function of VCL, error message appear to be in french even if the local language of the computer where it is executed is english,

how to fix that? do I really have to get an english version of Delphi?

when I check resource of my compiled application, there is one named "String", inside this, there is many errors message, but they are in french, I attached a screenshot,


any idea?

500 points for this one, thx
[embed=doc 2008]
0
Hi all,

How to Remove/Strip Debug Info of an exe in Delphi?

NOTE that I know how to remove the debug info of my project, what I want to do is to be able to remove/strip debug info of any compiled exe.

500 points for this one,

thanx in advance
0
I want to find a fast way to read large(100mb+) text files and parse them into a ListBox(TStringList).
0
Hi Experts,

I think i have a bit of a tricky situation here.

I have a client that requires some General Ledger Tools written and they have some very specific criteria.

The criteria is:

    (1) All dates entered into the ledger as a journal entry must be done on the last friday of the month.
    (2) Months have to correspond to a time period of the fiscal year. Ie: Australia is July - June = 1 to 12.

Example:

User Inputs:

Date                  Journal ID         Debit        Credit        Detail             Period
28/12/2008           1111             10.00        0.00          AccPayable        6                  Correct Entry
31/12/2008           1112               9.95        0.00          AccRecieve         6                  Wrong Entry

Lets say for this example the 28/12/2008 was a friday the entry should post to the database. If not it should be trapped and the error rasied.

I guess what i am looking for is a routine that i can pass a date and a period and return if it is correct, or put in a date and it returns the period for that date.

I have looked at a few date routines and i pretty much couldnt find what i was looking for.

Also keep in mind that some periods in a month may have 5 weeks not 4.

Regards,





Trevor
0
Hi there,

We're porting one of our Delphi 7.0 Applications to FreePascal/Lazarus, but are getting heaps of compiler errors.  One of the most basic errors is that we use the Ptr() function quite a lot to recalculate memory addresses and this function is apparently not supported.  Does anyone know if it is supported, and if so, what unit is it in

Thanks

Zakiwi
[code]eg: 
        result := Ptr(DWORD(APointer) + ACount);
[/code]
0
Before adding strings to a stringlist, I checked if the Stringlsit is assigned with  thios code:

Var  LogStr           :  TStringList;
somewhere else:
     .....
      if not assigned (LogStr) then LogStr:=TStringList.Create;
      LogStr.Add('<h2>  Misalignment check </h2>');


or here .....

procedure TMainForm.DisplayStatusText(InfoText: String);
begin
     if Assigned (LogStr) then
              LogStr.Add('<br> ' + Infotext);

end;


Why does the assigned check don't give me a working check if I aleady did a  LogStr.Free ?
0
Does anyone have, or would care to write, a "natural order" string comparison function in Delphi?

"Natural order" is defined here at Martin Pool's site
http://sourcefrog.net/projects/natsort/   (yes, that is sourceFROG not sourceforge) and
there is a sort of Delphi port here http://irsoft.de/web/strnatcmp-and-natsort-for-delphi (but it relies on a C obj file, and some regexp stuff which I never can grasp)

It does not have to be hugely efficient for my purposes, so I would rather have it in pure Delphi, no asm.
Also, just ASCII, no locale dependencies as per the original.

Thanks

0
Hi all,

I'm using CreateProcess to open a file and exec it in memory, but this process then has no parent, how would I do to put explorer as process parent for this new opened process?

Maybe using createprocess directly from explorer.exe ? or changing it the process parent directly?

what's the best solution?

thx all,

500 points for this
0
Hi all,

I have 2 smalls questions,

1) I want to add XP manifest to an exe (not on my project, I mean on a third party executable), how to do it in Delphi? or if it's too complicated, how to just take it from another exe and apply it on another one?

2) Is there a "Vista Manifest", does it exist? or Vista manifest is still the same as XP manifest?


Thank you all in advance.

500 points for this one
0
Hi all,

How can I strip relocation from an exe? I don't want to use third party application of course, I want it in delphi code.

Thank you in advance.

500 points for this one
0
Please translate to pascal or just explain how len is build.

for (len = 0, shift = 0; /* void */ ; shift += 7)
{
    len_byte = VSTREAM_GETC(stream)
    len |= (len_byte & 0177) << shift;
    if ((len_byte & 0200) == 0)
         break;
}
0
 From the code below you may see that i can control only one output at once.
  What must i do to control contemporary two outputs.
It must be that when first output is increasing the second must decrees and the third must be constant.
And then next must make second increase, third decrees and the first must be constant.
and next step.
the third must increase the first decrees and second must be constant.

[code]{ functions }
 
 
procedure led1;
begin
 for x:=1 to 120 do {ramp up}
      mDelay(10);
      inc(SoftPWM1);
     endfor;
 
    for x:=1 to 120 do {ramp down}
     mDelay(10);
     dec(SoftPWM1);
    endfor;
end;
 
procedure led2;
begin
 for x:=1 to 120 do {ramp up}
      mDelay(10);
      inc(SoftPWM2);
     endfor;
 
    for x:=1 to 120 do {ramp down}
     mDelay(10);
     dec(SoftPWM2);
    endfor;
end;
 
procedure led3;
begin
 for x:=1 to 120 do {ramp up}
      mDelay(10);
      inc(SoftPWM3);
     endfor;
 
    for x:=1 to 120 do {ramp down}
     mDelay(10);
     dec(SoftPWM3);
    endfor;
end;
 
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
 
begin
  SoftPWM1:= 0;
  SoftPWM2:= 0;
  SoftPWM3:= 0;
  SoftPWMarr[5]:= 45;
 
  EnableInts;
 
 
   
loop
   led1;
    led2;
     led3;
endloop;
 
 
end AVR_SoftPWM.[/code]
0
Hi,

I need an InputBox in pure API (for size reason) for Delphi.

500 points for this one.

Thank you in advance.

Marc
0
Hi all,

ok I want to create an hidden window with API and get his title,

It's because I want to know if a program is opened in a third party program who add [#] to the beginning of any window lunched in this (http://sandboxie.com),

my program don't have a form (a window), so I need to create one hidden, and then verify the title of this new created window, I must use only API,

thx a lot in advance,

500 points for this one
0
I have lots of two dimensional arrays... I need a function to detect if array (given by parameter) contains 4 in a row. The array values are:

0 - empty field
1 - player one
2 - player two

I need a checker to be as fast as possible, because I need to run it on about 100,000,000,000 examples!

Thanks in advance.
0
Hello
I have a polygon in geographical coordinates. It may be complex.
I want to draw the extarnal shape at a given distance.
Therefore, I draw the parallels linked by arcs of circle. But I don't find solution for concave polygons.

Does somebody know an algorithm for that case ?
I have posted the subject on http://www.developpez.net/forums/showthread.php?t=466614

Thanks for any help
0
Hi all,

the program I'm coding is an Icon Changer,
I want to extract icons of an exe or a dll, and then apply it on another exe file,

I already know how to apply icons on a file, I'm using MadRes to do so (http://help.madshi.net/madResUnit.htm),

but my problem is when I want to take off icons of a file (to apply them on another one), I only get bad quality icons, so yea, I can extract icon, but it's a very bad quality,

so how extracting all icons from a file in his original quality?

also, if I want to apply them to another exe file after, all extracted icons must be in just one .ico I think (to use it with madRes)


thx a lot in advance.

0
Ok so first off let me say I'm using lazarus 9.24 (compiles using the free pascal compiler) So if I have it like the snippet below, it returns error 1400 - or, as microsoft says, "can't find handle"... I've tried interchanging theTitle and nil in the function winOpen and neither return anything but 0, so I use a lazarus (maybe pascal) built in variable called Handle(and put it instead of the winopen procedure when the button's pressed) which is supposed to return the applications handle. This does return a number, but I still get error 1400. And, best of all, if I give SetWindowPos a handle I know exists and run it the program crashes giving me an access violation.
[code]function winopen(theTitle:pchar):integer;
var poshand:integer;
begin
 poshand:=FindWindow(theTitle,nil);
 Result:=poshand;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  if(SetWindowPos(winopen('project1'),-1,0,0,0,0,1)<=0) then begin
    label2.caption:=inttostr(GetLastError());
  end;
end;
[/code]
0
I have to take controll over MS-DOS application (Ca-Clipper) , May be there is a way to create console window with API  AllocConsole, CreateProcess, StartupInfo, GetStdHandle,
ReadConsoleOutput, Input_Record, VkKeyScan, WriteConsoleInput,
CloseHandle, FreeConsole?
Thank you in advance.
0
I would like to change processor affinity for some one application,If I know process name (handle) how affinity can be changed ? How can i use function  SetProcessorAffinity in delphi environment?
Thank you in advance.
0
I want to read default value (REG_SZ) by using API (to get path of default web browser)

and also, btw, what you think is the best way to get the default browser path? some purpose to get it using the file extension classes (html), but I'm not sure if it's 100% reliable because sometime, an html editor can be assigned to the file extension .html, so :(, what you suggest?

(I don't want to use registry unit for size reason)

Thx a lot in advance
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!