Despite of life and economic problems I had last years I decided to come back to the programming world, tried to ask for a job and market prefers all kind of languages derived from C++ so I decided to learn more than I had in my head. But let’s be honest, nothing as powerful and easier to learn than Pascal… So keeping on the dilemma.
After translating the fpweb Tutorial from Leledumbo into Spanish, I tried to follow the instructions point by point, and had some issues I’d like to share with you.
First, I clicked on
Project / New Project / and selected HTTP Server Application, then selected all options on the dialog box, Register Location to serve files from, Location
(let’s change this caption to another more “new user” specific friendly like “Location on URL”), Directory
(Must change to “Physical location of your files, leave empty if you plan to serve your files on the same place the web server application is”), Port
(nothing to change), and the thread for server request, after this dialog, I tried to run it, went to a browser and nothing happens… Turns that it doesn’t run because the cthreads unit is not put on the .lpr file.
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Next issue is the first
procedure RegisterFileLocation, digging the code, it’s not working according the logic of instructions there. Lines 65 and 71 are put wrong, must check if the aDirectory variable is empty and then check if that directory exists. So lines 65 and 71 ought to work together, at the end, the procedure is more to work like:
Procedure RegisterFileLocation(Const ALocation, ADirectory: String);
begin
if ALocation = '' then
Raise HTTPError.Create(SErrNoLocation);
if Pos('/',ALocation)<>0 then
Raise HTTPError.Create(SErrInvalidLocation);
if Locations = Nil then
Locations:=TStringList.Create;
if ADirectory = '' then
Locations.Values[IncludeHTTPPathDelimiter(ALocation)] := ExtractFilePath(ParamStr(0))
else
if DirectoryExists(ADirectory) then
Locations.Values[IncludeHTTPPathDelimiter(ALocation)] := IncludeTrailingPathDelimiter(ADirectory)
else
Raise HTTPError.Create(SErrInvalidDirectory);
if DefaultFileModuleClass = Nil then
DefaultFileModuleClass := TFPCustomFileModule;
RegisterHTTPModule(ALocation, DefaultFileModuleClass, true);
end;
Then comes the 232 error… turns that omitting {$IFDEF UseCThreads} above, it runs well.
There’s a lot more… but this is a good start.
