Syntactical compiler error

Syntactical compiler error

Postby Rick Lipkin » Wed Jul 27, 2011 6:05 pm

To All

I have been working on a Web Crawler app and I am creating a code block to run a method that passes parameters and envokes IE ..

I have a web site I am trying to load that has a hyphen in the DOM string ..

document:forms:tsf:lst-ib

The code block compiles but errors out ..

cSFD := "document:forms:tsf:lst-ib"
bSFD := &( [ { | IE | IE:]+cSFD+[:Value := "]+cPARTS+[" } ] )

When I try it the hard coded way ..

IE:document:forms:tsf:lst-ib:Value := cPARTS

The compiler errors on the hyphen between lst and ib .. and I feel here is the crux of the code block error..

Anyone know how to compile this method string ?

IE:document:forms:tsf:lst-ib:Value := cPARTS


Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby nageswaragunupudi » Thu Jul 28, 2011 3:01 am

Mr Rick
I had seen your earlier postings on this subject and the trouble you went through making the above codeblock.

I would prefer a different approach, which would even make your program more readable.

Here is a function I suggest. I have not tested, but please let me know the result. Keep this function available to all your modules.

Code: Select all  Expand view
function OSendMulti( cStr, uVal )

   local aMsg  := HB_ATokens( cStr, ":" )
   local o     := aMsg[ 1 ]
   local n     := Len( aMsg ) - If( uVal == nil, 1, 2 )
   
   AEval( aMsg, { |c| o := OSend( o, c ) }, 2, n )
   if uVal != nil
      OSend( o, ATail( aMsg ), uVal )
   endif
   
return o


You can use this function like this:
Code: Select all  Expand view
OSendMulti( "IE:document:forms:tsf:lst-ib:Value", cPARTS )

You can even use macros inside the first parameter as you like.
Second parameter is optional. If specified, second parameter is assigned. If not assigned the function returns the value of the first parameter.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby Rick Lipkin » Thu Jul 28, 2011 12:50 pm

Rao

I like your option much better .. the code did error out.

Appreciate your help ..

Thanks
Rick

Application
===========
Path and name: C:\Fox\WebCrawl\WebCrawl.Exe (32 bits)
Size: 3,095,040 bytes
Time from start: 0 hours 0 mins 18 secs
Error occurred at: 07/28/2011, 08:40:04
Error description: Error BASE/3000 Argument error: __OBJSENDMSG
Args:
[ 1] = C IE
[ 2] = C document

Stack Calls
===========
Called from: => __OBJSENDMSG(0)
Called from: => HB_EXECFROMARRAY(0)
Called from: .\source\function\HARBOUR.PRG => OSEND(221)
Called from: FUNC_LIB.PRG => (b)OSENDMULTI(336)
Called from: => AEVAL(0)
Called from: FUNC_LIB.PRG => OSENDMULTI(336)
Called from: Vendor1.prg => _VENDOR1(440)
Called from: URLTEST.PRG => (b)_URLTEST(131)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(445)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(631)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1295)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
Called from: main.prg => MAIN(270)

Image
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby nageswaragunupudi » Thu Jul 28, 2011 1:58 pm

Mr Rick

I am extremely sorry. My mistake.
Please try this function:
Code: Select all  Expand view
function OSendMulti( o, cMsg, uVal )

   local aMsg  := HB_ATokens( cMsg, ":" )
   local n     := Len( aMsg ) - If( uVal == nil, 0, 1 )
   
   AEval( aMsg, { |c| o := OSend( o, c ) }, 1, n )
   if uVal != nil
      OSend( o, ATail( aMsg ), uVal )
   endif
   
return o
 

Usage:
Code: Select all  Expand view
OSendMulti( IE, "document:forms:tsf:lst-ib:Value", cPARTS )

First parameter the main Object.
Second parameter all messages delimited with ":"
Third parameter optional value to be assigned.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby Rick Lipkin » Thu Jul 28, 2011 2:09 pm

Rao

AWESOME !!!! .. works GREAT !!!!

Appreciate your expertise !
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby Rick Lipkin » Thu Jul 28, 2011 3:01 pm

Rao

Ran into another problem .. it seems when there is a function parameter within the DOM string :item(0) I get an error ..

Thanks
Rick Lipkin

Code: Select all  Expand view

cSFD := "document:forms:item(0):search"
OSendMulti( IE, cSFD+":Value", cPARTS )   // in func_lib.prg
 


