Server Help

General Questions - Caption problem - regarding .ini generating

Creatix - Mon May 10, 2004 3:55 pm
Post subject: Caption problem - regarding .ini generating
Hello
atm im programming a little cute Tool with Delphi to create Lvz's. This will make it possible for any1 to create a lvz without needing to know about it. Well i gotten pretty far with the programming but thers 1 problem left:

The top of a lvz starts with 'outfile=lvzname.lvz'. Due the lvz is an ini file, every category has a caption such as [ Objectimages ] and [ mapobjects ]. But Delphi forces me to define a category wich means it doesnt seem to be possible for me to create The 'outfile' and the 'file=' part because it does not have a category. When delphi generates a .ini file it gives me a Fatal Error when i leave the category part empty.

Does any1 have an idea how to solve the problem?
Greetz
Creatix

P.s. im sure thers a solution for the problem somehow.. just werent in the mood to think of it very long... any1 an idea?
Cyan~Fire - Mon May 10, 2004 4:40 pm
Post subject:
Ask Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole...., he made LIE in Delphi.
Anonymous - Mon May 10, 2004 5:01 pm
Post subject:
ask him? how?
Mine GO BOOM - Mon May 10, 2004 5:11 pm
Post subject:
Creatixy wrote:
ask him? how?

Check his user profile, contains his email address among other things.
Jackmn - Mon May 10, 2004 6:52 pm
Post subject:
You could just manually code the ini i/o routines. That would probably be easiest.
Anonymous - Tue May 11, 2004 6:25 am
Post subject:
yeah, lol. silly me
k0zy - Tue May 11, 2004 5:54 pm
Post subject:
To solve this problem I coded my own Ini parser in LIE.

Code: Show/Hide
//procedure that reads the ini into several arrays
procedure TMainFrm.Open(Datei:String);
var f: TextFile;
    section,Flag,i: integer;
    Line,Help: string;
begin
  MapCount := 0;
  ScreenCount := 0;
  ImageCount := 0;
  section := 0;
  AssignFile(f,Datei);
  Reset(f);
  while not EOF(f) do
  begin
    Flag := 0;
    ReadLn(f,Line);
    If (LowerCase(Copy(Line,1,7)) = 'outfile') then
    begin
      eOutFile.Text := Copy(Line,9,Length(Line)-8);
    end;
    If (LowerCase(Copy(Line,1,4)) = 'file') then
    begin
      FileList.Items.Add(Copy(Line,6,Length(Line)-5));
    end;
    If (LowerCase(Copy(Line,1,14)) = '[objectimages]') then
    begin
      section := 1;
      Flag := 1;
    end;
    If (LowerCase(Copy(Line,1,12)) = '[mapobjects]') then
    begin
      section := 2;
      Flag := 1;
    end;
    If (LowerCase(Copy(Line,1,15)) = '[screenobjects]') then
    begin
      section := 3;
      Flag := 1;
    end;
    If (Flag = 0) then
    begin
      if (section = 1) and (Copy(Line,1,1) <> ';') and (Length(Line) <> 0) then
      begin
        // ObjectImages
        ImageCount := ImageCount + 1;

        {Get ImageNumber}
        Help := '';
        For i := 1 to Length(Line) do
        begin
          Help := Help + Copy(Line,i,1);
          If Copy(Line,i,1) = '=' then
          begin
            Help := Copy(Help,1,Length(Help)-1);
            Help := Copy(Help,6,Length(Help)-5);
            SetLength(Images,ImageCount);
            SetLength(ImageT,ImageCount);
            SetLength(ImageY,ImageCount);
            SetLength(ImageX,ImageCount);
            SetLength(ImageFile,ImageCount);
            Images[ImageCount-1] := StrToInt(Help);
            ImageBox.Items.Add('IMAGE'+IntToStr(Images[ImageCount-1]));
          end;
        end;

        {Get File of the Image}
        Help := GetImageFile(Line);
        ImageFile[ImageCount-1] := Help;

        {Other attributes}
        ImageX[ImageCount-1] := GetOption(Line,1,True);
        ImageY[ImageCount-1] := GetOption(Line,2,True);
        ImageT[ImageCount-1] := GetOption(Line,3,True);

      end;
      if (section = 2) and (Copy(Line,1,1) <> ';') and (Length(Line) <> 0) then
      begin
        // MapObjects
        MapObjectList.Items.Add(Line);
        MapCount := MapCount + 1;

        SetLength(MapX,MapCount);
        SetLength(MapY,MapCount);
        SetLength(MapImage,MapCount);
        SetLength(MapLayer,MapCount);
        SetLength(MapMode,MapCount);
        SetLength(MapTime,MapCount);
        SetLength(MapID,MapCount);

        MapX[MapCount-1] := IntToStr(GetOption(Line,0,False));
        MapY[MapCount-1] := IntToStr(GetOption(Line,1,False));
        MapImage[MapCount-1] := GetOption(Line,2,False);
        MapLayer[MapCount-1] := GetOption(Line,3,False);
        MapMode[MapCount-1] := GetOption(Line,4,False);
        MapTime[MapCount-1] := GetOption(Line,5,False);
        MapID[MapCount-1] := GetOption(Line,6,False);
      end;
      if (section = 3) and (Copy(Line,1,1) <> ';') and (Length(Line) <> 0) then
      begin
        // ScreenObjects
        ScreenObjectList.Items.Add(Line);
        ScreenCount := ScreenCount + 1;

        SetLength(ScreenX,ScreenCount);
        SetLength(ScreenY,ScreenCount);
        SetLength(ScreenImage,ScreenCount);
        SetLength(ScreenLayer,ScreenCount);
        SetLength(ScreenMode,ScreenCount);
        SetLength(ScreenTime,ScreenCount);
        SetLength(ScreenID,ScreenCount);

        ScreenX[ScreenCount-1] := GetObjectXY(Line,0);
        ScreenY[ScreenCount-1] := GetObjectXY(Line,1);
        ScreenImage[ScreenCount-1] := GetOption(Line,2,False);
        ScreenLayer[ScreenCount-1] := GetOption(Line,3,False);
        ScreenMode[ScreenCount-1] := GetOption(Line,4,False);
        ScreenTime[ScreenCount-1] := GetOption(Line,5,False);
        ScreenID[ScreenCount-1] := GetOption(Line,6,False);
      end;
    end;
  end;
  CloseFile(f);
end;
GetOption and GetObjectXY are functions I coded myself, too.

The whole sourcecode is attached. Feel free to contact me if you have any questions!

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group