Ver Mensaje Individual
  #4  
Antiguo 04-04-2006
lpkwebagent007 lpkwebagent007 is offline
Registrado
 
Registrado: abr 2006
Posts: 7
Reputación: 0
lpkwebagent007 Va por buen camino
Ping!
he encontrado el código,...pero no me funciona (ya mas o menos voy teniendo idea)
Código Delphi [-]
// Example: fill out 3 fields on a webpage. 
// If a field is found, continue to the next field; 
// else show an error message.
procedure TForm1.Button1Click(Sender: TObject);
begin
  if not FillForm(WebBrowser1, 'login', 'jaimito') then
    ShowMessage('Error: field LOGIN not found on page')
  else begin
    if not FillForm(WebBrowser1, 'password', 'soytupassword') then
      ShowMessage('Error: field PASSWORD not found on page')
    else begin
      if not FillForm(WebBrowser1, 'paja', 'activated') then
        ShowMessage('Error: field PAJA not done!');
    end;
  end; 
end; 

//Esto no entiendo
// Fill out the first field with the name "FieldName" with a value. 
// We assume that all the fields of the form(s) have different names.
function TForm1.FillForm(WB: TWebBrowser; FieldName, Value: string): Boolean;  
var  
  FormNr, ItemNr: integer;  
  TheForm: Variant;  
begin  
  Result := False;  
  // Check if there is at least one form in the document  
  if WB.OleObject.Document.All.Tags('FORM').Length = 0 then begin  
    ShowMessage('Error: no FORM found on page');
    Exit;  
  end;  
  // Process all forms of the document  
  for FormNr := 0 to WB.OleObject.Document.Forms.Length - 1 do begin  
    TheForm := WB.OleObject.Document.Forms.Item(FormNr); 
    // Process all forms of the document, stop if found  
    for ItemNr := 0 to WB.OleObject.Document.Forms.Item.length - 1 do
      try  
        // If the fieldname is found, try to fill out and stop  
        if TheForm.Item(ItemNr).Name = FieldName then begin  
          TheForm.Item(ItemNr).Value := Value;  
          Result := True;
        end;  
      except  
        Break;  
      end;
      if Result then Break; 
    end;
    // Remove next line if there are several forms in the document with the
    // same fieldnames an which should be set to the same value
    if Result then Break;
  end;  
end;

y sin embargo, compilando me salen chorrocientos de errores

[Error] Unit1.pas(28): E2003 Undeclared identifier: 'FillForm'
[Error] Unit1.pas(33): E2003 Undeclared identifier: 'Result'
[Error] Unit1.pas(35): E2003 Undeclared identifier: 'WB'
[Error] Unit1.pas(40): E2029 'DO' expected but identifier 'OleObject' found
[Error] Unit1.pas(41): E2066 Missing operator or semicolon
[Error] Unit1.pas(41): E2066 Missing operator or semicolon
[Error] Unit1.pas(43): E2029 'DO' expected but identifier 'OleObject' found
[Error] Unit1.pas(46): E2003 Undeclared identifier: 'FieldName'
[Error] Unit1.pas(47): E2003 Undeclared identifier: 'Value'
[Error] Unit1.pas(57): E2097 BREAK or CONTINUE outside of loop
[Error] Unit1.pas(59): E2029 '.' expected but ';' found
[Error] Unit1.pas(66): E2003 Undeclared identifier: 'FillForm'
[Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'

(no....no tengo ni p*ta idea de Delphi, estoy en pañales )

Última edición por lpkwebagent007 fecha: 04-04-2006 a las 02:15:04.
Responder Con Cita