Solved

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

Posted on 2010-11-17
13
553 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Auto select alias in visual foxpro 6 112
Scrolling a grid 3 1,468
not sure how to proceed 6 415
understanding loops vfp 7 90
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…
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now