Re: Creating variables

2008-08-06 Thread François Chaplais


Le 6 août 08 à 16:53, Eric Chatonet a écrit :


To be frank, I don't understand:
Below is your code snippet simplified.
What it does?
It stores a variable into a custom property: so far so good ;-)
But what more?
Please, enlighten me :-)

on mouseUp
   ask "Name of pseudo variable:" with "anExample"
   if it is empty then exit mouseUp
   put it into varName
   ask "value of variable" && varName
   if it is empty then exit mouseUp
   put it into varValue
   set the myProps[varName] of me to varValue
   answer "Do you want to retrieve the value of your variable?"  
with "Cancel" or "OK"

   if it is "OK" then
  answer "This is the value of variable" && varName & ":" &&  
the myProps[varName] of me

   end if
end mouseUp




the OP's code was

I did try this:

repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put "test" into (lineListOne & lineListTwo)
  end repeat
end repeat

and this (though I was sure it didn't work):

repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat

and some other variants (using the value of...) but nothing is  
working.


Is that possible or do I have to "manually" initialize the  
variables that way:


put "test" into A1
put "test" into A2


I interpreted this code as an attempt to manipulate a variable  
designated by name only . I have not found a way to do so without  
using the "do" command, which you rightfully pointed out as a  
solution  (but perhaps someone in the list knows of another way).


My only point is that custom properties are a way to store and  
retrieve data labeled with a string which is itself stored in a  
variable. It is probable that arrays would also do the trick, but I  
do not know arrays enough to elaborate on this.


My apologies if I am not very clear, but Revolution programming is  
just a hobby to me and since I am on vacation, I have some time to  
experiment some code, this should be over next week :-(


Best regards,
François
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread Richard Gaskin

Eric Chatonet wrote:
> In Revolution, you can write:
>
> put the long ID of fld "MyField" into tObj
> put empty into tObj
> set the showBorder of tObj to true
> etc.
>
> As soon as you have put a long name/ID into a variable, you can use
> it without any 'do' :-)
> Secure and easy...

...and fast.

In Rev, scripts are runtime-compiled, so you'll generally see some 
amazing speed with most operations.  But "do" and "send" can't be 
compiled on load like everything else, since the strings they operate on 
need to be assembled at runtime.  As a result, "do" and "send" will run 
more slowly than compilable alternatives like the example Eric noted above.



François Chaplais wrote:
> I think I have found a workaround for working with "variables"
> referenced by names. It involves custom property sets.
> Moreover the variables can be accessed globally and are stored in
> the stack file upon save. haven't tried in in a standalone for the
> moment, though.

The OS prevents applications from modifying themselves, so any 
modifiable data that you want to save will need to be stored separately 
from the stack file that becomes the standalone.


For good info on saving data in standalones check out this article at 
revJournal.com:


Saving data in Revolution standalones
by Sarah Reichelt


--
 Richard Gaskin
 Managing Editor, revJournal
 ___
 Rev tips, tutorials and more: http://www.revJournal.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread Eric Chatonet

To be frank, I don't understand:
Below is your code snippet simplified.
What it does?
It stores a variable into a custom property: so far so good ;-)
But what more?
Please, enlighten me :-)

on mouseUp
   ask "Name of pseudo variable:" with "anExample"
   if it is empty then exit mouseUp
   put it into varName
   ask "value of variable" && varName
   if it is empty then exit mouseUp
   put it into varValue
   set the myProps[varName] of me to varValue
   answer "Do you want to retrieve the value of your variable?" with  
"Cancel" or "OK"

   if it is "OK" then
  answer "This is the value of variable" && varName & ":" && the  
myProps[varName] of me

   end if
end mouseUp

Le 6 août 08 à 15:41, François Chaplais a écrit :

I think I have found a workaround for working with "variables"  
referenced by names. It involves custom property sets. These can be  
referenced by name. Here is an button script example:


on mouseUp
  ask "Custom property set?" with "example"
  if it is empty then
exit mouseup
  end if
  put it into theName
  set the customPropertySet of me to theName
  put the customproperties[thename] of me into myProps
  --  creation of variable by asking name; can be replaced by  
anything that returns a string

  ask "Name of pseudo variable:" with "anExample"
  put it into varName
  if varName is empty then
exit mouseup
  end if
  -- assigning value of "variable" anything will do, I think, since  
this is a custom property

  ask "value of variable" && varName -- put your code here
  if it is empty then
exit mouseup
  end if
  put it into myProps[varName]
  set customproperties[thename] of me to myProps -- value is set
  answer "Do you want to retrieve the value of your variable?" with  
