PxPlus User Forum

Twitter Twitter Twitter

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Josh Fake

Pages: [1]
1
Devon,

Thank you, it worked like a charm! I am not familiar with the preinput command as I am assuming the drivers for the application I work in handles those for us.  I was going off code that was written before with the shell.explorer.2 object.

Thanks Again!!

2
Devon,

Thanks for the response and yes if I removed those two lines that set a ctl value when an event is also triggered, it will execute the child objects beforeNavigate2() event.  But there is a caveat to this which is why those are needed unless there is a better way?

After the code I produced, it also has the following code waiting for an event to be triggered from the web page itself by the end user:
1000 ! loop unti user completes web navigation or closes window
1005 while 1
1010 obtain 'ME',*,'MN'; _ctl=ctl,_eom$=eom ! get input
1020 if cse(_ctl,100,101) then escape
1085 if cse(_ctl,104,4,-1999) then cancel=1; break
1090 wend


As you can see I am querying for those ctl values either 100 or 101 based on the event that occurs by user interaction within the web page itself.  Either by closing the window or by selecting one of the three buttons themselves. I cannot figure out how to show this directly within the post, but i have attached a screenshot.

So how within the code above can I have it wait in the main program for one of those events to be triggered as well as execute the BeforeNavigate2() event inside the child object?  I need both to occur using the *browser object.

The reason I need it to trigger the escape within the while loop as I have to execute javascript on its response to retrieve a "message" based on a listener.

Thanks again for your help.


3
I currently am trying to get the BeforeNavigate2() event to trigger code within a child object, so as in shell.explorer.2 make any necessary changes if allowed in the *browser object to the variant objects values.

My dilemma is that I have code that I can switch between *browser or shell.explorer.2 and with a child object waiting for the beforeNavigate2() event to be triggered, yet it will not be triggered inside of *browser but will within shell.explorer.2.  Based on what I have read on other posts, the help for *browser, and the presentation at Direxions 2018, this should work interchangeably without any issues.

Links I have mainly based this off of, thanks Jeff Wilder/Devon for the examples!!
https://forum1.pvxplus.com/index.php?topic=226.msg626#msg626
https://forum1.pvxplus.com/index.php?topic=82.msg138#msg138

My qnd for this is as follows whichIt will allow you to switch between shell.explorer.2 and *browser on line 120. The on the following line will allow you to optionally select how you want to navigate to open/navigate to a page/url via a local file, an url, or write the html directly (only works with *browser)


0010 ! sig.test.2
0100 ! configure url
0111 final_url$="https://www.blank.org/blank.html"
0115 html_file$="blank.html",html$=fnget_html$(html_file$)
0120 use_shell_explorer=0 ! 0 - use *browser object / 1 - use shell.explorer.2 object
0125 post_type$="use_url" ! "use_url","use_html_file","use_html_string"
0200 ! define window
0205 win_x=1,win_y=1,win_w=70,win_h=41
0210 win_title$="Testing of BeforeNavigate()"
0215 ! print 'dialogue'(int(win_x),int(win_y),win_w,win_h,win_title$,'CS'+'C0') ! create new window
0300 ! add *browser/shell.explorer.2 to local screen
0310 def object x,@(0,0,win_w,win_h)="[lcl]"+tbl(use_shell_explorer,"*browser","shell.explorer.2")
0315 y=new("[lcl]cseawebui",x)
0350 ! now configure y events to occur based off of standard x (browser) events
0355 ! on event from x process y ! this is configured inside of child object (y) within on_create routine
0360 on event "BeforeNavigate2" from x preinput 100
0365 on event "DownloadComplete" from x preinput 101
0400 !
0405 switch post_type$
0410 case "use_url"
0415 x'navigate2(final_url$) ! if shell.explorer.2 beforenavigate2 code is executed, browser it is not
0420 break
0430 case "use_html_file"
0435 tmp_file$="file://"+sub(lwd,dlm,"/")+tbl(mid(lwd,-1)=dlm,"/","")+html_file$
0440 x'navigate2(tmp_file$)
0445 break
0450 case "use_html_string"
0455 x'document'write(html$) ! will error if using shell.explorer.2 but still will not fire beforenavigate2 if *browser
0460 break
0470 default ; escape ! did not load xml invalid response
0480 end switch
0490 escape
0900 !
0905 escape ! do not even bother wtih the following until i can get beforenavigate2 to function with *browser
0910 drop object y ! cseawebui.pvc
0915 drop object x ! *browser/shell.explorer.2
30000 def fnget_html$(local file$)
30005 local tmp$,response$,opened
30010 try
30015 open (hfn)file$; opened=1
30020 read record (lfo,end=*next)tmp$; response$+=tmp$; goto *same
30025 catch ; response$="<failed load>"
30035 finally ; if opened then close (lfo)
30040 end_try
30045 return response$
30050 end def

After instantiating the *browser object, I open my child "object" to halt code when an event inside of the browser is triggered.  Instantiated on line 315.
0010 ! CSEAWEBUI.pvc
1000 ! ^1000,5
1005 def class "CSEAWEBUI"
1010 property postdata$
1020 property browser_type$
1080 function beforenavigate2(*)ON_BEFORE_NAVIGATE for event "BeforeNavigate2" ! *
1090 end def
2000 ON_CREATE:
2005 enter o_browser
2010 on event from o_browser process _obj
2015 browser_type$=try(o_browser'pvxname$,"*browser")
2020 msgbox "cseawebui - on_create"+sep+"Using: "+browser_type$,"event triggered","!"
2090 exit
3000 ON_BEFORE_NAVIGATE:
3005 enter pdisp,url,flags,targetframename,postdata,headers,cancel,err=*next
3006 msgbox "cseawebui - BEFORENAVIGATE2()"+sep+"Using: "+browser_type$,"event triggered","!"
3010 def object url
3015 def object flags
3020 def object targetframename
3025 def object postdata
3030 def object headers
3050 msgbox "url="+url'val$+sep+"flags="+str(flags'val)+sep+"targetFrameName="+targetframename'val$+sep+"headers="+headers'val$+sep+"postData="+postdata'val$,"INFO"
3090 exit


Using the code above when setting the qnd to use shell.explorer.2 beforenavigate2() event will trigger as desired and the message box will appear.  But within *browser it will not.  Is there anyone that can assist in pointing me how to get the beforenavigate2() event to trigger in *browser?  I have been spinning my wheels on this one.

Any and all help will be greatly appreciated.


4
Programming / Re: VS Code Extension for PxPlus
« on: November 13, 2020, 09:41:45 AM »
I am also looking for an extension for Visual Studio Code and actually started creating an extension at one time, but unfortunately time has not been a luxury.
The closest extension I could find is the Pick Basic extension.  I was using it as the basis for the extension I was creating

Would love to have a PxPlus extension as add on for Visual Studio Code!

5
Wish List / Re: prevent error 65 in *obj/xml
« on: August 20, 2020, 07:46:43 PM »
Mike,

I think I wrote this function before the try() system function was available back in early 2010 or 2011.  I was also using the MsXML2.ServerXMLHttp object which was significantly more code to retrieve a single value from a node/element.  i.e x$=evs("id'getelementsbytagname("+quo+tag$+quo+")'item(0)'text$",err=*next). So when migrating to the *obj/xml parser I just kept most of the syntax the same.

But I will definitely utilize your suggestion keeping speed in mind when I am tweaking those document import interfaces again. It will definitely help!

Thanks Mike!!

6
Wish List / Re: prevent error 65 in *obj/xml
« on: August 20, 2020, 12:02:31 PM »
Thomas,

I actually wrote a function  to trap the error and reduce coding inside of program.

14800 ! def function
14805 def fnxget$(id,tag$)
14810 local x$
14820 x$=evs("id'find_node("+quo+tag$+quo+")'value$",err=*next)
14825 return x$
14830 end def

Then utilize as:
x$=fnxget$(xml,"missing/node")

Hope this helps!!

7
Programming / Re: LIST OF OBJECTS
« on: June 02, 2020, 12:45:16 PM »
I am not sure when the introduction of powershell was introduced to windows, but I have also found the same command def object x,"*" to be very limiting regardless if on the server or via a windx client.

If the Windows 7 client has powershell, you can always use the following command to retrieve a list of ActiveX objects you can instantiate although many are O/S specific.

gci HKLM:\Software\Classes -ea 0| ? {$_.PSChildName -match '^\w+\.\w+$' -and
(gp "$($_.PSPath)\CLSID" -ea 0)} | ft PSChildName

Hope this helps!

8
Programming / Re: GUID generator
« on: December 06, 2019, 11:19:09 AM »
Dave/Gord,

