can I set and use global variables ?
for example i go to the option panel of my database (admin mode) and i type :
let pn := 110;
void
and then i would use pn (how to call "pn" back btw ? just use pn ?) anywhere in my tables
is it possible and what is the syntax ?
thanks all
16 replies
- 
  I assume you put it in "Global script definitions". I know a couple of us tried that when release 2.5 came out and didn't have any luck. One option is to create a table for persistent variables. For example, if you had a table named GV and you wanted to access a field named pn you would access it using... record(GV, 1).pn
- 
  thanks a lot sean, that's a nice alternative idea !! 
- 
  You’re welcome Laurent. I don’t mind a work around as long as it isn’t too cumbersome and this one isn’t bad. 
- 
  Hi, you can define a user function function pn() do 110 end; Now you can uses this like let XX := pn() + ... 
- 
  thanks günther ! this is what i was looking for and i'm going to test that real soon… the question that comes next is : can i use that function to FILTER views ??? 
- 
  Günther, This would be considered a global constant since it is hardcoded, but I really like the possibilities of this approach. 
- 
  Laurent, Why ask? Test!! 
- 
  lol sean, i will, i just was doing something else !! here i go for it now… 
- 
  Here's what I meant about the possibilities... function myVar(operation : text,num : number) doswitch operation docase "+=":record(GV,1).(Number := record(GV,1).Number + num)case "-=":record(GV,1).(Number := record(GV,1).Number - num)case "*=":record(GV,1).(Number := record(GV,1).Number * num)case "/=":record(GV,1).(Number := record(GV,1).Number / num)end;record(GV,1).NumberendThis is a combination of both. 
- 
  and the result is… NO, can't filter columns by a function !! (i thought =pn() would have done the job, but nope) 
- 
  Yeah, it looks like filter will not accept any kind of proxy. 
- 
  You have to take a calculated Field with pn() <compareOperation> . Then use yes/no in this field to select the valid entries.  
- 
  yes günther, that could be a work around for me, i'll think it over — thanks! 
- 
  It seems like record(GV, 1).pn is best for a single user environment. In a simultaneous multi-user environment, user two could write to the same global variable as user one, causing unexpected results. What would be a good way to make the the GV table per user, so each user would have their own global variables, based on their email address? 
- 
  you're right westy ! 
- 
  I haven't tried this, but if you add a User field to the GV table and you gave each user their own record in the GV table you could use the select statement to get the value you want. @Westy, it looks like a good modification for your user-defined function. 
Content aside
- 
    1
    
      Likes
    
- 6 yrs agoLast active
- 16Replies
- 6433Views

