[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

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
?
596 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

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…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 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