Re: [Factor-talk] Conditionally execute words in .factor-rc

2016-05-29 Thread Martin Saurer
Hi John

 

I tried to do this using lookup-word earlier, but with no success.

 

The execute( word was exactly what I was looking for.

Now everything work as expected.

 

Thanks for putting me in the right direction.

 

Best

 

Martin

 

Von: John Benediktsson [mailto:mrj...@gmail.com] 
Gesendet: Dienstag, 24. Mai 2016 23:53
An: factor-talk@lists.sourceforge.net
Betreff: Re: [Factor-talk] Conditionally execute words in .factor-rc

 

Yes, a few different ways:

 

1) The entire file is parsed so if you have a word that is available in 0.98 
but not in 0.97, you either have to call it dynamically:

 

"vm-version" "system" lookup-word execute( -- string )

 

or

 

2) Make separate files for 0.97 and 0.98, unfortunately we don't have good 
version words prior to 0.98, but you could do something like this:

 

   "vm-version" "system" lookup-word [
execute( -- string ) ".factor-rc-" prepend run-file

] [

".factor-rc-0.97" run-file

] if*

 

 

 

On Tue, May 24, 2016 at 12:19 PM, Martin Saurer <martin.sau...@bluewin.ch> 
wrote:

Dear all,

Is there a way to conditionally execute words?

For example: In one image "fuel" is loaded. In another image "fuel" is not 
loaded.
Or: In Factor 0.98 there is a word "vm-version". In Factor 0.97 there is no 
such word.

Is it possible to write a .factor-rc startup file that handles different 
environments and/or
Factor versions?

In Python I'm doing this the following way:

if sys.version_info[0] == 2:
  from BaseHTTPServer import BaseHTTPRequestHandler
  from BaseHTTPServer import HTTPServer
else:
  from http.serverimport BaseHTTPRequestHandler
  from http.serverimport HTTPServer

Many thanks in advance.

Martin



--
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

 

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Conditionally execute words in .factor-rc

2016-05-24 Thread John Benediktsson
Yes, a few different ways:

1) The entire file is parsed so if you have a word that is available in
0.98 but not in 0.97, you either have to call it dynamically:

"vm-version" "system" lookup-word execute( -- string )

or

2) Make separate files for 0.97 and 0.98, unfortunately we don't have good
version words prior to 0.98, but you could do something like this:

   "vm-version" "system" lookup-word [
execute( -- string ) ".factor-rc-" prepend run-file
] [
".factor-rc-0.97" run-file
] if*



On Tue, May 24, 2016 at 12:19 PM, Martin Saurer 
wrote:

> Dear all,
>
> Is there a way to conditionally execute words?
>
> For example: In one image "fuel" is loaded. In another image "fuel" is not
> loaded.
> Or: In Factor 0.98 there is a word "vm-version". In Factor 0.97 there is
> no such word.
>
> Is it possible to write a .factor-rc startup file that handles different
> environments and/or
> Factor versions?
>
> In Python I'm doing this the following way:
>
> if sys.version_info[0] == 2:
>   from BaseHTTPServer import BaseHTTPRequestHandler
>   from BaseHTTPServer import HTTPServer
> else:
>   from http.serverimport BaseHTTPRequestHandler
>   from http.serverimport HTTPServer
>
> Many thanks in advance.
>
> Martin
>
>
>
>
> --
> Mobile security can be enabling, not merely restricting. Employees who
> bring their own devices (BYOD) to work are irked by the imposition of MDM
> restrictions. Mobile Device Manager Plus allows you to control only the
> apps on BYO-devices by containerizing them, leaving personal data
> untouched!
> https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Conditionally execute words in .factor-rc

2016-05-24 Thread Martin Saurer
Dear all,

Is there a way to conditionally execute words?

For example: In one image "fuel" is loaded. In another image "fuel" is not 
loaded.
Or: In Factor 0.98 there is a word "vm-version". In Factor 0.97 there is no 
such word.

Is it possible to write a .factor-rc startup file that handles different 
environments and/or
Factor versions?

In Python I'm doing this the following way:

if sys.version_info[0] == 2:
  from BaseHTTPServer import BaseHTTPRequestHandler
  from BaseHTTPServer import HTTPServer
else:
  from http.serverimport BaseHTTPRequestHandler
  from http.serverimport HTTPServer

Many thanks in advance.

Martin



--
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk