Re: [Factor-talk] How to pass a VarArg to a C function?

2015-04-09 Thread Mark Green
Hi,

Thanks very much for the helpful answer. I have used the function
definition from your file, and I can now get the file picker to appear, but
there is a problem when it exits:

: main ( -- )
  f f gtk_init
  "Hello" s>gs f GTK_FILE_CHOOSER_ACTION_OPEN "Cancel" s>gs
GTK_RESPONSE_CANCEL int  "Open" s>gs GTK_RESPONSE_ACCEPT int  f
  gtk_file_chooser_dialog_new dup gtk_dialog_run GTK_RESPONSE_ACCEPT =
  [ dup gtk_widget_destroy gtk_file_chooser_get_filename
alien>native-string ]
  [ gtk_widget_destroy f ] if . ;


The problem is that the value returned from gtk_dialog_run is never
GTK_RESPONSE_ACCEPT nor GTK_RESPONSE_CANCEL, instead it appears to be a
pointer value, but I cannot dereference it with "int deref" because it is
not wrapped in an alien type. Looking at your code in the file-picker
package, you did not seem to have this problem, so I wonder if this is an
oddity of Windows GTK?

(By the way, I noticed that the Windows multiplatform file-picker uses the
file picker from Windows 3.1! It might be nice to use one of the newer ones
:) )

Mark
--
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] How to pass a VarArg to a C function?

2015-04-07 Thread Mark Green
Hi,

I'm continuing my noodling with UIs using GTK but have hit a problem when
using GTK's dialog functions. They accept a final vararg parameter and I'm
not sure how to specify these when calling from Factor. To whit:

: s>gs ( string -- gstring ) utf8 string>alien ;

: main ( -- )
  f f gtk_init
  "Hello" s>gs f GTK_FILE_CHOOSER_ACTION_OPEN GTK_STOCK_CANCEL
 { GTK_RESPONSE_CANCEL GTK_STOCK_OPEN GTK_RESPONSE_ACCEPT f }
 gtk_file_chooser_dialog_new gtk_dialog_run drop ;

If I try this, I get a message saying "generic word underlying>> is not
defined for string 'gtk-cancel'". I presume that at some point,
GTK_RESPONSE_CANCEL is getting expanded into Factor string "gtk-cancel". I
then tried to fix this by applying [ s>gs ] map to the list, but this also
doesn't work as I get an error saying that s>gs cannot be applied to the
word GTK_RESPONSE_CANCEL. So it seems that s>gs needs to be performed
somewhere during the expansion process, but isn't being. Plus, I don't even
know if this is the right syntax for a varargs call. Is there a standard
for how to do this?

Mark
--
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Turning a string into a char-array for C

2015-03-02 Thread Mark Green
Hi,

Thanks for the note. However I am not writing the function declaration
myself, I'm using the ones provided in extra.gtk.ffi. Can I use encode to
roll my own into the char-array type?

Mark
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Turning a string into a char-array for C

2015-03-01 Thread Mark Green
Hi,

If I want to turn a string into a char-array type to use the GTK library
with it, is there a function to do this? I've tried  but that
seems to want to do a multiplication.

Mark
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Desperate UI help

2015-02-21 Thread Mark Green
Hi,

Most problems can render outside of their window if needed for a menu. For
example, try shrinking your web browser window vertically so that only one
line or so of the web page is visible, then right-clicking in the visible
space.

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Desperate UI help

2015-02-21 Thread Mark Green
Hi folks,

I'm really sorry to have to post about this again but I'm getting flak at
this point and having to consider pulling a project off Factor because of
the difficulties with the UI library.

Is there any way to print or trace the behavior of UI objects so that I can
see why a model is behaving improperly and failing to feed its value on
activation?

Is there any way to allow show-menus to break the boundaries of their
window, as pop-up windows generally can?

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] UI worlds and printing question

2015-01-17 Thread Mark Green
Hi,

Thanks. I hadn't considered that the UI was setting the input stream to
something else!

On the pop-ups - ok, fair enough, but is there then a good way to open a
popup that is not constrained to the borders of the parent window to get
around issue #1268?

