Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Object/Path? question

 [1/7] from: kpeters:otaksoft at: 1-Sep-2007 12:08


config-obj: attempt [ make object! load %my-app.cfg ] probe config-obj/setting1 The probe fails if there is no 'setting1 defined in %my-app.cfg Is there a way to test for this before attempting to probe (or doing anything else with it) other than wrapping it in an 'attempt? Thanks Kai

 [2/7] from: tim-johnsons::web::com at: 1-Sep-2007 11:39


On Saturday 01 September 2007, Kai Peters wrote:
> config-obj: attempt [ make object! load %my-app.cfg ] > > probe config-obj/setting1 > > The probe fails if there is no 'setting1 defined in > %my-app.cfg > > Is there a way to test for this before attempting to probe (or doing > anything else with it) other than wrapping it in an 'attempt?
;; How about 'in ?
>> o: context[t: 1] >> in o 't
== t
>> in o 'x
== none
>> either in o 'x[print 'yes][print 'no]
no
>> get in o 't
== 1 HTH Tim

 [3/7] from: kpeters::otaksoft::com at: 1-Sep-2007 14:54


Thanks for the quick help, Tim! On Sat, 1 Sep 2007 11:39:58 -0800, Tim Johnson wrote:

 [4/7] from: moliad:g:mail at: 4-Sep-2007 23:44


as a side note... you can use value? to test for a value within a context at that moment (or otherwise if its been defined globally). I use it sometimes to delay the refresh of things which can run in an gui or not, or which have a chance of being run before the gui is opened... ex: unless value? 'gui [ show gui ] -MAx On 9/1/07, Kai Peters <kpeters-otaksoft.com> wrote:

 [5/7] from: moliad:g:mail at: 4-Sep-2007 23:44


doh... should have been : if value? 'gui [ show gui ] On 9/4/07, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote:

 [6/7] from: moliad:gma:il at: 4-Sep-2007 23:49


another way to look at this, is to build yourself a prefab config and default to it, this has the advantage of allowing your config file to be optional and to be extensible: ex: default: context [ visible?: true saved?: true setting1: none ] either config-file: attempt [ make object! load %my-app.cfg ] [ config: make default third config-file ][ print "CONFIG FILE ERROR" config: default ] -MAx On 9/1/07, Kai Peters <kpeters-otaksoft.com> wrote:

 [7/7] from: moliad::gmail::com at: 5-Sep-2007 0:11


and, in fact, be carefull how you use config files. you should be using construct within your attempt (instead of make object!)... its safer cause it wont evaluate the block itself. reducing the chance that the config is setting your values as funcs and sending values over tcp/ip ;-) -MAx On 9/4/07, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote: