How to Create an HTMLRenderer as a child with ⎕NEW ?

MiServer is Dyalog's APL-based web development framework

How to Create an HTMLRenderer as a child with ⎕NEW ?

Postby PGilbert on Thu Jul 16, 2020 12:45 am

The following is working as expected to create an HTMLRenderer as a children of a Form:
      'F' ⎕WC 'Form'
'F.HR' ⎕WC 'HTMLRenderer' ('AsChild' 1)


However, the following creates an error:
      F ← ⎕NEW ⊂'Form'
F.HR ← ⎕NEW 'HTMLRenderer' (⊂'AsChild' 1)
DOMAIN ERROR: The object could not be created
F.HR ← ⎕NEW'HTMLRenderer'(⊂'AsChild' 1)


What would be the proper syntax to create an HTMLRenderer as a child of a Form using ⎕NEW ?
User avatar
PGilbert
 
Posts: 400
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to Create an HTMLRenderer as a child with ⎕NEW ?

Postby Brian|Dyalog on Thu Jul 16, 2020 2:29 am

Hi Pierre!

This is a really good question. I too have been tripped up making the transition from ⎕WC to ⎕NEW when using the Dyalog GUI objects. It's important to remember two things when using ⎕NEW with GUI objects:
  • when creating a child object it needs to be in the context of the parent object.
  • The argument to ⎕NEW needs to be a 1 or 2 element array of [1] the type of the object and optionally [2] a depth 3 (or ¯3) array of child properties.
So, let's create a form...</br>
We need to enclose the argument since the first element of the argument to ⎕NEW needs to be the type of the object to be created. If we were to specify properties for the form, the initial enclose wouldn't be necessary.
      f←⎕NEW ⊂'Form'

If we want to specify a single property, it needs to be enclosed so as to make it depth 3 (or ¯3):
      f←⎕NEW 'Form' (⊂'Posn' (10 10))

With multiple properties, the enclose isn't necessary:
      f←⎕NEW 'Form' (('Posn' (10 10))('Sizeable' 0))

Now, to create an HTMLRenderer as a child of the form, we need to call ⎕NEW in the context of the form:
      f.(h←⎕NEW 'HTMLRenderer' (('AsChild' 1)('Posn'(0 0))('Size' (50 100))))

f.h is now a reference to the HTMLRenderer child.

Page 73 of the Windows Interface Guide has a good example of using ⎕NEW instead of ⎕WC.

I hope this helps!
/Brian
User avatar
Brian|Dyalog
 
Posts: 101
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: How to Create an HTMLRenderer as a child with ⎕NEW ?

Postby PGilbert on Thu Jul 16, 2020 2:59 am

Thanks Brian, that's a super good explanation.
User avatar
PGilbert
 
Posts: 400
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada


Return to MiServer

Who is online

Users browsing this forum: No registered users and 1 guest