RPGspSave Function


Saves a session variable. Does not return a value.


Syntax

RPGspSave(name : value)

Part Description
name Required. The name of the session variable.
value Required. Character expression representing the value to save.


Remarks

Session variables are variables that can be shared across multiple page requests within a session. In RPGsp, a session starts when a new user requests a browser page. The session ends when that same user closes the browser or has not requested or refreshed a page in the application for a long time. A common use for session variables is to store the position of an HTML subfile.

The value passed to RPGspSave is not actually saved until the page has executed entirely and is sent to the client. This value can be retrieved later by its session variable name with the use of the RPGspIn function.


Example

The following code increments and displays a counter with every refresh of a page.

     D  counter        S              5I 0

     C                   Eval      counter = RPGspVal(RPGspIn('COUNTER'))
     C                   CallP     RPGspOut(%Char(counter))

     C                   CallP     RPGspSave('COUNTER':%Char(counter+1))

Note the use %Char to convert a numeric value to characters before passing to RPGspSave.

To test this snippet of code, start a new RPG Smart Page, select the Insert RPG Script option, copy and paste the code above, then compile and launch.


See Also

RPGspIn

%Char


Profound Logic Software, Inc.
www.ProfoundLogic.com
(937) 439-7925