Address book by Nick Modified
Based on Nicks tutorials I have been able to write a complete app. Also, I am not a professional programmer, I am just a hobbyist, not really trained in programming. Rebol is fascinating in that way, cause, it has allowed me to achieve so much in so little time. I have tried modern BASICs and python earlier. Here is Nicks code heavily modified: R E B O L [title: "Address Book by Nick modified by AnikaSOFT 2024"] write/append %contacts "" contacts: load %contacts save-contacts: func [] [ save %contacts contacts ] remove-contact: func [rno] [ count: 1 foreach [i n a p c] contacts [ if i = rno [ remove/part at contacts count 5 break ] count: count + 5 ] ] extract-names: func [] [ names: copy [] foreach [id name address phone comments] contacts [append names rejoin [id " " name]] copy names ] extract-rnums: func [] [ extract-names rnums: copy [] foreach name names [ append rnums to-integer (first parse name " ") ] sort rnums copy rnums ] clear-fields: func [] [ foreach i [fldRec fldName fldPhone fldAddress fldComments] [ set-face get i "" ] ] view mainWin: layout [ backcolor mint h1 "Address Book" yellow box 700x3 yellow across left-pane: panel [ below h2 "Data list" black bold lst: text-list data extract-names [ fldRec/text: copy first parse lst/picked/1 " " fldName/text: copy pick contacts (1 + index? find contacts fldRec/text) fldPhone/text: copy pick contacts (2 + index? find contacts fldRec/text) fldAddress/text: copy pick contacts (3 + index? find contacts fldRec/text) fldComments/text: copy pick contacts (4 + index? find contacts fldRec/text) show mainWin ] changes: text "" yellow bold ] box 3x400 yellow right-pane: panel [ across h2 "Details" black bold return text "No:" fldRec: field return text "Name:" fldName: field return text "Address:" fldAddress: field return text "Phone:" fldPhone: field return text "Comments:" fldComments: area return across btn "New" [ clear-fields if empty? extract-rnums [ fldRec/text: "1" show fldRec exit ] fldRec/text: to-string (1 + last extract-rnums) show fldRec ] btn "Add / Edit" [ if fldName/text = "" [ alert "Empty name not allowed" exit ] if fldRec/text = "" [ alert "Record number empty" exit ] remove-contact copy fldRec/text append contacts reduce [copy fldRec/text copy fldName/text copy fldAddress/text copy fldPhone/text copy fldComments/text] save-contacts lst/data: extract-names lst/update show lst clear-fields ] btn "Remove" [ if fldRec/text = "" [ alert "Record number empty" exit ] if request "Do you really want to delete the record" [ remove-contact copy fldRec/text save-contacts lst/data: extract-names lst/update show lst clear-fields ] ] btn "Search" [ field-to-search: request-list "field:" [1 2 3 4 5] if field-to-search = none [exit] text-to-search: request-text if text-to-search = none [exit] found-values: copy [] foreach [i n a p c] contacts [ reduced-values: reduce [i n a p c] reduced-values: pick reduced-values field-to-search found-value: find reduced-values text-to-search if found-value [ append found-values rejoin [i " " n] ] ] if empty? found-values [ alert "not found" exit] temp: request-list "" found-values attempt[ fldRec/text: copy first parse temp " " fldName/text: copy pick contacts (1 + index? find contacts fldRec/text) fldPhone/text: copy pick contacts (2 + index? find contacts fldRec/text) fldAddress/text: copy pick contacts (3 + index? find contacts fldRec/text) fldComments/text: copy pick contacts (4 + index? find contacts fldRec/text) show mainWin ] ] ;btn "Save" [save %contacts contacts] btn "Raw" [editor %contacts] btn "Cancel / Clear" [ clear-fields ] return btn "Sort Ascending" [ sort/skip contacts 5 lst/data: extract-names show lst ] btn "Sort Descending" [ sort/skip/reverse contacts 5 lst/data: extract-names show lst ] return ] ] Things I have been able to achieve: 1. Heavily edited Nicks tutorial code 2. to have a data list 3. to have record numbers - so relational database can be created What I need help with? How to arrange the fields to be aligned with each other ? How to have a scroller for the area field? Suppose my record has many many fields, How to use view/new to add sub parts of my record? How to make relational database using the same code?
posted by: neuropsych 29-Aug-2024/11:05:40-7:00
There was a book called Rebol: The official guide maybe a quarter century or so ago. I still have it in the garage in a bin :) If I remember correctly, that one covered the most of any published book, about building what would be considered a 'database' system with Rebol. I devoured that book when it first came out, because Rebol was a fantastic tool in its day - there was nothing else quite like it. Maybe look at that if you really want to build a database system with Rebol. But... These days, large ecosystems surrounding other languages provide endless libraries and tools that eliminate work and make connectivity and compatibility possible ways that have left Rebol in the dust (especially after the Rebol company stopped doing business around 2012). Rebol is beautifully engineered tool which is certainly still cool to learn, and potentially useful for isolated in-house projects, but it's severely limited compared to other tools in the modern landscape. And none of the AIs write Rebol code very well, which is a serious handicap compared to other languages - any benefit that Rebol had in terms of reduced boilerplate code, graceful composability, etc., is outweighed 10x-1000x by AI code generation, for projects that most people might expect to complete these days with Rebol. There are still graceful dialects being written and beautifully engineered tools being created - the UI dialect in SQLPage is ridiculously productive, and learning SQL for database work is certainly an essential skill if you ever want to be able to communicate and collaborate with other software developers, or others who work in development-adjacent fields. My two cents is to take the general knowledge you've gained by learning some Rebol, and learn how the same sorts of thinking is materialized in other languages. Tools like the Python Anvil framework can get you started making a seriously productive transition within a few weeks. My tutorial at https://pythonanvil.com will get you going on the path to accomplishing more than you ever could with Rebol, and you'll see that all the basic concepts you've implemented with Rebol (using variables, data structures, conditional evaluations, loops, functions, etc.), have easy-to-learn corollaries in basic Python - without as many *edge cases* to deal with. I think where most people get stuck with learning Python or other languages is that there tends to be a seemingly endless road ahead that requires learning about a massive landscape of tools which are hard to make coalesce into a practical, useable toolkit that can be applied directly to building software in simple ways. And often, learning Python or almost any other language eventually leads into having to invest a few additional years learning all about HTML/CSS/JavaScript front-end options - and all of that can make it seem like the bleeding time and energy will never come to an end. Even with the help of popular frameworks, the work load can seem like there's a never-ending mountain to climb, even in the friendly Python ecosystem. The Anvil tutorial will get you past that, directly into building full stack applications within your first hour, and then you'll be prepared to use and integrate all the tools in those massive Python and JS ecosystems, pretty easily, and as needed to improve your own capabilities. You could also try my tutorial at https://streamlitpython.com (although I'd recommend Anvil over Streamlit, without reservation). It's really very easy to make the switch between languages, if you have the right perspective and tools about how to put them to productive use right away, and becoming comfortable as a polyglot is a standard expectation to complete real work as a developer (to collaborate with others, and to integrate with common systems in common ways - and also to make use of the outrageously productive potential of AI code generation). If Anvil and Python rub you the wrong way, after a week or two of checking it out, give SQLPage a try. My tutorial at https://learnsqlpage.com will get you doing many of the same things you saw in the Rebol tutorials. And you can't go wrong learning SQL, especially if your interest is in databases. The ergonomics and ethos of SQLPage is so reminiscent of Rebol, to me - although I'd still recommend starting with the Anvil tutorial as a base to move on from. Learn Anvil, then perhaps learn SQLAlchemy within Anvil, then take SQLAlchemy out of Anvil and learn it in Flask, along with some basics about building UIs with Bootstrap. That's a really nice learning path, and you can make a comfortable transition from Rebol code structures to Python, in Anvil, within a few weeks. You do *not have to learn much Python to really begin using Anvil to do things that would be very difficult in Rebol - and you'll be able to deliver apps to virtually every kind of modern device (iOS, Android, Chromebook, Window, Mac, Linux, Raspberry Pi, etc.), which could never use your Rebol code. The scope and capability of the Python and JS ecosystems are hard to beat, and you can easily wade into them as needed - Anvil's structure makes that very easy to accomplish if you have no other background. Alternatively, SQLPage can help do the same, if you want to learn SQL. Start with it, learn to build useful full-stack CRUD apps without needing any other tools, then begin to connect with some simple Python scripts and/or Flask API endpoints on the back end, and build some simple HTML/CSS/JS/Bootstrap front end components to extend the UI capabilities in SQLPage. That's another really good learning path that will provide you with actually useful software building capabilities, right from the start, and keep you going productively in a way that won't box you in, or leave you diving down deep rabbit holes of impossibility as your needs expand. That's just my 2 cents, but it comes after 40+ years of writing code, and lots of success using many language tools, frameworks, and ecosystems to build hundreds of projects that are used in production, in a really wide variety of environments. At least give Anvil or SQLPage a try for a few weeks, it's worth it :)
posted by: Nick 29-Aug-2024/16:34:48-7:00
Honestly, I'd focus on getting the broadest exposure to the greatest number of tools, because over the next year or so AI is going to reduce the need for humans to write lines of code, and shift the focus more towards understanding how to connect parts to fulfill broader engineering goals. We're actually already there, and if you have a clear enough understanding of how things work and what to ask for, you have to *write very little code* manually. The barrier to entry doing that is going to continue to lower as AI models are given more agency in working with tools. Focusing on knowing as much as possible about as many ecosystems, with some deeper skill in the most used ecosystems like Python, HTML/CSS/JS, Java, C, etc., and all the tools that are used in those ecosystems, such as databases, build tools, compilers, etc. will give you the most bang for you buck going forward.
posted by: Nick 29-Aug-2024/20:07:29-7:00
One thing you may want to try is to take an example from the SQLPage tutorial and ask GPT, Claude, or another AI to make some changes you'd like to implement. You can also ask for explanations of exactly how any code works, interact with the AI to clarify how changes work, etc. (and typically any code that gets generated will automatically be commented by default)
posted by: Nick 30-Aug-2024/13:17:32-7:00
If you're interested in seeing how you can interact with GPT to create the working code for a real project, entirely from the ground up, see ths case study: https://com-pute.com/nick/brython-tutorial-and-GPT-case-study.txt
posted by: Nick 30-Aug-2024/13:44:39-7:00
|