Sandstorm
2009-02-21 20:30:53
Simple script, my first large form. Forms aren't all that hard (one page forms anyways).
Easy to use. Just type in the name, click Get Id, and wait a second or two. It will then pop up the id in the second box. It takes about four to sive milliseconds seconds per ID for me (on average, after the update.).
*Note - The name must be the exact name, or it will return a false positive most of the time.
~Sandstorm
Easy to use. Just type in the name, click Get Id, and wait a second or two. It will then pop up the id in the second box. It takes about four to sive milliseconds seconds per ID for me (on average, after the update.).
*Note - The name must be the exact name, or it will return a false positive most of the time.
program New;
{.include srl/srl.scar}
var
EndItemForm : Boolean;
frmdesign : TForm;
Button1, Button2, Button3 : TButton;
Edit1 : TEdit;
Input, Output : TGroupBox;
Memo1, Memo2, Memo3, Memo4 : TMemo;
Items, Npcs : TObject;
Page : Integer;
itemsini, npcsini : String;
procedure ItemFormOnClose(Sender : TObject; var Action : TCloseAction);
begin
if (not(frmdesign.ModalResult = 1)) then
EndItemForm := True;
end;
Function Contain(Stringz, Strings : String) : Boolean;
Begin
Result := Pos(Stringz, Strings) <> 0;
End;
Function GetId(QueryIs : String) : String;
Var
H, Quereh : String;
C, T : Integer;
Begin
MarkTime(T);
Quereh := Lowercase(QueryIs);
H := Lowercase(itemsini);
If lowercase(Quereh) = 'cannonball' Then
Begin
Result := '2';
WriteLn('Took: ' + IntToStr(TimeFromMark(T)) + ' milliseconds');
Exit;
End;
If Not Contain(Quereh, H) Then
Begin
Result := 'Unknown Item Id';
WriteLn('Took: ' + IntToStr(TimeFromMark(T)) + ' milliseconds');
Exit;
End;
C := Pos(Quereh, H);
While not (StrGet(H, C) = Chr(10)) Do
Begin
Dec(C);
End;
Result := GetNumbers(Copy(H, C, Length(Quereh)));
WriteLn('Took: ' + IntToStr(TimeFromMark(T)) + ' milliseconds');
End;
Function GetNpcId(QueryIs : String) : String;
Var
S, Quereh : String;
C : Integer;
Begin
S := Lowercase(npcsini)
Quereh := Lowercase(QueryIs);
C := Pos(Lowercase(Quereh), S);
If Not Contain(Quereh, S) Then
Begin
Result := 'Unknown Npc Id';
Exit;
End;
While Not Contain('npc', Quereh) Do
Begin
Dec(C);
Quereh := StrGet(S, C - 1) + Quereh;
End;
Result := GetNumbers(Quereh);
End;
procedure StartButton(sender: Tobject);
begin
Case (Memo1.Visible and Memo2.Visible) Of
True: Begin
With Memo1.Lines Do
Add(Edit1.text);
With Memo2.Lines Do
Add(GetId(Edit1.text));
End;
False : Begin
With Memo3.Lines Do
Add(Edit1.text);
With Memo4.Lines Do
Add(GetNpcId(Edit1.text));
End;
End;
end;
procedure Changing(Sender: TObject);
begin
If Page = 1 Then
Begin
Memo2.Visible := False;
Memo1.Visible := False;
Memo3.Visible := True;
Memo4.Visible := True;
Edit1.Text := 'Npc Name';
End else
Begin
Memo3.Visible := False;
Memo4.Visible := False;
Memo2.Visible := True;
Memo1.Visible := True;
Edit1.Text := 'Item Name';
End;
end;
Procedure Changing1(Sender: TObject);
Begin
Dec(Page);
If Page <> (0 or 1) Then
Page := 0;
Changing(Items);
End;
Procedure Changing2(Sender: TObject);
Begin
Inc(Page);
If Page <> (0 or 1) Then
Page := 1;
Changing(Npcs);
End;
procedure ItemForm;
var
TimeItemForm : Integer;
begin
TimeItemForm := GetSystemTime;
frmdesign := CreateForm;
with frmdesign do
begin
OnClose := @ItemFormOnClose;
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize,biSystemMenu];
ClientWidth := 439;
ClientHeight := 359;
Caption := 'frmDesign';
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
PixelsPerInch := 96;
end;
Button1 := TButton.Create(frmdesign);
with Button1 do
begin
Parent := frmdesign;
Left := 176;
Top := 48;
Width := 75;
Height := 25;
Caption := 'Get Id!';
TabOrder := 0;
OnClick := @StartButton;
end;
Button2 := TButton.Create(frmdesign);
with Button2 do
begin
Parent := frmdesign;
Left := 90;
Top := 48;
Width := 75;
Height := 25;
Caption := 'Items';
TabOrder := 0;
OnClick := @Changing1;
end;
Button3 := TButton.Create(frmdesign);
with Button3 do
begin
Parent := frmdesign;
Left := 262;
Top := 48;
Width := 75;
Height := 25;
Caption := 'Npcs';
TabOrder := 0;
OnClick := @Changing2;
end;
Edit1 := TEdit.Create(frmdesign);
with Edit1 do
begin
Parent := frmdesign;
Left := 152;
Top := 24;
Width := 121;
Height := 21;
TabOrder := 1;
Text := 'Item Name';
end;
Input := TGroupBox.Create(frmdesign);
with Input do
begin
Parent := frmdesign;
Left := 8;
Top := 80;
Width := 201;
Height := 265;
Caption := 'Input';
TabOrder := 2;
end;
Memo1 := TMemo.Create(Input);
with Memo1 do
begin
Parent := Input;
Memo1.Visible := True;
Left := 8;
Top := 16;
Width := 185;
Height := 241;
ReadOnly := True;
ScrollBars := ssVertical;
TabOrder := 0;
end;
Output := TGroupBox.Create(frmdesign);
with Output do
begin
Parent := frmdesign;
Left := 224;
Top := 80;
Width := 201;
Height := 265;
Caption := 'Output';
TabOrder := 3;
end;
Memo2 := TMemo.Create(frmdesign);
with Memo2 do
begin
Parent := frmdesign;
Memo2.Visible := True;
Left := 232;
Top := 96;
Width := 185;
Height := 241;
ReadOnly := True;
ScrollBars := ssVertical;
TabOrder := 4;
end;
Memo3 := TMemo.Create(frmdesign);
with Memo3 do
begin
Parent := Input;
Memo3.Visible := False;
Left := 8;
Top := 16;
Width := 185;
Height := 241;
ReadOnly := True;
ScrollBars := ssVertical;
TabOrder := 0;
end;
Memo4 := TMemo.Create(frmdesign);
with Memo4 do
begin
Parent := frmdesign;
Memo4.visible := False;
Left := 232;
Top := 96;
Width := 185;
Height := 241;
ReadOnly := True;
ScrollBars := ssVertical;
TabOrder := 4;
end;
WriteLn('ItemForm compiled in ' + IntToStr(GetSystemTime - TimeItemForm) + ' milliseconds!');
end;
procedure SafeItemForm;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ItemForm', V);
end;
procedure ShowItemFormModal;
begin
frmdesign.ShowModal;
end;
procedure SafeShowItemFormModal;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowItemFormModal', V);
end;
procedure MainItemForm;
begin
try
SafeItemForm;
SafeShowItemFormModal;
finally
FreeForm(frmdesign);
except
WriteLn('An error seems to have occurred in: ItemForm');
end;
end;
begin
WriteLn('Retrieving Item IDs, please wait.');
Itemsini := GetPage('http://schumaker40.site90.com/Auth.scar');
WriteLn('Retreived Item IDs! Now grabbing NPC IDs, please wait.');
Npcsini := GetPage('http://schumaker40.site90.com/Npcs.scar');
WriteLn('Retrieved Item and NPC IDs, initializing script!');
MainItemForm;
end.
~Sandstorm