The following module demonstrates a method of creating and using a ref-like variable within a user defined type while programming in Tier 1.
https://github.com/charlesgriffiths/agk-modules/tree/main/other/ref
Global variables are always an alternative, but crowd the namespace and their scope makes a large program difficult to analyze. Using a tRef adds minimal delay to variable access (typically under a microsecond) and the type will indicate whether data has been read or written more recently by use of the dirty flag. Using a ref within your own type allows you to write more generic code and not (for example) resort to copying a routine just to change the name of one global variable.
Ref_Init() create
Ref_Delete() delete
Ref_DeleteAll() delete all instances of tRef
Ref_IsDirty( tRef )
Ref_SetDirty( tRef )
get and set data via the type
Ref_GetInt( tRef )
Ref_SetInt( tRef, integer )
Ref_GetFloat( tRef )
Ref_SetFloat( tRef, integer )
Ref_GetString( tRef )
Ref_SetString( tRef, integer )
Ref_ToString( tRef ) puts the data in a tRef into a string
tRefa is like tRef but stores arrays instead of single values.
Comments welcome.