Also if you are using Windows, you can use the following code:

0252 def object myguid,"Scriptlet.TypeLib"
0253 guid$=mid(myguid'guid$,2,36)
0254 drop object myguid

Just another way to accomplish the same thing as Gord!

Josh

9
Wish List / XML -> JSON CVS Translator
« on: September 25, 2019, 12:43:01 PM »
As a wish, could it be possible to add an additional option to the CVS() function or within the XML.pvc so that a custom engine to generate XML can be easily translated to JSON. 
This would allow web services that are generated in prior versions allow external systems that once requested XML change to JSON without many changes to the interfaces that generated the XML. 
 ie.  json$=cvs(xml$,"XML:JSON")
or
xml=new("*obj/XML")
........
xml$=xml'get_xml$()
json$=xml'get_json$()
if api_response$="JSON" then print(%print_fn)json$ else print(%print_fn)xml$
drop object xml

10
Programming / *obj/Excel - When Dropped Excel Closes
« on: June 12, 2019, 12:31:18 PM »
Using the new excel object *obj/excel, instantiating the object and making the changes to either a new worksheet or an existing worksheet, making it visible to the end user works great.
The only issue I have is that when I want to drop the object, it will close the excel spreadsheet.  I have viewed the pxplus documentation on the excel object, and could not find an answer, but is there a way to allow the excel worksheet to stay open and visible to the end user when the application drops the excel object? 

I want the end user to have the capability within excel itself to specify the location (due to using OneDrive/Sharepoint locations) where they want it saved instead of adding a new multi_line prompt within my code to do so.

Thanks for the help ahead of time!

11
Programming / Re: XML Parser - Find Node based on Attribute Value
« on: March 29, 2019, 12:34:05 PM »
Thanks Allen, this client uses Unform extensively.   I might check it out as I could use your REST interfaces to post the Question Node and have it return a response back to FACTS as a new alternative.

12
Programming / Re: XML Parser - Find Node based on Attribute Value
« on: March 29, 2019, 11:57:20 AM »
Thank you Allen!

I will try this as I have never worked directly with the xml() function and see if this will work.  I have about 30 of these I have to navigate through so I will probably have to add a switch/case/end switch while transversing through all the question sub-nodes.  But I will definitely try this.

 I was just hoping there would be a way to handle this via the xml class find_node() method.  Most of the methods I use in the MS Com Object are easily converted to a method within the*obj/XML interface with the exception of this one. I'll add this as an "enhancement request".

13
Programming / XML Parser - Find Node based on Attribute Value
« on: March 29, 2019, 10:19:05 AM »
To All:

I am in the process of moving away from the MS XML Parser MSXML2.DomDocument and replacing with the native XML object parser *obj/XML.  95% of the code is easily interpreted from using the MS COM Object to the Pvx Parser, but this last issue.

I have an incoming XML response from a webservice (this is just a "small snippet") with a list of a very large of Question Subnodes within the Question Node.

<Questions Level="Product">
    <Question Name="SpecialtyShape">
        <Answer>None</Answer>
    </Question>
    <Question Name="MV_ConfigIDListVisual">
        <Answer>1340</Answer>
        <Answer>1348</Answer>
    </Question>
    <Question Name="PricingGroup">
        <Answer>L06</Answer>
    </Question>
    <Question Name="Shape">
        <Answer>Rectangular</Answer>
    </Question>
    <Question Name="InsectScreen">
        <Answer>No</Answer>
    </Question>
    <Question Name="ConfigIDAccessoryGrid">
        <Answer>-29</Answer>
    </Question>
    <Question Name="NetPriceExtended">
        <Answer>2951.10</Answer>
    </Question>
    <Question Name="InsectScreenMaterial">
        <Answer>N/A</Answer>
    </Question>
</Questions>

Within the MSXML DOM Document I could easily find a Question based on the Name attributes value.
shape_node=xml'selectsinglenode("Questions/Question[@Name=""Shape""]")
shape$=shape_node'getelementsbytagname(""Answer"")'item(0)'text$

Is there any method within the PxPlus XML object to find a node based on an attributes' value as it can be achieved in the MS XML Object?
I could loop through all questions (almost 200) and create a memory file using the Name of the Question as the primary key, but that would involve more changes than I was hoping to make, I justed was hoping to replace the object so the code was not limited to a windows o/s.

Thanks for any and all help ahead of time

Pages: [1]