getting the instatiating var inside the type

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

getting the instatiating var inside the type

Brian Loomis-2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
        <title>TITLE</title>
        <meta http-equiv="refresh" content="10;URL=[response_filepath]">
</head>
<body>

<?Lassoscript
var( 'br' ='</br>',
                'hr' ='</hr>'
                );
               
var( 'myparams' =Array (
                -Username ='******',
                -Password ='****',
                -Database ='mydatabase'));
                       
define_type:'table';

/* ~~~~~~~ this searches and returns the records array ~~~~~~ */
        define_tag('search.records', -description = 'returns an array of  
records',
                -required = 'max', -type = 'integer');
                local('myFeedback' = array);
       
                inline: -Search,
                -table='articles',
                        $myparams,
                        -maxrecords=#max;
                // #myFeedback += found_count;
                        records;
                                #myFeedback->insert:(field:'id');
                        /records;
               
                /inline;
               
                        #myFeedback += '<br/>';
                return(@#myFeedback);
       
        /define_tag;


/define_type;

var('articles' = table);

$articles->search.records(-max = 10);

?>
</body></html>


In the following sample say I want to use this type for any tablename.

could I get it to process any table name by making the table name the  
instatiating variable name?

I'd like to be able to do this:

var('anothertable' = table);
$anothertable->search.records(-max = 10);

var('yetanothertable' = table);
$yetanothertable->search.records(-max = 10);








#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lists.montania.se/Lists/knop/
(log in with your email and ConfirmationID as password, send message to
<[hidden email]> to get that ID)
Project homepage http://montania.se/projects/knop/
AIM chatroom knop aim:gochat?roomname=knop


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting the instatiating var inside the type

Johan Solve-2
I was thinking of the same thing to be able to provide better logging output in the Knop ctypes, for example I'd like ->trace to output this header:
$customerform form trace

Instead of just
Form trace

To do that I would need to get the instatiating variable name  from within the ctype itself. I didn't look closer for a way to do this but didn't see a direct solution either.


At 21.53 -0600 2007-03-18, Brian Loomis wrote:

><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
><html>
><head>
> <title>TITLE</title>
> <meta http-equiv="refresh" content="10;URL=[response_filepath]">
></head>
><body>
>
><?Lassoscript
>var( 'br' ='</br>',
> 'hr' ='</hr>'
> );
>
>var( 'myparams' =Array (
> -Username ='******',
> -Password ='****',
> -Database ='mydatabase'));
>
>define_type:'table';
>
>/* ~~~~~~~ this searches and returns the records array ~~~~~~ */
> define_tag('search.records', -description = 'returns an array of records',
> -required = 'max', -type = 'integer');
> local('myFeedback' = array);
>
> inline: -Search,
> -table='articles',
> $myparams,
> -maxrecords=#max;
> // #myFeedback += found_count;
> records;
> #myFeedback->insert:(field:'id');
> /records;
>
> /inline;
>
> #myFeedback += '<br/>';
> return(@#myFeedback);
>
> /define_tag;
>
>
>/define_type;
>
>var('articles' = table);
>
>$articles->search.records(-max = 10);
>
>?>
></body></html>
>
>
>In the following sample say I want to use this type for any tablename.
>
>could I get it to process any table name by making the table name the instatiating variable name?
>
>I'd like to be able to do this:
>
>var('anothertable' = table);
>$anothertable->search.records(-max = 10);
>
>var('yetanothertable' = table);
>$yetanothertable->search.records(-max = 10);
>
>
>
>
>
>
>
>
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list <[hidden email]>.
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>
>List archive http://lists.montania.se/Lists/knop/
>(log in with your email and ConfirmationID as password, send message to
><[hidden email]> to get that ID)
>Project homepage http://montania.se/projects/knop/
>AIM chatroom knop aim:gochat?roomname=knop


--
     Johan Sölve    [FSA Member, Lasso Partner]
     Web Application/Lasso/FileMaker Developer
     MONTANIA SOFTWARE & SOLUTIONS
http://www.montania.se   mailto:[hidden email]
 (spam-safe email address, replace '-' with 'a')

#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lists.montania.se/Lists/knop/
(log in with your email and ConfirmationID as password, send message to
<[hidden email]> to get that ID)
Project homepage http://montania.se/projects/knop/
AIM chatroom knop aim:gochat?roomname=knop

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting the instatiating var inside the type

Bil Corry-3
In reply to this post by Brian Loomis-2
Johan Solve wrote on 3/19/2007 3:28 PM:
> To do that I would need to get the instatiating variable name  from within the ctype itself. I didn't look closer for a way to do this but didn't see a direct solution either.

This was my reply on LassoTalk.

- Bil

-------- Original Message --------

Brian Loomis wrote on 3/18/2007 9:01 PM:
> could I get it to process any table name by making the table name the
> instatiating variable name?

I don't know of a way to get the var name during onCreate or sooner.  But after the var has been created, you can use this method to find the varname:


define_type:'test';
    local:'me_id' = string;
    local:'me_name' = string;

    define_tag:'oncreate';
        self->'me_id' = lasso_uniqueid;
    /define_tag;

    define_tag:'me';
        if: self->'me_name'->size;
            return: self->'me_name';
        else;
            iterate: vars, local:'i';
                if: (var: #i->name)->properties->first->(find:'me_id') == self->'me_id';
                    self->'me_name' = #i->name;
                    return: #i->name;
                /if;
            /iterate;
            self->'me_name' = 'unknown';
        /if;
        return: self->'me_name';
    /define_tag;

    define_tag:'onassign';
        self->'me_name' = string;
        self->'me_id' = lasso_uniqueid;
    /define_tag;

    define_tag:'onconvert';
        return: self->me;
    /define_tag;
/define_type;

var:'hello' = test;
var:'world' = test;;
var:'test' = $world;
$hello;'<br>'; // hello
$world;'<br>'; // world
$test;'<br>';  // test
$hello;'<br>'; // hello
$world;'<br>'; // world
$test;'<br>';  // test





#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lists.montania.se/Lists/knop/
(log in with your email and ConfirmationID as password, send message to
<[hidden email]> to get that ID)
Project homepage http://montania.se/projects/knop/
AIM chatroom knop aim:gochat?roomname=knop


Loading...