Application
===========
Path and name: C:\Fox\WebCrawl\WebCrawl.Exe (32 bits)
Size: 3,095,040 bytes
Time from start: 0 hours 0 mins 18 secs
Error occurred at: 07/28/2011, 10:52:15
Error description: Error InternetExplorer.Application:DOCUMENT:FORMS/0 S_OK: ITEM(0)
Args:

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:ITEM(0)(0)
Called from: => __OBJSENDMSG(0)
Called from: => HB_EXECFROMARRAY(0)
Called from: .\source\function\HARBOUR.PRG => OSEND(221)
Called from: FUNC_LIB.PRG => (b)OSENDMULTI(334)
Called from: => AEVAL(0)
Called from: FUNC_LIB.PRG => OSENDMULTI(334)
Called from: Vendor1.prg => _VENDOR1(447)
Called from: URLTEST.PRG => (b)_URLTEST(131)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(445)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(631)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1295)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
Called from: main.prg => MAIN(270)

Image
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby nageswaragunupudi » Fri Jul 29, 2011 12:35 am

Rao

Ran into another problem .. it seems when there is a function parameter within the DOM string :item(0) I get an error

Yes. (x) and [x] as part of the string does not work now.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby nageswaragunupudi » Fri Jul 29, 2011 1:53 am

Please try this revised function as it is:
Code: Select all  Expand view
function OSendMulti

   local n

   PARAMETERS o, cMsg, uVal

   if PCount() > 2
      if ( n := RAt( ":", cMsg ) ) > 0
         o     := &( "o:" + Left( cMsg, n - 1 ) )
         cMsg  := SubStr( cMsg, n + 1 )
      endif
      o  := OSend( o, cMsg, uVal )
   else
      o  := &( "o:" + cMsg )
   endif

return o
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby Rick Lipkin » Fri Jul 29, 2011 2:33 pm

Rao

YES .. the functions and parameters are now working .. however the dom string that contains a "-" hyphen again is broke


Code: Select all  Expand view

cSFD := "document:forms:tsf:lst-ib"
OSendMulti( IE, cSFD+":Value", cPARTS )   // in func_lib.prg
 


Application
===========
Path and name: C:\Fox\WebCrawl\WebCrawl.Exe (32 bits)
Size: 3,095,040 bytes
Time from start: 0 hours 0 mins 23 secs
Error occurred at: 07/29/2011, 09:30:47
Error description: Error InternetExplorer.Application:DOCUMENT:FORMS:TSF/0 S_OK: LST
Args:

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:LST(0)
Called from: FUNC_LIB.PRG => OSENDMULTI(337)
Called from: Vendor1.prg => _VENDOR1(451)
Called from: URLTEST.PRG => (b)_URLTEST(131)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(445)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(631)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1295)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
Called from: main.prg => MAIN(270)

Image


I can certainly live with both iterations of your code and set a try, catch, end try on your latest code .. and if it fails .. catch and try the first function ..

From what I have seen from various web sites .. functions with parameters in the DOM string are always present .. only the use of a "-" hyphen is very rare and probably meant to defeat exactly what I am trying to do .. Some of these web masters even rotate their DOM strings hourly and change the last element so any stored DOM string becomes stale .. I have had to defeat that bugger too .. with a for next loop and test for other attributes like "name" = "submit" instead of the direct DOM address..

Been quite an interesting education ..

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby nageswaragunupudi » Fri Jul 29, 2011 2:41 pm

Yes.
Macros can not handle "-" and OSend (as I am using) can not handle "(x)"
I am thinking of how to make a better function to handle either situation.

Soon I shall post here
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby Rick Lipkin » Fri Jul 29, 2011 3:02 pm

Rao

