Solved

Need to access object names in a web page that has charsactors that foxpro does not like

Posted on 2010-11-17
13
571 Views
Last Modified: 2012-05-10
Here is the situation, given that a web page has the following:
<input name="input-one"></input>
<input name="input|two"></input>

Open in new window


And I am accessing the page via createobject in foxpro:
o=CREATEOBJECT('internetexplorer.application')
o.Visible=.t.
o.navigate2('c:\inputs.html')

Open in new window


Is there a simple way I can access these web page input box names by using some sort of conversion, unicode or eval statement?

Foxpro does not like the "-" (minus) or "|" (pipe) charactor

I have a somewhat complex workaround in some situations, but these are really not desirable methods.

Thank you all again!

BC
0
Comment
Question by:busycoder
  • 4
  • 4
  • 4
  • +1
13 Comments
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34158718
Yes you can.

Check STRCONV(), COMPROP and SYS(3101)
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34158736
How about getting all the elements names and addressing them in an array?
0
 

Author Comment

by:busycoder
ID: 34158870
Thats what I was doing, I am looking for another way, can you give me any examples to get me started using the functions you mentioned to directly acces an object with a name like:

input|two (using the pipe char)

You are giving me hope here :)

BC

0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34160120
0
 

Author Comment

by:busycoder
ID: 34161040
I guess I have not gotten the issue across, I have a good understanding of how to populate forms with data from Foxpro in a web page or a web object in a form.

The problem I am having using my examples above is:

You can't do this in foxpro:

o=CREATEOBJECT('internetexplorer.application')
o.Visible=.t.
o.navigate2('c:\inputs.html')
o.document.body.all.input1.value=somevalue <<-- This will work
o.document.body.all.input-one.value=somevalue <<--This will fail
o.document.body.all.input|two.value=somevalue <<--As will this


Without using an array to reference the object, does anyone know of a way to do this on one line of code for example, using some kind of conversion function to access a named object that has a dash or a pipe character in it?

Thanks,

BC
0
 
LVL 2

Expert Comment

by:Gary2Seven
ID: 34161967
Can you post or attach the contents of inputs.html?


G2S
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34162060
Why don't you use STRTRAN to rename the strings in the input.html to names that you can access.

cHTML = FILETOSTR("c:\input.html")
cHTML = STRTRAN(cHTML,"input-one","input1")
= STRTOFILE(cHTML,c:\input1.html")

you navigate to input1.html
0
 

Author Comment

by:busycoder
ID: 34165892
The examples are from a local page but the application will be pages stored on the web, I cannot have the names changed in the pages, which is why I am trying to find solutions to access these types of names. Below is how I am handling this now, I would like to know if there is a way to do something simpler, on one line of code, like you can when the object name does not contain a dash or pipe charactor in it.

x=""
o=1
the_length=Thisform.web1.Document.getElementsByTagName("input").Length

Do Whil At("input-one",Lower(x),1)=0 And o<the_length
	g='thisform.web1.document.getElementsByTagName("input").['+Alltrim(Str(o))+'].name'
	If Type('&g')="C"
		x=&g
	Endif
	o=o+1
Enddo
tt = Evaluate('thisform.web1.document.getElementsByTagName("input").['+Alltrim(Str(o-1))+']')
tt.value=some_value

Open in new window


Thanks again for helping me think about this!!!

BC
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34168515
Think about adressing the elements just via their position in the array getElementsByTagName() returns. Foxpro cannot adress the names with forbidden chars, even javascript cannot perhaps, but you can adress the element via an object reference.

Bye, Olaf.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34183620
I don't get what you want. You ARE setting the value in one line aren't you?

Of course you can also change your code a little to shorten it, and you see nowhere a name is used to adress a html tag, access is done via object reference tt and the inputtags object.

Bye, Olaf.

tt=.null.
x=""
o=1
inputtags = oIE.Document.getElementsByTagName("input")
the_length = inputtags.Length
? the_length

Do While o<=the_length
	tt = inputtags.item(o-1)
	If Type('tt.name')="C"
	    x=tt.name
	    ? x
	    ? tt.value
	Endif
	o=o+1
Enddo

Open in new window

0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34183627
Just change one line to fit your situation:

inputtags = oIE.Document.getElementsByTagName("input")
should be like in your code:
inputtags = thisform.web1.document.getElementsByTagName("input")

Bye, Olaf.
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 34183919
Or are actually just searching for getElementsByName?

tt =  thisform.web1.document.getElementsByName("input|two")

if a tag with that name exists tt should be the reference you need, if not tt.item(0) should be it.

Bye, Olaf.
0
 

Author Closing Comment

by:busycoder
ID: 34184400
That did it, thanks again all, thanks for keeping after it Olaf, now I can do it on one line of code a LOT cleaner.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Database Upscaling 9 116
one to many join on two fields vfp 2 686
Copying a DBF file fails 9 268
Foxpro 64bit decoding 8 193
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question