Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-11-17
13
Medium Priority
?
601 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 30

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 30

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 30

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 30

Accepted Solution

by:
Olaf Doschke earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Machine Learning is one of the profound applications of AI and therefore, just like AI, it is surrounded by myths and fears. Check out these facts about ML that demystify the related myths.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

578 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