(Actually, where is the code that opens the error list? I did have a look
but I had assumed it was : debugger-window but I now see I was wrong..)

Mark
--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] UI worlds and printing question

2015-01-15 Thread Mark Green
Hi folks,

Can I ask two further questions about UIs?

- I've been trying to reproduce something like the selection window that
appears in the listener when there is an error. I noticed that this window
can break the borders of the listener and that it is actually opened as a
new window rather than as a glass layer over the listener. I have worked
out how to create a similar dialog window but is it possible to choose the
location on the screen where the new dialog window is opened? Also, is
there a way to make it model in the sense that any click that is in the
application but not on the window will close it?

- Is there any way to prettyprint from UI code? I can use . but it doesn't
output anything. It would be helpful for debug tracing.

Thanks,
Mark.
--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Version of while that leaves pred's result on the stack?

2015-01-02 Thread Mark Green
Hi,

Sorry to post yet again! I've been trying to write something to read lines
from a file while ignoring comments, and have gotten this far:

: readln-skipcomments ( -- line )
[ { [ string? ] [ first CHAR: # = not ] [ ] } 1&& ] [ readln ] do while
;

The problem is that it seems that while consumes the result of running
pred, so this ends up not returning anything. If I put a dup into the last
entry in the 1&&, to leave an extra copy on the stack in case of success,
then I get a deep error complaining that the stack effect of the inputs of
1&&'s internal ifs are unbalanced. If I put the dup after the 1&& in the
while I get an error that pred is unbalanced. If I put it in the looped
quotation I get the error that the loop is not balanced by pred. Is there
any way I can do this?

Mark
--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Model activation sequence

2015-01-01 Thread Mark Green
Hi folks,

After my previous post about a model which could extract a part of a
complex structure inside another model, I had a go at it myself as follows:

TUPLE: partmodel < model master extractor updater ;

: partmodel-fetch ( partmodel -- )
dup [ master>> value>> ] [ extractor>> ] bi call( master -- part ) swap
set-model ;

: new-partmodel ( master extractor updater class -- partmodel )
f swap new-model swap >>updater swap >>extractor [ add-dependency ] [
swap >>master ] 2bi dup partmodel-fetch ;

M: partmodel model-changed
nip partmodel-fetch ;

M: partmodel update-model
dup master>> locked?>> [ "Warning: partmodel failing to update master"
. drop ] [
dup [ master>> value>> ] [ value>> ] [ updater>> ] tri call(
mastervalue newslavevalue -- )
master>> [ [ update-model ] [ notify-connections ] bi ]
with-locked-model
] if ;

:  ( master extractor updater -- partmodel ) partmodel
new-partmodel ;

:  ( master index -- partmodel )
[ '[ _ swap nth ] ] [ '[ _ rot set-nth ] ] bi  ;


Notice that I ended up having to roll my own notification inside
update-model because using set-model doesn't seem appropriate given that
the reference to the higher level structure will not change and most of the
functions for updating parts of complex structures act in place and pop the
old reference form the stack.

The problem however occurs when I create a  whose master is an
. In this case, even when I add it to a UI element, the  does
not seem to be activated and does not fetch its value. This seems odd as
the partmodel should have the arrow added to its dependency list in
new-partmodel before being activated itself. Am I doing something terribly
wrong?

Mark
--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Dealing with parts of a model

2014-12-30 Thread Mark Green
Hi,

I hope everyone had a good Christmas. I'm still struggling a bit with how
to create a UI that alters parts of a structure.

So far I can store the structure as a whole in the model slot of the
containing pane, and I can create arrow models for the individual controls
to refer to. The problem is writing changes back again, since the arrow
model does not propagate changes back across itself. I see there is a
double-ended arrow model in extra called , but it seems to depend
on the arrow operation being invertible which extraction of part of a
sequence (for example) is not. It is however mergable in that the data from
the lower level model could be re-incorporated into the higher level model
given knowledge of them both. Does anything support this?

Also, does  work correctly? When I try to create one, it seems
to come up blank and editable, even if the arrow model contains data and is
not writable.

Mark
--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Architecting a UI

2014-12-22 Thread Mark Green
Hi,

I'm having a bit of trouble working out how to create a UI that edits parts
of a tuple data structure.

First of all, what's the best way of keeping the tuple, plus other stateful
parts of the UI, available to edit? The options seem to be:

1 - Make a mega-tuple that contains the tuple plus the states of the UI and
leave it on the stack.
2 - Put the regular tuple and the state on the stack in some order, and
have everything carefully step around the parts of the stack storing state
it doesn't need.
3 - Put them all in global variables.

Then, there's the question of how to edit parts of it, as the choices seem
to be:

1 - Make models that are manually updated with parts of the tuple, and feed
them to the UI objects. Seems a bit ugly.
2 - Make arrow models that are linked to parts of the tuple. The problem is
that arrow models are unidirectional, although I suppose it would be
possible to create one that is not, assuming there is protection against
recursive dependancy loops in the models handler.

So is there a standard for how to represent and store the data model for a
UI?

Thanks and Happy Christmas,
Mark.
--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Some UI questions

2014-12-20 Thread Mark Green
Hi,

Thanks very much for the help. This is really interesting stuff. I am
actually using a grid-layout already, it's just that when I place a
checkbox in the grid, it is hard to the left of the assigned grid space -
would adding a border help?

Regarding drop-button, what I want to do is to create a "drop list box"
which shows a selected option, and clicking on it opens a menu of all the
possible options; clicking one of those changes the selected option. The
assoc is to store pairs of the value to display to the user and the value
to store in the internal variable (or to pass to the quotation - I'm not
entirely sure about connecting the data model to the UI yet, if it's best
done using  or using targetted commands or leaving stuff on the
stack...)

The whole code I'm doing is at http://github.com/hyphz/fr8x-editor if
you're interested in it, although it's probably still pretty beginner-grade
(although I have to give you huge thanks for the SYNTAX: code for chunks as
I was able to extend that to create writers as well as readers which saved
a mass of code)

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Some UI questions

2014-12-19 Thread Mark Green
Hi,

Sorry to bother you again *sheepish*

1 - Is it possible to have a UI element adjust its positioning within the
space it is allocated? For example, if a checkbox is allocated more space
than it needs is it possible to specify it should be centered inside the
space?

2 - Is it possible to create an  that can only enter numbers or
that can only enter a certain size of input?

3 - I have been trying to create a drop-down choice box. So far I have this:

:: show-drop-menu ( button assoc quot -- ) vertical 
[ button swap [ first ] [ second ] bi quot curry  f
track-add ] assoc each show-menu ; inline

:  ( value assoc quot -- gadget )
[ drop at* drop ] 2keep '[ _ _ show-drop-menu ]  ;

However when the object is clicked on I get a nonsensical error message
about "cannot load value into slot" which makes no sense since I'm not
doing that anywhere in that code. Can anyone tell me what's wrong?
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Multiple quotation reduce?

2014-12-18 Thread Mark Green
Hi,

Is there any version of reduce which accepts an array of values and an
array of quotations, and performs reduce but rather than calling the same
quotation every time, calls the quotation corresponding to the list
position of the value?

So that as
{ 1 2 3 } { } [ f ] reduce
is equivalent to
{ } 1 f 2 f 3 f

Thus
{ 1 2 3 } { } { [ f ] [ g ] [ h ] } multi-reduce
is equivalent to
{ } 1 f 2 g 3 h

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Data format macro

2014-12-15 Thread Mark Green
Thanks very much for your help and for the explanation. The confusion I had
wasn't with how to define a tuple but with how to integrate the code to do
that with your code - I'm only just getting the hang of combining results
using bi/tri/cleave and I couldn't figure out how to apply anything like
that when dealing with the "scan" words that are used incrementally and are
stateful so they can only be called once. When I'm done with work I'm
probably going to reverse engineer the code you wrote which I see seems to
have added the tuples via using an association list?? I'm not quite sure.

I'm also getting a bit worried about the UI aspect.. I notice there are
some UI words which seem to be undocumented like  but I wonder if
there is a way to display standard message windows or in particular a file
chooser. I know you mentioned that there is one under Cocoa but I haven't
found one under windows or a word that works on either platform (does
Factor have platform conditional compilation?)

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Data format macro

2014-12-14 Thread Mark Green
That is amazing and does actually make sense to me.. Thanks!  Can the
syntax expression define the tuple too? I see there is a compiler word for
that but I'm not sure how to fit it in.
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Fwd: Macros and unpacking bitstreams

2014-12-14 Thread Mark Green
Thanks very much for your help. I'm now getting into unpacking data
structures from the bitstreams, but this is getting me some horrible code,
to whit stuff like this:

TUPLE: scData creator type ver num name reverb-character reverb-prelpf
reverb-time reverb-delay reverb-predelay reverb-level
   reverb-selected chorus-prelpf chorus-feedback chorus-delay chorus-rate
chorus-depth chorus-sendrev chorus-senddelay
   chorus-level chorus-selected delay-prelpf delay-timecenter
delay-timeratioleft delay-timeratioright delay-levelcenter
   delay-levelleft delay-levelright delay-feedback delay-sendreverb
delay-level delay-selected masterbar-recall-register
   index-icon bassoon edited junk unknown ;

: parse-sc ( -- head ) test "SC" get-chunk first
  { [ 4 7 bsread-string ]   ! Creator
[ 4 7 bsread-string ]   ! Type
[ 4 7 bsread-string ]   ! Ver
[ 4 7 bsread-string ]   ! Num
[ 8 7 bsread-string ]   ! Name
[ 7 swap bsread ]   ! Reverb Character
[ 7 swap bsread ]   ! Reverb Prelpf
 ... And so on for a whole bunch of lines ...
[ 7 swap bsread ]   ! Bassoon
[ 7 swap bsread ]   ! Edited
[ 15 swap bsread ]  ! Dummy
[ 57 7 bsread-string ]  ! Unknown
  } cleave scData boa ;

Now, I know I could make this much shorter by not repeating the quotations
but that has the problem that I then lose the comments and easy
editability. But! I have dipped my toe into LISP and it would be rather
fantastic to have a macro so that I could write something like:

FORMAT: scData creator ascii 4 7 type ascii 4 7 ver ascii 4 7 num ascii 4 7
name ascii 8 7 reverb-character integer 8 1 ...

And have that create the tuple and function above. Of course, I have no
idea how to do that - I've tried playing with the MACRO: and SYNTAX:
statements but I don't know how SYNTAX: takes input and MACRO: seems to
work using quotations in a way I'm not really used to from LISP style - I'm
guessing I need a whole new world of understanding the parser to do this.
Any inspirations?

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Sorry, another request for advice..

2014-12-14 Thread Mark Green
That's very helpful, but the thing is that what I really want to do is to
pull a series of fields from the bitreader and store them in a tuple via
boa. Something like bitreader [ 4 7 bsread-string ] [ 8 7 bsread-string ]
tri boa . The problem is that to do that I need a version of bsread-string
that takes the bitreader argument as the deepest rather than the
shallowest, and I don't see any way of doing that (other than using locals)
because it's hard to reach down 3 steps on the stack. Is there any way of
doing this?

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Sorry, another request for advice..

2014-12-13 Thread Mark Green
If you want me to stop posting these just tell me so. I don't want to be a
pain.

Is there a good way to tidy this up to get rid of the large number of swaps?

Mark

: get-chunk ( alist id -- chunk )
swap at*
[ "Missing chunk type" throw-set-loading-error ] unless
0 swap nth  ;

: bsread-string ( count width bitreader -- string )
'[ _ _ bsread ] replicate ascii decode ;

: parse-sc ( -- head ) test "SC" get-chunk
  25 swap 7 swap bsread-string ;
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] File Chooser

2014-12-12 Thread Mark Green
Oh, sorry if I am asking too many questions but is there a way to start the
OS standard file chooser from a factor program?

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Code Check and UI request

2014-12-12 Thread Mark Green
Thanks. I've worked out a few of the basics of how bitstreams works but I'm
not sure about the whole thing.. I do have another bit of code that I'd be
very grateful if folks could look at and tell me if it could be done
better, because I'm really not used to this language at all!

Also, is there somewhere in the UI library the prefabs for the neat rounded
coloured buttons that the Factor UI uses?

Mark


USING: kernel locals accessors math sequences math.bitwise bitstreams
io.files io xml io.encodings.binary xml.traversal strings
  assocs math.parser combinators ;
FROM: io => read ;

IN: fr8x

TUPLE: chunkinfo
{ name string }
{ size integer }
{ count integer }
{ offset integer } ;

TUPLE: chunkdata name data ;

: get-header ( -- bin ) "\x8d" read-until drop ;

: chop-junk ( bin -- slice ) 4 tail-slice ;

: get-chunk-tags ( head -- vector ) children>> 1 swap nth children-tags ;

: get-int-attr ( attrs name -- int ) swap at* drop string>number ;

: parse-chunk-tag ( tag -- chunkspec )
[ name>> main>> ] keep
attrs>>
[ "size" get-int-attr ] [ "number" get-int-attr ] [ "offset"
get-int-attr ] tri
chunkinfo boa ;

: parse-chunk-tags ( vector -- chunks ) [ parse-chunk-tag ] map ;

: parse-header ( -- chunks ) get-header chop-junk bytes>xml get-chunk-tags
parse-chunk-tags ;

: load-chunk ( chunkinfo offset -- chunkdata )
  swap
  [ offset>> + seek-absolute seek-input ] keep
  [ name>> V{ } ] [ size>> ] [ count>> ] tri
  [ [ read suffix ] keep ] times
  drop chunkdata boa ;

: load-chunks ( chunkinfos -- chunkdatas ) tell-input [ load-chunk ] curry
map ;

: parse-set-file ( -- head ) parse-header load-chunks ;

: load-set-file ( fn --  head ) binary [ parse-set-file ] with-file-reader ;

: test ( -- head ) "FR-8X_SET_001.ST8" load-set-file ;
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Code check and UI request

2014-12-11 Thread Mark Green
Hi,

Wow, thanks very much for your help! I only just noticed that there is
already a bitstreams library, but is there some further documentation for
it somewhere? The online documentation only shows the prototypes and the
link to the -docs.factor file goes to a dead github page.

Mark
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Code check and UI request

2014-12-10 Thread Mark Green
Hi Folks,

I recently had a go at writing a Factor object to pull bitstrings of
arbitrary length from a bytearray. Since I'm still a bit of a newbie, could
you give any commentary on the coding or the style and how it could be
improved?

USING: kernel locals accessors math sequences math.bitwise ;

TUPLE: bitreader bytearray curpos curbit ;:  ( bytearray --
bitreader ) 0 0 bitreader boa ;
: advance ( reader -- reader ) 0 >>curbit [ 1 + ] change-curpos ;
: check-advance ( reader -- reader ) dup curbit>> 8 = [ advance ] when ;
:: readsinglevalue ( bits reader -- result ) reader curpos>> reader
bytearray>> nth
 reader curbit>> dup bits
1 - + swap bit-range
 reader [ bits + ]
change-curbit check-advance drop ;
: bitsleft ( reader -- result ) curbit>> 8 swap - ;

DEFER: readbits
:: readmultivalue ( bits reader -- result ) reader bitsleft :> bitsextra
bitsextra reader readsinglevalue
bits bitsextra - reader readbits
bitsextra shift + ;
:: readbits ( bits reader -- result ) reader curbit>> bits + 8 < [
bits reader readsinglevalue ] [ bits reader readmultivalue ] if ;

Also, is there any widget for the Factor UI that behaves like a
combo-box or list-box for entering a string?

Thanks very much,
Mark.
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Multiuser Deployment of Factor

2014-08-21 Thread Mark Green
Hi,

Thanks for your replies.

Regarding running individual instances of Factor, the problem is that here
(as at most Unis), the students' home directory is a network share. This
means that if they install their own Factor then it will be running over a
share which is rather slow.

I know about adding alternative work directories, but scaffold-work will
still target the work directory within the install path and trigger an
error.

I'll take a look at the suggested file.

Mark
--
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Multiuser Deployment of Factor

2014-08-19 Thread Mark Green
Hi,

I am considering introducing Factor to students as an example of a 
concatenative language, but I am having some problems with the way Factor is 
set up which make it very hard to deploy onto a Windows network such as the one 
we use.

1. Factor's default work directory is a subdirectory of its install directory 
which normally would not be writable for users. Although work directories can 
be added it seems that the default cannot be changed permanently. Is there a 
way to alter the default work directly? 

2. As Factor starts up it generates an encryption key and saves it to the All 
Users profile (I'd really like to know why it is doing this!). However it does 
not actually set the ACL to give all users access to the file, and if Factor is 
started by a user who cannot access this file it immediately halts. Is there a 
way to prevent this and why is Factor doing it anyway? 

Mark Green
m...@antelope.nildram.co.uk




--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Wiki Tutorial

2013-08-19 Thread Mark Green
Hi,

I tried to post part of my tutorial on the concatenative.org website, but
when I try to Edit the page I created, as soon as I click Save the editor
just throws away the text and goes back to the Edit window.

Mark
--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Wiki Tutorial

2013-08-18 Thread Mark Green
Hi Charles,

Thanks for your reply, I am aware of the docs online, I have been working
on writing a bit of an introduction to basic Factor (I plan to introduce it
to some programming students as an example of concatenative programming)
and was wondering if there was somewhere I could post it where it could
help and be expanded by myself and other people - I remember a post here
saying that a longer Factor tutorial was something that people were
interested in.

Mark


On Sun, Aug 18, 2013 at 12:44 AM, Mark Green wrote:

> Hi,
>
> Is there any Wiki where a Factor tutorial is being or could be built?
>
> Mark
>
--
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Wiki Tutorial

2013-08-17 Thread Mark Green
Hi,

Is there any Wiki where a Factor tutorial is being or could be built?

Mark
--
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Models for UI

2013-07-15 Thread Mark Green
Oops, managed my own fudge for this:

TUPLE: uiInt intModel strModel ;

M: uiInt model-changed strModel>> swap value>> number>string swap set-model
;

:  ( int -- uiInt ) uiInt new
  over  2dup add-connection >>intModel
  over number>string  >>strModel nip ;

: uiInt>> ( uiInt -- int ) intModel>> value>> ;
: >>uiInt ( int uiInt -- ) intModel>> set-model ;
: change-uiInt ( uiInt quot: ( int -- int ) -- ) swap intModel>> swap
change-model ; inline

Mark



On Mon, Jul 15, 2013 at 11:58 PM, Mark Green wrote:

> Hi,
>
> Sorry - one other question:
>
> If I have a numeric value that I want to put onto a UI, am I forced to
> store it in a model as a string? Or to have two models, one for the number
> and one for the string?
>
> Mark
>
>
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Models for UI

2013-07-15 Thread Mark Green
Hi,

Sorry - one other question:

If I have a numeric value that I want to put onto a UI, am I forced to
store it in a model as a string? Or to have two models, one for the number
and one for the string?

Mark
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Using find-by-class in html.parser.analyzer

2013-07-15 Thread Mark Green
Hi Alex,

Thanks very much for your reply. I think my issue might come from the fact
that find-by-class or its XML equivalent require the entire class string to
match which is technically not correct (an element can have several CSS
classes so it should be a "string contains as a whole word" type search,
not an exact match).  Is there any function that does a match of this time?
I expect it could be written up as a quotation.

Mark
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Using find-by-class in html.parser.analyzer

2013-07-14 Thread Mark Green
Hi,

Is there any documentation for find-by-class in html.parser.analyzer? I'm
not sure what it does. It doesn't seem to search for elements with a given
value in the class attribute and I'm not sure how it would return them
anyway (is it a filter?)

Thanks!
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Bresenham Linedraw: unbalanced conditionals

2013-07-03 Thread Mark Green
Thanks very much for your reply, Alex. I only have a few minutes to post but I 
can reply to some of these :)

4 - Is it permissible to include declarations of that type inside a word 
definition that's using the local variable syntax? I did want to put a 
description of the quotation into the stack effect but I wasn't sure if I could 
do it while at the same time giving the local variable holding the quotation a 
name. In your example, is the quotation variable named "quot"?

5 - It's the Bresenham linedraw code taken from the Wikipedia page; the final 
optimised version on that page.

Mark Green
m...@antelope.nildram.co.uk



--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Bresenham Linedraw: unbalanced conditionals

2013-07-03 Thread Mark Green
Hi,

Thanks very much for the previous help. Since then I've tried to refine the
Bresenham routine a bit and did actually get it working, but then decided
to indulge my functional-programmer urges and try to make it higher level.
Unfortunately, this hit another problem..

The idea of doline is that it takes two coordinates and a quotation, traces
a line between the coordinates, and calls the quotation at each point along
the line, leaving the x and y coordinates on the stack for it.  The
quotation is expected to leave two value on the stack itself: a "return"
value which is what doline should return if that's the end of the line, and
a "continue" value which specifies if the quotation wants to force the line
loop to halt at that point. The line loop may halt without being forced if
it has reached the destination coordinate, which is why the quotation is
always expected to push a return and continue value, rather than only
pushing a return if continue is f.

The problem, is after calling the quotation, if the quotation's continue
value is t (ie, it doesn't want to halt) and the line has not reached the
end, then an unused return value is left on the stack and I want to drop
it. Unfortunately it seems that there is no conditional function that will
allow me to drop a value based on a condition, as all of the conditions
seem to require that the stack is balanced on both sides of the
conditional. So this code refuses to compile because of the drop inside the
when block. Is there any way of doing this?

(Also, is the manual short circuit optimization of "and" into two whens
necessary or would the compiler have done it automatically? And, the code
is still.. um, rather C-like.. is there a way to style this better?)

Mark


! Create a new 10x10 grid
:  ( -- byte-array ) 100  ;

! Get address of cell x,y
: celladdress ( n n -- n ) 10 * + ;

! Get value of cell at x,y
: cellat ( byte-array n n -- n ) celladdress swap nth ;

! Do operation on cell at x,y
:: docell! ( array x y op -- ) x y celladdress array op change-nth ; inline

! Set value of cell at x,y
:: setcell! ( array x y val -- )  array x y [ drop val ] docell! ; inline

:: doLine ( ax ay bx by code -- codeout )
 bx ax - abs :> dx!
 by ay - abs :> dy!
 dx dy - :> err!
 t :> continue!
 ax :> cx!
 ay :> cy!
 [ continue ] [
cx cy code call continue!
cy by = [ cx bx = [ f continue! ] when ] when
[ continue ] [ drop
  err 2 *
  dup 0 dy - > [ err dy - err! cx dx sgn + cx! ] when
  dx < [ err dx + err! cy dy sgn + cy! ] when
] when
 ] while ; inline

:: los? ( map ax ay bx by -- bool ) ax ay bx by [| cx cy | map cx cy cellat
0 = dup ] doLine ;
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Bresenham Linedraw

2013-07-02 Thread Mark Green
Hi,

Is there a good standard implementation of Bresenham's linedraw? My silly
attempt, which is basically just a translation of a Processing program, is
below. I know it can be done better than this, I'm just not sure how - and
this program fails to compile with a rather bizarre error related to the
first unless statement which apparently takes something like 5 inputs!?

Mark


! Create a new 10x10 grid
: newgrid ( n n -- byte-array ) *  ;

! Get address of cell x,y
: celladdress ( n n -- n ) 10 * + ;

! Get value of cell at x,y
: cellat ( byte-array n n -- n ) celladdress swap nth ;

! Do operation on cell at x,y
:: docell ( array x y op -- ) x y celladdress array op change-nth ;

! Set value of cell at x,y
:: setcell ( array x y val -- )  array x y [ drop val ] docell ;

:: los ( map ax ay bx by -- bool )
 bx ax - abs :> dx!
 by ay - abs :> dy!
 dx! dy! - :> err!
 t :> continue!
 t :> result!
 ax ay
 [ continue! ] [
2dup cellat 0 = [ f :> continue! f :> result! ] unless
2dup by = swap bx = and [ f :> continue! t :> result! ] when
err 2 *
dup 0 dy! - > [ err! dy! - :> err! roll dx! sgn + -roll ] when
dx! < [ err! dx! + :> err! dy! sgn + ] when
 ] while
 result! ;
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk