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.


Topics - Josh Fake

Pages: [1]
1
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.


2
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

3
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!

4
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]