Acorn Arcade forums: Programming: [BASIC] Advice to code an editable matrix grid
|
[BASIC] Advice to code an editable matrix grid |
|
fvanzeveren (20:18 17/12/2013) sa_scott (09:53 18/12/2013) Zarchos (11:30 18/12/2013) arawnsley (17:09 18/12/2013) arawnsley (12:48 19/12/2013) MEmerton (15:24 20/12/2013) fvanzeveren (18:06 21/12/2013) arawnsley (19:55 21/12/2013)
|
|
François Vanzeveren |
Message #122886, posted by fvanzeveren at 20:18, 17/12/2013 |
Member
Posts: 2
|
Hello all
I am a "continental" newcomer to riscos (I discovered it beginning of this year on RaspberryPi) and since then went through most of the book "Beginner's Guide to WIMP Programming". I have started to develop a WIMP application and reached the point where I can handle both "auto redraw" and non "auto redraw" windows", using fonts, playing with datablocks, etc...
But now, I would like to have a window presenting a editable grid matrix like the one found in spreadsheet programs. The grid matrix will be used to present data as numbers and to enter data as numbers...
But this is currently beyound my BASIC capabilities, so I am looking some advices here, if possible...
Thank you for your help.
François |
|
[ Log in to reply ] |
|
Stephen Scott |
Message #122887, posted by sa_scott at 09:53, 18/12/2013, in reply to message #122886 |
Member
Posts: 73
|
Hi there,
Pages like this may help you:
http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter14.html
You basically need a two dimensional array to hold your values.
You may need to have some dynamic property for tabbing from one 'cell' to another. There is a WIMP flag for that, but can't recall what that would be.
Hope this paves the way to helping you.
Good luck!
Steve |
|
[ Log in to reply ] |
|
Xavier Louis Tardy |
Message #122888, posted by Zarchos at 11:30, 18/12/2013, in reply to message #122886 |
Member
Posts: 47
|
Salut.
Tu auras peut-être de l'aide ici, mais le mieux c'est d'aller sur 'google groups acorn programmer' https://groups.google.com/forum/#!forum/comp.sys.acorn.programmer là tu toucheras plus de personnes capables de t'aider.
Bye, Xavier.
[Edited by Zarchos at 11:33, 18/12/2013] |
|
[ Log in to reply ] |
|
Andrew Rawnsley |
Message #122889, posted by arawnsley at 17:09, 18/12/2013, in reply to message #122888 |
R-Comp chap
Posts: 598
|
I suspect the easiest way, but not best performing, would be a two-dimensional array of integer icon numbers - DIM grid%(x,y) I think. That would hold the icon numbers created via a loop.
Note, my BASIC is very rusty - almost all my coding is C.
You could create a basic icon "template" in your window via a template editor, and essentially "copy" it each time, storing the resulting icon number in grid%
This would allow you to reference the icons by x,y notation, and receive back the icon number.
When creating icons, simply increase x/y co-ordinates each time round a loop. Then store the resulting number in grid%(x,y).
NOTE - using icons isn't particularly efficient for this, but if you're only showing a medium amount of content, using icons gives you a number of benefits (auto keyboard handling, borders, writeable capability, "mouse-over" pointer change and so on).
The more complex approach is to draw your own grid etc, which would give you maximum flexibility/performance, but I think would take much longer to develop. |
|
[ Log in to reply ] |
|
Andrew Rawnsley |
Message #122890, posted by arawnsley at 12:48, 19/12/2013, in reply to message #122889 |
R-Comp chap
Posts: 598
|
Edit - I appreciate this method is foul from an elegance perspective (DIM'd array is not sensible for a variable size data set), but equally this is about the easiest way to get started, and BASIC isn't ideal for doing linked lists of structs. |
|
[ Log in to reply ] |
|
Michael Emerton |
Message #122891, posted by MEmerton at 15:24, 20/12/2013, in reply to message #122890 |
Member
Posts: 75
|
Well unless you use Basalt! Then you can re-DIM the array. |
|
[ Log in to reply ] |
|
François Vanzeveren |
Message #122893, posted by fvanzeveren at 18:06, 21/12/2013, in reply to message #122886 |
Member
Posts: 2
|
Hi all
Thank you for your replies.
I am considering to use two data blocks: one to contain the data (floating point numbers coded on 8 bytes) and the second for the cells definitions (x and y positions, width and height and a pointer to the data)
I should look at Basalt, if I understand...
Thanks
François |
|
[ Log in to reply ] |
|
Andrew Rawnsley |
Message #122894, posted by arawnsley at 19:55, 21/12/2013, in reply to message #122893 |
R-Comp chap
Posts: 598
|
I'd be a touch cautious of using 3rd party BASIC extension modules, as you'd need to supply them with the software, and that rather defeats the purpose of using the (always maintained) built-in BASIC.
The single biggest attraction of BBC BASIC as found in RISC OS is that the interpreter is a core part of the OS which is updated for each new hardware port. This means that pure BASIC apps work regardless of hardware platform with no recompile needed. Once you add 3rd party dependencies, your code is always subject to the whims of whoever maintains the dependency. |
|
[ Log in to reply ] |
|
|
Acorn Arcade forums: Programming: [BASIC] Advice to code an editable matrix grid |