A single function would be great .. I have been looking at the differences between your two iterations thinking I could test for one type of parameter or another .. I did try a dual try catch end try and got it working .. one other possibility that would defeat this strategy would be a combination of both "-" hyphen and :Item(0) in the same DOM string :(

Rick


Code: Select all  Expand view

*IE:document:forms:item(0):search:Value = cPARTS
*cSFD := "document:forms:tsf:lst-ib"
*IE:document:forms:tsf:lst-ib:Value := cPARTS
*IE:document:forms:item(0):search:Value := cPARTS
*cSFD := "document:forms:item(0):search"
*OSendMulti( IE, cSFD+":Value", cPARTS )   // in func_lib.prg

try
  * bSFD := &( [ { | IE | IE:]+cSFD+[:Value := "]+cPARTS+[" } ] )
   OSendMulti( IE, cSFD+":Value", cPARTS )   // in func_lib.prg
catch
   try
     OSendMulti1( IE, cSFD+":Value", cPARTS )   // in func_lib.prg
   catch
      cSAY := "Inserting part number "+cPARTS+"  FAILED"
      oSay:ReFresh()
      SysReFresh()

      aLINE := { cURL,cPARTS,cSAY,"   ", "    ", "  " }
      AAdd( aResults, aLine )
      oLbx2:Refresh()
      oLbx2:GoBottom()

      SysReFresh()

      try
         IE:Quit()
      catch
      end try

      IF cTESTING = "TEST"
         oBtn1:Enable()
         oBtn2:Enable()
      ENDIF

      SysReFresh()
      RETURN(.F.)
   end try
end try

*eval( bSFD, IE )

cSAY := "Inserting part number "+cPARTS+"  DONE"
oSay:ReFresh()
SysReFresh()

SysWait(1)
 
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby nageswaragunupudi » Sat Jul 30, 2011 7:30 am

Mr Rick

Now please try this function and let me know how this works.
Code: Select all  Expand view
function OSendMulti( o, cMsg, uVal )

   local aMsg  := HB_ATokens( cMsg, ":" )
   local n     := Len( aMsg ) - If( uVal == nil, 0, 1 )
   local p

   AEval( aMsg, { |c| o := OSendEx( o, c ) }, 1, n )
   if uVal != nil
      OSend( o, ATail( aMsg ), uVal )
   endif

return o

function OSendEx( o, c )

   local p, nAt

   if ( nAt := At( '(', c ) ) > 0
      p     := SubStr( c, nAt + 1 )
      c     := Left( c, nAt - 1 )
      p     := &( Left( p, At( ')', p ) - 1 ) )
      o     := OSend( o, c, p )
   else
      o     := OSend( o, c )
   endif

return o
 

Note: OSendMulti uses OSendEx function. Please keep both of them in your lib.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby Rick Lipkin » Sat Jul 30, 2011 5:08 pm

Rao

You have solved the hyphen "-" and the :item(0) function .. however the code does not now handle this type of method where you have an action .. like Click()

cSSBD := "document:all:go"
OSendMulti( IE, cSSBD+":Click()", ) // in func_lib.prg

Application
===========
Path and name: C:\Fox\WebCrawl\WebCrawl.Exe (32 bits)
Size: 3,103,744 bytes
Time from start: 0 hours 0 mins 56 secs
Error occurred at: 07/30/2011, 09:35:31
Error description: Error BASE/1449 Syntax error: &
Args:
[ 1] = C

Stack Calls
===========
Called from: FUNC_LIB.PRG => OSENDEX(350)
Called from: FUNC_LIB.PRG => (b)OSENDMULTI(335)
Called from: => AEVAL(0)
Called from: FUNC_LIB.PRG => OSENDMULTI(335)
Called from: Vendor1.prg => _VENDOR1(640)
Called from: URLTEST.PRG => (b)_URLTEST(131)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(445)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(631)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1295)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
Called from: main.prg => MAIN(270)

Image

However .. if I remove the parenthesis :Click() to :Click .. your solution works and the method fires properly without the parenthesis !!

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Syntactical compiler error

Postby nageswaragunupudi » Sat Jul 30, 2011 6:04 pm

Please try this now:
Code: Select all  Expand view
function OSendMulti( o, cMsg, uVal )

   local aMsg  := HB_ATokens( cMsg, ":" )
   local n     := Len( aMsg ) - If( uVal == nil, 0, 1 )
   local p

   AEval( aMsg, { |c| o := OSendEx( o, c ) }, 1, n )
   if uVal != nil
      OSend( o, ATail( aMsg ), uVal )
   endif

return o

function OSendEx( o, c )

   local p, nAt

   if ( nAt := At( '(', c ) ) > 0
      p     := SubStr( c, nAt + 1 )
      c     := Left( c, nAt - 1 )
      p     := Left( p, At( ')', p ) - 1 )
   endif
   o  := If( Empty( p ),  OSend( o, c ), OSend( o, c, &p ) )

return o
 

Still this does not work for more than one parameter inside (..). We shall handle that later.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Syntactical compiler error

Postby Rick Lipkin » Sat Jul 30, 2011 6:35 pm

Rao

The parameters seem to now work :Click() and :Item(0) .. however, now the "-" is erroring .. I appreciate your tenacity .. I know it is difficult to test this without the code.

Very appreciative !
Rick Lipkin

Code: Select all  Expand view

cSFD := "document:forms:tsf:lst-ib"
OSendMulti( IE, cSFD+":Value", cPARTS )   // in func_lib.prg
 



Application
===========
Path and name: C:\Fox\WebCrawl\WebCrawl.Exe (32 bits)
Size: 3,101,184 bytes
Time from start: 0 hours 0 mins 55 secs
Error occurred at: 07/30/2011, 14:27:01
Error description: Error BASE/1449 Syntax error: &
Args:
[ 1] = C lst-ib

Stack Calls
===========
Called from: FUNC_LIB.PRG => OSENDEX(352)
Called from: FUNC_LIB.PRG => (b)OSENDMULTI(335)
Called from: => AEVAL(0)
Called from: FUNC_LIB.PRG => OSENDMULTI(335)
Called from: Vendor1.prg => _VENDOR1(453)
Called from: URLTEST.PRG => (b)_URLTEST(131)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(445)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(631)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1295)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
Called from: main.prg => MAIN(270)

Image
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests