Global Variable - clarification needed

I am using SC since version 4 but I still do not understand the semantic of global variables in SC.

  1. Variable type: IN and OUT global variable
    What is the real difference ?

According to the documentation IN variables are passed to a given application from other applications where OUT variables are created within the given application.
To me you can pass a variable V from A to B declaring V in A , regardless is IN or OUT in B .

Morover when I create a link from A to B I am asked to set the values for all variable in B regardless they are IN or OUT, which makes the difference between IN and OUT even more difficult to understand.

The only difference I have understood so far is that if you create an IN variable in B and you run B standalone , then the browser asks to set all value for the INs and dont ask to set the OUTs

  1. Variable with Optional flag set to on
    What is the purpose of this flag for an OUT variable ?
    If an OUT variable is supposed to be created within the application and NOT passed to the application what is reason for being an optional parameter ?
    What is an optional OUT variable ?

  2. Scope: GET/POST/SESSION

Again, if an OUT varibale is not an input parameter why should I care if it is passed via GET or POST ? It should never passed becasue it is of type OUT and not type IN
Morover to me, all global variables regardless they are IN or OUT are all saved in SESSION and are globally availabe in all apps even if they are not declared as SESSION.
So what is the purpose of the SESSION scope ?
Arent all global variable eventually saved in the SESSION even if the SESSION scope is not flagged ?

In variables are variables that are not declared in the module where they are defined. Out variables are instantiated in the module where they are declared. So you have only one ‘in’ variable and the rest are out. I don’t see the use of optional, ignored it. Get/Post/Session, in get post the variables are passed to other programs using the get or post stack. I assume that you don’t have to do that (optional) but I’m not sure. In earlier versions of Scriptcase you could see the vars appear on the url on get, but that was a huge leak. Session is the php session stack and should be default imho. Then the sessionid is used to access the correct stack. Been discussing it for ages, they never changed it.

This is really misleading because one could think that GET and POST variables are local to the app, but actually var [var_name] will always return the same value in all apps: the last one that was set in any app.

IN is the input to an application. OUT is a variable created by an application. I don’t use optional. GET and POST are http requests … GET is used for viewing something without changing it … POST is used for making changes. You need POST to transfer data between applications. That’s probably oversimplified but that’s my understanding.

[var] is a global variable, if u want it to be something else then you either need to clear it, or replace it with another value. [var_glob] = ‘x’;
Anything in [] is global, anything in {} is for field or SC values.
When creating your forms and sending values from form or app to app then you will want to decide if the value you want to use is a session value or if you are posting it from another app, ie sending it or get, retrieving it from the browser header for instance.
In most situations Post and Get will do, but like I said that depends, in most cases I use session, unless I need something to be posted from an outsourced app, in which case Post.