hedgewars/uFLUtils.pas
author unc0rr
Sun, 25 Jan 2015 00:08:42 +0300
branchqmlfrontend
changeset 10751 97d00ace1aed
parent 10616 20a2d5e6930a
child 10757 f71275973737
permissions -rw-r--r--
CMake script for qmlFrontend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     1
unit uFLUtils;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     2
interface
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     3
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     4
function str2PChar(const s: shortstring): PChar;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     5
function intToStr(n: LongInt): shortstring;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10517
diff changeset
     6
function strToInt(s: shortstring): LongInt;
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
     7
function midStr(s: shortstring; pos: byte): shortstring;
10517
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
     8
procedure underScore2Space(var s: shortstring);
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     9
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    10
implementation
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    11
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    12
var
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    13
    str2PCharBuffer: array[0..255] of char;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    14
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    15
function str2PChar(const s: shortstring): PChar;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    16
var i: Integer;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    17
begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    18
   for i:= 1 to Length(s) do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    19
      begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    20
      str2PCharBuffer[i - 1] := s[i];
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    21
      end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    22
   str2PCharBuffer[Length(s)]:= #0;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    23
   str2PChar:= @(str2PCharBuffer[0]);
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    24
end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    25
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    26
function intToStr(n: LongInt): shortstring;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    27
begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    28
    str(n, intToStr)
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    29
end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    30
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10517
diff changeset
    31
function strToInt(s: shortstring): LongInt;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10517
diff changeset
    32
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10517
diff changeset
    33
val(s, strToInt);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10517
diff changeset
    34
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10517
diff changeset
    35
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    36
function midStr(s: shortstring; pos: byte): shortstring;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    37
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    38
    midStr:= copy(s, pos, length(s) - pos + 1)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    39
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    40
10517
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    41
procedure underScore2Space(var s: shortstring);
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    42
var i: LongInt;
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    43
begin
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    44
    for i:= length(s) downto 1 do
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    45
        if s[i] = '_' then s[i]:= ' '
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    46
end;
844bd43db47a getScriptsList implementation
unc0rr
parents: 10440
diff changeset
    47
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    48
end.