storing system variables
I worked out a way of storing named global variables using a GLOBALS table and two global scripts.
If this is of any use to anyone, I would be happy to post my solution.
5 replies
- 
  Hi Louis Yes please! Always interested to see what other developers have come up with. Regards John 
- 
  The scripts and field descriptions are below. I use this to store text values during the session, but it can apply to any field type. let result = setGlobal( globalName, value) let result = getGlobal(globalName) The key is to bind storedGName at the server and bind storedGValue at the browser (local memory) in the table named GLOBAL. The values are stored in a table called Globals. #{//}#; 
 #{//}#;
 #{//}#;
 #{// *******************************************************}#;
 #{// ***************** FUNCTION Set Global ***********************}#;
 #{// *******************************************************}#;
 #{//}#;
 function setGlobal(gName : text,gValue : text) do
 let xResult := "";
 let xFind := "";
 let xCnt := 0;
 let xGName := lower(gName);
 let xGValue := gValue;
 if gName = null then
 let xResult := "error - gName empty.";
 xResult
 else
 let xCnt := cnt(select globals where storedGName = xGName);
 if xCnt = 0 then
 #{// if null, then no record was found so create one and store the global name and value.*}#;
 let p := (create globals);
 p.(storedGName := xGName);
 p.(storedGValue := xGValue);
 #{// *alert("A xResult is null" + xResult + "<< (Null)");**}#;
 "ok -A"
 else
 #{// if not null, then a record was found so store the global value.*}#;
 let xFind := last(select globals where storedGName = xGName);
 xFind.(storedGValue := xGValue);
 #{// *alert("xResult**=" + xResult + "<<(not null)");**}#;
 "Ok -B"
 end
 end
 end;
 #{//}#;
 #{//}#;
 #{// *******************************************************}#;
 #{// ***************** get Global ***********************}#;
 #{// *******************************************************}#;
 function getGlobal(gName : text) do
 let xGName := lower(gName);
 let xResult := "";
 let xCnt := 0;
 if gName = null then
 xResult := "error - gName empty.";
 void
 else
 xResult := last(select globals where storedGName = xGName).storedGValue
 end;
 xResult
 end;
 #{//}#;
 #{//}#;
 #{//}#;
- 
  Nifty, thanks 
- 
  Do you have a sample database I can see this working in? 
Content aside
- 1 yr agoLast active
- 5Replies
- 199Views
- 
    4
    Following
    