"Cancel" or "OK"

  if it is "OK" then -- retrieve variable value
put the customproperties[thename] of me into myProps
get myProps[varName]
answer "This is the value of variable" && varName & ":" && it
  end if
end mouseUp

I think this can be made pretty generic and split into several  
independent handlers/functions. Moreover the variables can be  
accessed globally and are stored in the stack file upon save.  
haven't tried in in a standalone for the moment, though.


Best regards,
François


Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread François Chaplais


Le 6 août 08 à 14:26, Eric Chatonet a écrit :

I'm sorry, I was a bit quick: all this works when getting/setting  
properties only:


put the long ID of fld "MyField" into tObj
set the text of tObj to empty




I think I have found a workaround for working with "variables"  
referenced by names. It involves custom property sets. These can be  
referenced by name. Here is an button script example:


on mouseUp
  ask "Custom property set?" with "example"
  if it is empty then
exit mouseup
  end if
  put it into theName
  set the customPropertySet of me to theName
  put the customproperties[thename] of me into myProps
  --  creation of variable by asking name; can be replaced by  
anything that returns a string

  ask "Name of pseudo variable:" with "anExample"
  put it into varName
  if varName is empty then
exit mouseup
  end if
  -- assigning value of "variable" anything will do, I think, since  
this is a custom property

  ask "value of variable" && varName -- put your code here
  if it is empty then
exit mouseup
  end if
  put it into myProps[varName]
  set customproperties[thename] of me to myProps -- value is set
  answer "Do you want to retrieve the value of your variable?" with  
"Cancel" or "OK"

  if it is "OK" then -- retrieve variable value
put the customproperties[thename] of me into myProps
get myProps[varName]
answer "This is the value of variable" && varName & ":" && it
  end if
end mouseUp

I think this can be made pretty generic and split into several  
independent handlers/functions. Moreover the variables can be  
accessed globally and are stored in the stack file upon save. haven't  
tried in in a standalone for the moment, though.


Best regards,
François
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread Eric Chatonet
I'm sorry, I was a bit quick: all this works when getting/setting  
properties only:


put the long ID of fld "MyField" into tObj
set the text of tObj to empty


Le 6 août 08 à 14:22, François Chaplais a écrit :


Le 6 août 08 à 13:48, Eric Chatonet a écrit :


put the long ID of fld "MyField" into tObj
put empty into tObj
set the showBorder of tObj to true


I have tried this
-
on mouseUp
  put empty into fld 1
put the long ID of fld 1into tObj
put "hello" into tObj --- does not work, tObj now contains "hello"
end mouseUp
--
and it does not work (field stays empty, script executes). However
-
on mouseUp
  put empty into fld 1
put the long ID of fld 1into tObj
set the text of  tObj  to "hello"--- works
end mouseUp
---
works.

Best regards,
François


Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread François Chaplais


Le 6 août 08 à 13:34, Mark Schonewille a écrit :


Hi François,

When a variable contains a reference to an object and you can't use  
the put command with that variable because it would change the  
variable rather than the object referred to, use the text property:


set the text of myFieldReference to "some text"




thanks. indeed,

on mouseUp
  put the long name of fld 1 into myFldName
  ask "type text"
  set the text of fld myFldName to it
end mouseUp

works.
this also works:
---
on mouseUp
  put the long name of me into theName
  ask "what"
  set the myProp of theName to it
end mouseUp
--
works. If this can be generalized, does this mean that setting  
properties of objects referenced by name strings is possible in general?

(I just read Eric's post, and it seems the answer is "yes").


However, this does not address the issue of the OP, which want to set  
the value of variable referenced by name. "value" is a function and  
not a property (is this right?), so it does not do the trick.


Best regards,
François
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread François Chaplais


Le 6 août 08 à 13:48, Eric Chatonet a écrit :


put the long ID of fld "MyField" into tObj
put empty into tObj
set the showBorder of tObj to true


I have tried this
-
on mouseUp
  put empty into fld 1
put the long ID of fld 1into tObj
put "hello" into tObj --- does not work, tObj now contains "hello"
end mouseUp
--
and it does not work (field stays empty, script executes). However
-
on mouseUp
  put empty into fld 1
put the long ID of fld 1into tObj
set the text of  tObj  to "hello"--- works
end mouseUp
---
works.

Best regards,
François
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread Eric Chatonet

Bonjour François,

Le 6 août 08 à 13:25, François Chaplais a écrit :

as far as I am concerned, it seems to me that, for instance, if  
 is the long name of a filed, if you want to put empty into  
the field with name , then you have to script

do "put empty into" && 


In Revolution, you can write:

put the long ID of fld "MyField" into tObj
put empty into tObj
set the showBorder of tObj to true
etc.

As soon as you have put a long name/ID into a variable, you can use   
it without any 'do' :-)

