[Gambas-user] Passing arguments between WebPages
    Tobias Boege 
    taboege at ...626...
       
    Thu May 18 17:14:38 CEST 2017
    
    
  
Hi Benoit (or gb.web experts),
I have two questions about argument passing with WebPages (gb.web),
when I include one webpage into another with the <<OtherPage>> syntax.
(1) The first situation is that I have a small widget encapsulated in a
WebPage, let's say it is a specially formatted button MyButton.webpage.
It expects to be included with a text to put on the button:
  <<MyButton text="label">>
I want to be able to pass the value of a local variable of my parent
WebPage inside this argument like this (which doesn't work):
  <% For Each iInd = 0 To AllButtons - 1 %>
    <<MyButton text=Subst$("Button #&1", iInd)>>
  <% Next %>
Is this possible? A workaround here would be to define a function in the
parent WebPage which creates and renders an instance of MyButton and call
that, resulting in something like:
  <% For Each iInd = 0 To AllButtons - 1 %>
    <%= RenderButton(Subst$("Button #&1", iInd)) %>
  <% Next %>
This is good enough but I'm curious if the <<WebPage>> syntax admits
the other kind of argument passing somehow, as I think it would make
the parent WebPage prettier.
(2) The other question is about receiving arguments. If I'm a child page
and the parent included me by setting the "text" argument (like in (1)),
then I can print the "text" value via the special syntax
  <%!text>
But I want to use this value inside a <% Code %> or <%= Expr %> section,
to evaluate or manipulate it (this also doesn't work, but hopefully gets
my question across):
  <%= Subst$(!text, "#", "No. ") %>
For instance, is there a hidden Collection containing all the passed
arguments somewhere in the scope in which <% Code %> and <%= Expr %>
execute?
Regards,
Tobi
-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
    
    
More information about the User
mailing list