How would you do this ?

82 views
Skip to first unread message

Craig Lindley

unread,
Oct 17, 2018, 4:05:21 PM10/17/18
to pforthdev
I am developing a UI button in pForth which has the following attributes:

\ Button data structure
:struct button
  ubyte type
  ubyte x
  ubyte y
  ubyte width
  ubyte height
  ubyte radius
  aptr text
  ubyte flags
  ushort buttonColor
  ushort borderColor
  ushort textColor
  aptr callback
;struct

which I have defined in this structure. I would now like to create a button creation word that would parse the button's name from the input stream and return a pointer to the button structure so I could get/set attributes using s@ and s!.

How would one code this?

Craig Lindley

unread,
Oct 17, 2018, 4:56:23 PM10/17/18
to pforthdev
Again I figured this out myself and it is really simple. I guess I was over thinking the problem.

: createButton ( name -- ) ( rt: -- btnAddr )
  button
;


  createButton but1
  createButton but2

  69 but1 s! type
  96 but2 s! type

: test
  ." but1: " but1 s@ type . cr
  ." but2: " but2 s@ type . cr
;


It works!

Phil Burk

unread,
Oct 24, 2018, 8:07:03 AM10/24/18
to pfor...@googlegroups.com
Hello Craig, sorry I did not reply earlier I have been on the road. I'm curious how you rendereing these buttons. Are you drawing them using on-screen ASCII terminal commands? Or did you write a graphics library for pforth?
Phil Burk

--
You received this message because you are subscribed to the Google Groups "pforthdev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pforthdev+...@googlegroups.com.
To post to this group, send email to pfor...@googlegroups.com.
Visit this group at https://groups.google.com/group/pforthdev.
For more options, visit https://groups.google.com/d/optout.

craig and heather

unread,
Oct 24, 2018, 10:10:37 AM10/24/18
to pfor...@googlegroups.com
Hi Phil,

Yes I have ported your pForth to the ESP32 and have written a graphics library for the ili9341 controller with touch. I also added WiFi networking, GPIO control, a NeoPixel driver and a bunch of other stuff as well. It is a pleasure to program in pForth with named parameters and local variables. I had completely written off Forth for the longest time because I wasn't very productive but with these changes I can code in Forth with the same productivity as in any of the other languages I use.
--
Craig Lindley / Heather Hubbard

New Recordings are here
Previous Recording are here
Personal Website is here

Home Phone: (719) 495-1873 (call us here first)
Craig's Cell: (719) 502-7925
Heather's Cell: (719) 571-0944

If you’re one in a million, there are now seven thousand people exactly like you.
Reply all
Reply to author
Forward
0 new messages