Secure and easy...

Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread Mark Schonewille

Hi François,

When a variable contains a reference to an object and you can't use  
the put command with that variable because it would change the  
variable rather than the object referred to, use the text property:


set the text of myFieldReference to "some text"

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Benefit from our inexpensive hosting services. See http://economy-x-talk.com/server.html 
 for more info.


On 6 aug 2008, at 13:25, François Chaplais wrote:



Le 5 août 08 à 16:12, Eric Chatonet a écrit :


Bonjour Eric,

Le 6 juil. 08 à 22:38, Éric Miclo a écrit :


repeat for each line lineListOne in listOne
 repeat for each line lineListTwo in listTwo
   put (lineListOne & lineListTwo) into varName
   put "test" into varName
 end repeat
end repeat


put  into tContents
do "put tContents into" && varName

Best regards from Paris,
Eric Chatonet.



a more general digression on manipulating rev object by names and  
not by value:


as far as I am concerned, it seems to me that, for instance, if  
 is the long name of a filed, if you want to put empty into  
the field with name , then you have to script

do "put empty into" && 
and then probably have to deal with the quotes in the long name (it  
seems I have had to do this countless times when executing a loop on  
object names in a group/card/whatever)


The OP was concerned to setting a variable value when knowing only  
its name, and Eric's answer was to use the "do" command. This is  
something I have used quite frequently in my HC days, but  
unfortunately use of the "do" command is severely restricted in  
standalones (with reasons I can understand).


I was hoping that the reference operator @ would do the trick, i.e.  
passing the name of the variable instead of the variable itself. The  
following button handler works:

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-06 Thread François Chaplais


Le 5 août 08 à 16:12, Eric Chatonet a écrit :


Bonjour Eric,

Le 6 juil. 08 à 22:38, Éric Miclo a écrit :


repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat


put  into tContents
do "put tContents into" && varName

Best regards from Paris,
Eric Chatonet.



a more general digression on manipulating rev object by names and not  
by value:


as far as I am concerned, it seems to me that, for instance, if  
 is the long name of a filed, if you want to put empty into the  
field with name , then you have to script

do "put empty into" && 
and then probably have to deal with the quotes in the long name (it  
seems I have had to do this countless times when executing a loop on  
object names in a group/card/whatever)


The OP was concerned to setting a variable value when knowing only  
its name, and Eric's answer was to use the "do" command. This is  
something I have used quite frequently in my HC days, but  
unfortunately use of the "do" command is severely restricted in  
standalones (with reasons I can understand).


I was hoping that the reference operator @ would do the trick, i.e.  
passing the name of the variable instead of the variable itself. The  
following button handler works:


---
on mouseUp
  put 1 into myVar
  doput "hello",myVar
  answer myVar
end mouseUp

on doput theText,@theVarName
  put theText into theVarName
end doput
--

the following causes an execution error when trying to execute the  
doput handler


--
on mouseUp
  put 1 into myVar
  doput "hello","myVar"
  answer myVar
end mouseUp

on doput theText,@theVarName
  put theText into theVarName
end doput
--

If something similar could be done without using the "do" command,  
for instance by passing arguments by name (i.e. a string), I would be  
very happy to hear about it.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: call to the "do" command...limited in standalones [was: Creating variables]

2008-08-05 Thread François Chaplais


Le 6 août 08 à 00:19, Hansen Erik a écrit :




unfortunately, this is another call to the "do" command whose usage
is seriously limited in standalones (this has been already discussed).
I wish that there were to tell transcript that when "set the
 of  to ",  refers to
variables whose value is the name of a transcript language chunk,
without using the "do" command.
I have never tried this before, but using a variable reference (with
@  for instance?) would perhaps do the trick?

Best regards
François

===

What was the thread called?

Merci, Erik



it seems the reply was messed up. The previous post was from Eric  
Chatonet, quoted below:

Bonjour Eric,

Le 6 juil. 08 à 22:38, Éric Miclo a écrit :



repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat



put  into tContents
do "put tContents into" && varName

Best regards from Paris,
Eric Chatonet.


(which prompted my remark on the do command)
it was itself a reply to

Hello,

I've 2 lists of names and want to create variables by combining the  
names of the 2 lists.


Example:

listOne is:

A
B
C


listTwo is:

1
2

and I want to create those variables:

A1
A2
B1
B2
C1
C2

I did try this:

repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put "test" into (lineListOne & lineListTwo)
  end repeat
end repeat

and this (though I was sure it didn't work):

repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat

and some other variants (using the value of...) but nothing is  
working.


Is that possible or do I have to "manually" initialize the  
variables that way:


put "test" into A1
put "test" into A2
...



by Eric Miclo. HTH
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-05 Thread François Chaplais


Le 5 août 08 à 16:12, Eric Chatonet a écrit :


Bonjour Eric,

Le 6 juil. 08 à 22:38, Éric Miclo a écrit :


repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat


put  into tContents
do "put tContents into" && varName




unfortunately, this is another call to the "do" command whose usage  
is seriously limited in standalones (this has been already discussed).
I wish that there were to tell transcript that when "set the  
 of  to ",  refers to  
variables whose value is the name of a transcript language chunk,  
without using the "do" command.
I have never tried this before, but using a variable reference (with  
@  for instance?) would perhaps do the trick?


Best regards
François

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-08-05 Thread Eric Chatonet

Bonjour Eric,

Le 6 juil. 08 à 22:38, Éric Miclo a écrit :


repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat


put  into tContents
do "put tContents into" && varName

Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Creating variables

2008-08-05 Thread Éric Miclo

Hello,

I've 2 lists of names and want to create variables by combining the  
names of the 2 lists.


Example:

listOne is:

A
B
C


listTwo is:

1
2

and I want to create those variables:

A1
A2
B1
B2
C1
C2

I did try this:

repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put "test" into (lineListOne & lineListTwo)
  end repeat
end repeat

and this (though I was sure it didn't work):

repeat for each line lineListOne in listOne
  repeat for each line lineListTwo in listTwo
put (lineListOne & lineListTwo) into varName
put "test" into varName
  end repeat
end repeat

and some other variants (using the value of...) but nothing is working.

Is that possible or do I have to "manually" initialize the variables  
that way:


put "test" into A1
put "test" into A2
...

Thanks, best,

ÉrIC

-- My NeXT computer will Be a Mac too! --


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-07-06 Thread Éric Miclo

Hello Mark,

It's workin fine!
Thanks a lot!.

Best regards,

ÉrIC

Le 6 juil. 08 à 22:49, Mark Schonewille a écrit :



Hi Éric,

Use the do command:

do ("put" && quote & "test" & quote && "into" && varName)

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Benefit from our inexpensive hosting services. See http://economy-x-talk.com/server.html 
 for more info.


On 6 jul 2008, at 22:44, Éric Miclo wrote:


Hello,

I've 2 lists of names and want to create variables by combining the  
names of the 2 lists.


Example:


I did try this:

repeat for each line lineListOne in listOne
repeat for each line lineListTwo in listTwo
 put "test" into (lineListOne & lineListTwo)
end repeat
end repeat

and this (though I was sure it didn't work):

repeat for each line lineListOne in listOne
repeat for each line lineListTwo in listTwo
 put (lineListOne & lineListTwo) into varName
 put "test" into varName
end repeat
end repeat

and some other variants (using the value of...) but nothing is  
working.


Is that possible or do I have to "manually" initialize the  
variables that way:


put "test" into A1
put "test" into A2
...

Thanks, best,

ÉrIC


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution



-- My NeXT computer will Be a Mac too! --


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating variables

2008-07-06 Thread Mark Schonewille

Hi Éric,

Use the do command:

do ("put" && quote & "test" & quote && "into" && varName)

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Benefit from our inexpensive hosting services. See http://economy-x-talk.com/server.html 
 for more info.


On 6 jul 2008, at 22:44, Éric Miclo wrote:


Hello,

I've 2 lists of names and want to create variables by combining the  
names of the 2 lists.


Example:


I did try this:

repeat for each line lineListOne in listOne
repeat for each line lineListTwo in listTwo
  put "test" into (lineListOne & lineListTwo)
end repeat
end repeat

and this (though I was sure it didn't work):

repeat for each line lineListOne in listOne
repeat for each line lineListTwo in listTwo
  put (lineListOne & lineListTwo) into varName
  put "test" into varName
end repeat
end repeat

and some other variants (using the value of...) but nothing is  
working.


Is that possible or do I have to "manually" initialize the variables  
that way:


put "test" into A1
put "test" into A2
...

Thanks, best,

ÉrIC


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Creating variables

2008-07-06 Thread Éric Miclo

Hello,

I've 2 lists of names and want to create variables by combining the  
names of the 2 lists.


Example:

listOne is:

A
B
C


listTwo is:

1
2

and I want to create those variables:

A1
A2
B1
B2
C1
C2

I did try this:

repeat for each line lineListOne in listOne
 repeat for each line lineListTwo in listTwo
   put "test" into (lineListOne & lineListTwo)
 end repeat
end repeat

and this (though I was sure it didn't work):

repeat for each line lineListOne in listOne
 repeat for each line lineListTwo in listTwo
   put (lineListOne & lineListTwo) into varName
   put "test" into varName
 end repeat
end repeat

and some other variants (using the value of...) but nothing is working.

Is that possible or do I have to "manually" initialize the variables  
that way:


put "test" into A1
put "test" into A2
...

Thanks, best,

ÉrIC

-- My NeXT computer will Be a Mac too! --
-- My NeXT computer will Be a Mac too! --


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


need help with XML-RPC server side (or, creating variables on the run...)

2004-07-06 Thread Andre Garzia
Hi Folks,
I am finishing a XML-RPC server side implementation and stumbled in a 
problem. For those that are not familiar with XML-RPC let me explain it 
briefly and also note why it is so important to us. XML-RPC Stands for 
XML Remote Procedure Call. I hope that everyone here is familiar with 
XML, XML is a kind of text document with special tags one can use to 
represent arbitrary data, it feels similar to HTML but it's general 
purpose,  an simple example might be:


Andre Garzia
Mr Murphy

One trying to understand XML better should read the wonderfull tutorial 
by Sarah at http://www.troz.net/Rev/#XMLdemo1 this will teach the 
basics of XML and why it's good for us. Now lets get back to the RPC 
part of XML-RPC. When we code in transcript, we write handlers and 
functions, our programs call this handlers and functions to work. What 
a RPC system does is to make possible that one program can call a 
handler/function of another program across a network (or even on the 
same machine). This way we can have a engine on the server and a client 
on the local machine and the client would call the needed functions on 
the server. A real world demo of this is the Blogger API that drives 
the weblogs hosted on Blogger.com (which is now a google company). You 
can use the HTML interface to manage your blog or use a custom client 
running on your desktop. Either way, when you post a new entry to your 
weblog, the client (HTML interface or custom) sends a remote procedure 
call to the server, this call is called Blogger.newPost with your login 
and the entry as parameters, then the entry is added to your blog, it's 
elegant and simple and one of the reasons behind the blog revolution. 
The protocol that drives this is XML-RPC, that's the lingua franca 
spoken between the server and the clients.

to use XML-RPC one assemble the call as a XML and POST it to the 
server, the server then answers the result. It's that simple. To see 
the spec of XML-RPC just point your browser to http://www.xmlrpc.com an 
simple example of XML-RPC call is this:



   examples.getStateName
   
  
 41
 
  
   
See the handler to be called on the server is identified as 
examples.getStateName and the only parameter is a integer, 41.

What I am implementing is the server side of this, the part that takes 
the XML and feeds it to revolution so that you could do this:



   myStack.add
   
  
 1
  1
 
  
   
and your result would be 2. Remember, that would be executed on a 
remote machine and the result sent to your app. Thats as easy as a 
distributed app can be. Now the problem. What I am doing is, parse the 
XML to extract the handler to be called then start parsing the 
parameters, there can be any number of params in a call, there's no way 
to predict it. So how do I store this parameters? I want the the above 
XML call to be translated to the following code:

send "add 1 1" to stack "myStack"
with string is easy, we can just append them to the message we will 
call, but XML-RPC calls can contain arrays and even dictionaries (keyed 
arrays) as parameters, I need a way to create variables on the fly 
while parsing and then assemble them all in a line to use "send" 
function. I thought about using an array, but arrays can't contain 
arrays, so if the XML contains an array then my solution folds...

I could use a data structure common to CS students, the Stack, where I 
would push elements into it as I go parsing the XML, then when 
assembling the "send" line I could pull the elements from the stack and 
do it, my problem is, I am not succeeding in implementing a Stack Data 
Structure that can contain arrays... if someone here can help or can 
think in another way to implement a way to store an arbitrary number of 
parameters please tell me. I want to be ready with this before the 
summit... It would be a great addition to demo XML-RPC server side 
there...

Cheers
Andre
--
Andre Alves Garzia  2004
Soap Dog Studios - BRAZIL
http://studio.soapdog.org___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution