├── CFExcel1.xls ├── CFExcel1.zip ├── How to build a primitive in CFE.pptx ├── Creole forth for excel - Forth Day.pptx ├── .gitattributes ├── .gitignore └── README.md /CFExcel1.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiluser/Creole-Forth-For-Excel/HEAD/CFExcel1.xls -------------------------------------------------------------------------------- /CFExcel1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiluser/Creole-Forth-For-Excel/HEAD/CFExcel1.zip -------------------------------------------------------------------------------- /How to build a primitive in CFE.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiluser/Creole-Forth-For-Excel/HEAD/How to build a primitive in CFE.pptx -------------------------------------------------------------------------------- /Creole forth for excel - Forth Day.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiluser/Creole-Forth-For-Excel/HEAD/Creole forth for excel - Forth Day.pptx -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Creole Forth for Excel 2 | ---------------------- 3 | 4 | Intro 5 | ----- 6 | 7 | This is a scripting language built on top of VBA for Excel based on the Forth language. 8 | The design and architecture of the language is similar to a previous language that worked 9 | as a Delphi/Lazarus component. 10 | 11 | How to run 12 | ---------- 13 | 14 | 1. Open up the CFExcel1.xls workbook. If you do not have Excel, there's a standalone version 15 | in the same folder CFExcel1.exe that can be used instead. 16 | 17 | 2. Make sure macros are enabled. 18 | 19 | 3. Type the shortcut CTRL-Shift-C. Two sheets will appear that weren't there before : one with 20 | a GlobalDS label and the other with a Dictionary label. 21 | 22 | 4. Go to the GlobalDS sheet. 23 | 24 | 5. In the cell next to the label 'Input Area', enter two words: HELLO WORLD. 25 | 26 | 6. Hit the submit button. 27 | 28 | 7. Two dialog boxes will pop up : the first says "Hello" and the second says "World". 29 | 30 | Compiling programs 31 | ------------------ 32 | 33 | Like other Forths, Creole has a colon compiler. Below are two example programs: 34 | 35 | : SQR DUP Nx ; 36 | 37 | : TESTBU BEGIN 1 N+ DUP 10 GT UNTIL ; 38 | 39 | If you paste these programs into the Input Area and hit submit, you will see their entry into 40 | the dictionary. To execute, put the following in the input area 41 | 42 | 2 SQR 43 | 44 | The above will place 2 on the stack, duplicate itself, and then multiply the two operands, 45 | leaving 4 on the stack. 46 | 47 | 48 | TOGGLESU 1 TESTBU TOGGLESU 49 | 50 | The TOGGLESU command toggles screen updating (turns it off if it's on and vice versa) 51 | and should be used whenever there's a word with a looping construct (it's very slow otherwise). 52 | 1 TESTBU puts the number 1 on the stack, and adds it to itself until it goes over the limit 53 | specified in the definition (10). 54 | 55 | Some questions 56 | -------------- 57 | 58 | Q: What is Forth? 59 | 60 | Forth is a stack-oriented language primarily known for programming hardware and embedded systems. It's 61 | distinguished by its simple postfix syntax, passing of parameters via a stack, and miniscule size and 62 | use of resources. 63 | 64 | A: How does Creole work? 65 | 66 | 1. A set of space-delimited values (words) is placed in an input-cell. 67 | 2. One by one, they're looked up in a dictionary. 68 | 3. If found, they're executed. 69 | 4. If not, they're pushed onto the data stack. 70 | 71 | Q: What version of Excel should I be using? 72 | 73 | A: It should be backward compatibile to version 2003. 74 | 75 | Q: What if I don't have Excel? 76 | 77 | A: There's a version of available compiled to an executable using XLtoEXE (a free tool) in the same 78 | folder as the spreadsheet. 79 | 80 | Q: Does it work with OpenOffice/LibreOffice? 81 | 82 | A: No, at least not yet. It seems likely that a separate version would have to 83 | be developed to work with them. 84 | 85 | 86 | Q: The programs and examples given seem awfully simple. Can't it do more? 87 | 88 | A: Perhaps, but it's already demonstrated one of the ways you can improve and extend the Creole Forth environment. 89 | 90 | There are several ways to extend the language but we'll mention two for starters: 91 | 92 | 1. By creating additional "primitives". A primitive consists of a VBA class method that is defined in one of the class modules 93 | attached to the spreadsheet. It must then be introduced into the Dictionary page via the BuildPrimitive method. 94 | 95 | 2. By adding high-level definitions. This is generally done through the colon compiler. Its job is to compile assemblages 96 | of previously defined "words" or definitions. These behave as extensions to the language and are functionally indistinguishable 97 | from lower level (primitive definitions). 98 | 99 | List of shortcuts and commands 100 | ------------------------------ 101 | 1. Ctrl-Shift-C : Sets up default Forth Bundle, which consists of a GlobalDS page and a Dictionary page. 102 | Most of the time, you're only going to need one bundle. 103 | 104 | 2. Ctrl-Shift-R : Removes default Forth Bundle. 105 | 106 | 3. Push button : Put a value in the Scratch cell, and press the Push button. The value will be placed on 107 | top of the DataStack. 108 | 109 | 4. Submit button : Submits code in the InputAea. 110 | 111 | 5. Clean up stacks button: Push it and it will empty the DataStack, ReturnStack, and ParsedInput. 112 | 113 | Things to watch out for, especially for experienced Forth programmers 114 | --------------------------------------------------------------------- 115 | 116 | 1. Dates - Excel tries to convert anything it can into a date and turning off this feature is very difficult. I would avoid putting anything into the input or stacks that can be converted into one. 117 | 118 | 2. Check the dictionary to see if any of the common primitives have been renamed. 119 | 120 | 3. N+ replaces + because Excel will interpret a cell with a leading + as a formula. Same is true for N-. 121 | 122 | 123 | 4. * has become Nx due to trouble with the lookup process with *. 124 | 125 | 5. Boolean comparison operators such as < , <=, >, =, etc are now LT, LE, GT, EQ, etc. 126 | 127 | 6. Be careful about deleting any named ranges on the worksheets - they're the key to everything working. You should use the push button to push items on the stack, don't just do it manually. 128 | 129 | 7. If something gets screwed up manually, the Ctrl-Shift-R/Ctrl-Shift-C will bring everything to its previous state. I generally prefer it now to using FORGET, although that's available. 130 | 131 | 132 | 133 | Changes by date 134 | --------------- 135 | 12/17/2016 136 | 1. Added the AppSpec/AppSpecMain modules to ease building of new primitives for the user and made APPSPEC the current default vocabulary. 137 | 138 | 2. Added "How to build primitives in creole forth for excel" PowerPoint presentation. 139 | 140 | 3. Added a TutorialCode class module. It has examples from the presentation above 141 | to paste into the AppSpec module and isn't meant to be used directly. 142 | 143 | 4. Added list compiler { } which allows multiple arguments to be pushed onto the stack 144 | and occupy one cell. 145 | 146 | 5. Set up the ExecForthWords sub to allow execution of CFE words in a string passed as a parameter. 147 | 148 | 12/07/2016 149 | 150 | 1. Added Forth Day 2016 PowerPoint presentation. 151 | 152 | 08/29/2016 153 | 154 | 1. Updated README.md file with "Things to watch out for" and "Changes by date". 155 | 156 | 2. Made some minor formatting changes to README.md. 157 | 158 | 8/28/2016 159 | 160 | 1. For those who don't have Excel, there's a version compiled into and exe using XLToEXE, a free tool. It's in the repository as a zip file 161 | and just has to be unzipped an run (no instalation required). It appears to work the same as the regular spreadsheet and you can even see 162 | the source code of the project. 163 | 164 | 2. There's a README.md file now. It's intended to replace the quick_intro_cs.txt file. 165 | 166 | 08/26/2016 167 | 168 | 1. Toggling of screen updating in rebuild (is now many times faster) 169 | 170 | 2. Addition of RunCommand sub. It allows features such as compiling and running code from an arbitrarily located cell. 171 | 172 | 3. CONSTANT and VARIABLE are now a default part of the dictionary (defined as high-level definitions). 173 | 174 | 4. Fixed DoDoes so DOES> works correctly when called from inside a colon definition. Before is only worked right when 175 | the interpreter handled it. 176 | 177 | 5. DEPTH fixed. 178 | 179 | 6. Empty stacks button. Removes junk from the places they're most likely to accumulate and cause trouble. Specifically 180 | the Data Stack, the Return Stack, and the Parsed Input. 181 | 182 | 7. Added the TOGGLESU primitive. Allows alternatively turning off screen updates, and then turning back on. Great to use 183 | in looping statements, which are slow otherwise. 184 | 185 | 8. TOGGLESHOW primitive. This allows alternately hiding and showing the code sheets. Right now the GlobalDS and Dictionary 186 | pages are there, but others could be added at the discretion of the developer. 187 | 188 | 9. Changed NOW to pop up a message box instead of pushing a value onto the stack. I didn't like its tendency to change formatting everywhere it 189 | touched. 190 | 191 | 10. Set limit of ForthBundleCount to 4 - it's now a property of the ForthBundleParamSet. 192 | 193 | 08/07/2016 194 | Initial commit. 195 | --------------------------------------------------------------------------------