CHANGES TO SOURCE CODE D4 DEFINITION <./d4.doc> The syntax of expressions is very simple:- E::= + | + E | E + E +::= F | S | U Function or operator F::= Primitive function (+ - * % Etc.) S System function ( #window, #files, #edit, Etc.). U User defined function. D::= N | T Data N Numeric N Numeric Matrix or Vector T Text Any array of bytes E::= +E Monadic operator E::= E+E Dyadic operator E::= (E) Priority of evaluation E::= E[E] Indexing. E::= I<-E | I[E] <- E Assignment. I::= Identifier. An identifier consists of a sequence of upper case letters, digits, the underscore (_), dollar sign ($), and dot (.). Any identifier must start with either a letter, dollar, or underscore. The use of identifiers allows the combination of various data types without the overhead of creating files. These named variables are used in cut and paste operations. All this seems very good, but it does not work yet. Only one level of parentheses is supported. Also the system runs out of memory too often on PCs. This means rewriting the expression evaluator. That is more or less done. It would be interesting to add postfix and prefix operations on L-values as in c. A++, ++A, A[X]++ and ++A[X]. Also the system names can start with a "$" as well as "#". Try to get thai with 60 lines, or possibly 30 lines with 8*16 This means using the DOS interrupt correctly. VGA_FONT changed. Also screen output changed to DOS interrupts instead of 'putch()' in C library. The editor works with 34 lines or more now. For thai, it just means getting the font, and writing some more editing routines. Z<- #alpha TABLE could have new lines, to add to existing capability. Extra rows stand for position above or below. Also the inverse video in the menu function needs to extend over three lines for thai. This means extensive use of the thai stacking routine. Another question is the combination of french accented forms with arabic. After all, french-arabic is a common North African combination. Thai needs a new font. Maybe try to get this from ftp. Thai also needs additional logic for input routine. Use 3 lines as usual. All of this needs to be done for DOS, and UNIX with a virtual screen. Eliminate _ctype and replace with gtype.h 256 bytes bit significant, test for digits etc. Mouse support. Use #zgets as interface. Go board, and font editor should work. Problem with driver for this particular computer. Paco tried a DELL mouse, but the connector was not suitable. Editor needs find and replace function, with correct handling for reverse orientation. This change gives opportunity to introduce remote control editing, where any command string involving complicated wild card expressions (regular expressions) may be applied to a file image. Only a small subset of commands will be allowed: maybe . and * as single character and string matches, and the use of the & symbol for substitutions. A command such as |*|&.o\ncc &.c -c -o /local/obj/&.o| could work to build makefile instructions from a list of names. Find and replace still not good. FREQUENCY COUNT FUNCTIONS Count the distinct words in a symbol stream. This should be an additive function in a sense. C(s1, s2) = C(s1) + C(s2) C is a vector in the space W. The basis of W is all the words which could be taken from S. For most texts, C can be expected to be in V < W. V is much smaller than W. Some words are very infrequent. For thai and amharic this would be convenient. The font could be cached with the most frequent words or syllables being set. Some computers did use special treatment for certain ascii values: look up the font, before display. Handle counts > 32000 This means arithmetic on more than 16-bits. Small integers are OK for smaller databases, but whole countries require figures in millions. Translation of the World Bank data into Amharic, or Farsee is the objective. Getting the world Bank figures in ASCII requires the handling and formatting of small numbers. These numbers can be 'reverse engineered' into a tabular form by knowing the statistics of columns. Many zeros mixture of N/A or reports. 0 < x < 100 => percent. Range A < x < B a statistic. Millions people, dollars, animals, diseases. Billions hyperinflation, micro-organisms, science figures. Small numbers rare diseases, collectors items. The system requires global operations: +,-,*,/,=. Also compare, search and sort. Use a very simple minded format statement. V<- "total #######" z X This is inconvenient to write in programs, but very easy to read from 'template' text. The format routine matches text to to marked places. The mark is a character that appears rarely. It's value as a character can be set by means of an environment variable (or #poke for convenience). HARD DISK FUNCTIONS (1995) R<- #disk 0, D R<- #disk 1, D status of disk D DATA<- #disk 2, D, HEAD, TRACK, SECTOR, CNT Read CNT sectors of data. R <- DATA #disk 3, D, HEAD, TRACK, SECTOR, CNT Write DATA. CNT must be the corresponding number of sectors. /* rather dangerous routines to test */ #define DSK_SET 0 #define DSK_STATUS 1 #define DSK_READ 2 #define DSK_WRITE 3 int biosdisk(int cmd, drive, head, track, sector, nsects, char* buffer); INT 13 - DISK - RESET DISK SYSTEM AH = 00h DL = drive. Return: AH = status INT 13 - DISK - GET STATUS OF LAST OPERATION AH = 01h DL = drive AH = previous operation INT 13 - DISK - READ SECTOR(S) INTO MEMORY AH = 02h AL = number of sectors to read (must be nonzero) CH = low eight bits of cylinder number CL = sector number 1-63 (bits 0-5) high two bits of cylinder (bits 6-7, hard disk only) DH = head number DL = drive number (bit 7 set for hard disk) ES:BX -> data buffer AH = status (see #0120) AL = number of sectors transferred INT 13 - DISK - WRITE DISK SECTOR(S) AH = 03H AL = number of sectors to write (must be nonzero) CH = low eight bits of cylinder number CL = sector number 1-63 (bits 0-5) high two bits of cylinder (bits 6-7, hard disk only) DH = head number DL = drive number (bit 7 set for hard disk) ES:BX -> data buffer AH = status (see #0120) AL = number of sectors transferred */ #int 33h MOUSE1;X AA: X<-5 0 #int 51 ->(0=X[1])/AA | number of times button pressed since last call X | gives 1 1, X,Y%2 ->AA Test button 1. This works well in windows. NEW STARTUP VARIABLE The definition i=anything in the startup line will suppress CTRL-C checking to allow correct reading of standard input from a file. This is an untested feature, and the name 'i' may change to 'b' for batch. 1996-7 Associative arrays. Default value is the frequency count. use.c LANGUAGE SUPPORT 1 Keyboard mapping. Allow any table. One default table 2 Direction: left to right, and right to left. Also up, down for composite characters. 3 Rules: 3.1 Composite characters. 3.2 Arabic-Farsee shape determination. 3.1 A list of entries (a,b)->c 3.2 Depends on word length. 3.1 + 3.2 needs a termcap driver. Some routines need compiling. 4.0 Some machine dependent translation of file names. Many of these require table search validation. Domain and host names. Program distribution. GZIP + TAR. D4A.EXE GZIP.EXE .. maybe D4D.GZ README D4A.EXE should be modified to run archieve files. A command 'D4A.EXE DEC.XR' acts to install several files. In fact the file DEC.XR may look like:- {auto.hd ^Z} {GZIP.EXE} {.taz .arz} Use an environment variable _UFILE, the current run file. It would be useful to transfer measured slices of an archieve to a transcript object. Also bitmaps of course. Introduce APL encode, decode at least for integers. R<- X b Y #base R<- X n Y #represent Tidy up floating point formatting . Although it worked adequately on the SUN, it should be better. Also try to get more memory for #cmd function. File functions: #del file delete file #cd return current directory #cd dir change working directory #mkdir dir make new directory #rmdir dir remove directory Function #theta to rotate matrix about horizontal axis. Change sys_text((ASCIZ)name) to give NULL after #ex"name". A[X]+Y crashes the program if A is undefined. Add features to #zgets to allow form input, especially multiple pages of questions, and input of choice fields, as well as numeric, and plain-text. It is necessary to keep a reasonable tabbing over questions, so that a user may fill in a table by rows or columns according to preference. Input fields require some form of tagging: 0 Invert and Select 1-3 Fill in use 'edlin' or similar routine. 4 Validate single key value against table 8 Choice of word via menu. exit #zgets with special code (CTRL-S). MARCH/96 Change working of _CLS so as not to change colour. Clear text only. (For WINDOWS95). wwmap.c APRIL-MAY 1996 Try to get it to read files with wordprocessor paragraphs, which appear as very long lines. linbuf[] defined in mm_sfile.c Also work on formatting functions to create .html files from plaintext in paragraphs. JUNE, JULY 1996 alin.c, mm_sfile.c fxww.c linbuf[MAXLINE] sl_supp.c new line width code. would like to introduce 'awk' like functions. could change symbol table, and parse input lines. must do: change float to integer, for negative numbers. Allow stream file to include stdin, stdout. Define functions for file buffers. Implement S<-A[I] A[I]<-X for generalised arrays, as in perl. Done: Some 'sed' like functions. Regular expressions are:- \c character c . match anything * match any number of previous character & replace the found string in substitute command \n newline \r carriage return \t horizontal tab character Required: Improved string matching. a.*b works, but not a*b Array like processing of buffers. Faster access HYPERTEXT OPERATIONS Want several features: (1) Lynx look alike (2) Allow #find to take regexp done: R<-str #rxfind text R is an (index, length) pair. (3) Improve regexp coding (4) Change window structure to use nested array for text (5) Allow int for characters so that editor works in UNICODE 1997 May June More #sed functions, including sort of file. Make cursor reflect screen_top + line_offset sed.c revise page-formatter to preserve "<" at newline. sl_supp.c Elimiminate stuff from sl_slice.c and fxww.c Change input key translation to accept 256 values. Should make this more flexible. Done (#keymap). Should implement inverse video area selection. Also add more functions to #sed, including duplicate line. Maybe use 'I @' or something, where (I)nsert (R)eplace take interpreted strings. Use $1,$2,...$n for fields of current line. \$ for $. Use $var for D4 variables. Define new function Z<-{FS} #split X where _1, _2, _3 etc .... are placed in symbol table. Not done. Improve #val function, and command input to evaluate large integers to double precision. June 1997. lex.c na.c Split uses $0, $1, etc. A field seperator is allowed. CNT<- {FS} #split LINE Variable names may start with $, but must use only uppercase, '.', '_', or digits. The result of the function is the number of fields. Improve #do X (1) stack overflow (2) suppress print of result. ... not done yet. This means changes to main() in ma.c. (1) set $0 $1 etc as command line (2) #load passes parameters in ARGS #load F (3) Speed up the code. #sed code made more systematic. R<-#sed"./str/" returns line number, or -1. R<-#sed"/xyz/" defaults to find /xyz/. June 97. Still not much improvement. Line counter S_LC(base) sometimes looks wrong. Reduce size of .exe file: put more things in symbol table. Line buffer is 16K. Could easily increase to 32K+ with a $linbuf variable. Assign a 4K buffer called inline. The sun system would use another for the virtual screen. .. done 6/1997 Change #zgets for single field. Always exit. July 1997. New functions for #sed. see d4.doc to do: (1) allow d4ar to create directories. use the 'ar d arfile' option. Also found error in eval.c. fixed, july 1997. (2) explode real .tar files. (3) try and get 32 bit compiler. Editor does not break long lines at correct place. edit.c Fixed. #sed"d/xyz/" deletes text to line containing string xyz. 8 July 1996. Write Kanji output routine in c. Directory is /d4/graph. d4k.exe has routines M #kjput (y,x,colour) and for later M<-#kjget y, x, nr, nc, colour. Here nr is number of scan lines, and nc is number of bytes. Pixels are in a matrix of size nr x (8*nc). 9 July #window size bug in WONDOWS95. Sometimes the system starts up with the cursor outside the default window, 25 x 80. The DSH function gives a repeated error. This would be ameliorated if the window size is given the full screen size as a default. Z<- #window 1, idx Initialise window with a default rectangle of (0 0, #screen). Also #sed should create and release windows as required. R<- J #sed":r ",FILE create window J. R<- #sed":q" delete window R<- #sed":d" clear transcript 11-14 July. Mouse support. {B,Z} <- #mouse Z where Z=(y,x). ... make #sed"S/str/strstr/a" double all strings 'str'. Currently it just goes on. Done. 15/7/97 S/~~/~/ag and S/~/~~/ag should switch hanzi codes according to Fung F. Lee's method. Changes to sed.c were entirely motivated by making it good for reading PRC Chinese e-mail. Font problem. Use .ttf or bit-mapped raster fonts, and write to screen memory. Cursor problem. DSH needs more work. HZ spec problem. Chinese newsfeeds do not necessarily double the tilde (~) character, possibly because it is not really necessary. A sequence such as x~~} realy means x~ + . Video modes need better control. Use int 10h with AX=0X0F00 Return: AH = number of character columns AL = display mode (see #0009 at AH=00h) BH = active page (see AH=05h) Mode 0X12 gives colour. Mode 0X11 is B/W only. Aug97. Remove settxt mode setting function. Remove form input functions #zgets, #zputs. These will work relative to the currently selected window allowing horizontal and vertical scrolling in form input methods. Repeat error bug: This can be cured at the script level. Just use a count variable. In particular the system can recover after trying to read in an excessive sized file. Sept 1997. Change Z<- #window 5 function. This should give the cursor position in the text buffer. Z=(y,x) where y is line number, and x is character position. Fix bug in sed.c to give correct return from K<- WP #sed ":e" Oct 1997 Try to change the editor. There are two objectives:- (1) Allow a full command mode, with transition between screen and status line. The screen is updated after each command stack. The 'edit' function calls 'sed'. (2) Allow form input by directing the cursor to specified areas. life.d4f LIFE simulation. The algorithm uses associative arrays. The display method uses 'fat-pixel' fonts. Large populations cause the memory to get used up. Allow associative arrays of fixed length keys with unsigned integer values, for counts. An undefined key takes a value of _1. The table is stored as two arrays: a (size x k) table of keys, and an integer array of length size. The keys should be pairs of integers for a 65536*65536 universe. R<-(N,K) #use "A" N>2, K >1 N = table size, K = key size (integers) A[X]<-i0 => A[X]++ X an MxK table. A[X]<-val => set values October 1997 Change sed.c so that L<-#sed"@ nn" gives _1 at end of file. November 1997 Change ma.c, eval.c to allow postfix operations. A++, A--, A[J]++, A[J]-- work on integer arrays. The result returned is the result _after_ the operation is performed (unlike C). Try to delete unused routines rset - ss_supp.c; Deleted functions #fx (make function), #cr (canonical representation) and #edit. These functions are replaced with #sed commands. Also changed edit.c to allow #sed commands to be typed on status line. Improve editor. Allow data input, and cursor selection within a window. Allow more editing of data, including expression of HTML tags, before display. Editing an associative array is the same as spread sheet input. Individual data fields are entered via the (q) #inlin routine. Some changes in the EDIT function, which used #edit, then #sed cause old functions to lose the current screen, because EDIT"X" now causes the returned key to be printed to the screen. Also there are changes to the aliasing system, so that token translation is done via associative arrays rather than string searches. There is also a big change that loading the alias file d4s.lst does not delete all of the aliases defined in the .afn file. This means that the new version of dsh.afn may not be compatible with all the .d4f examples. The editor uses a 'line input' routine. The size of the line on the screen may be limited, but the size of the line data may grow by using a character pushing method: the cursor stays, but text goes away to the left or right. Each time the cursor moves over a line, that line is edited, and trailing spaces are trimmed. The editor is reasonably good at getting pasted text from MS-Windows. The sed commands need improving. Firstly the s/^/str/ construct should insert a string before the current line, while s/$/str/ appends a string. Also when a substituted string contains newlines, the file image should reflect the new lines created. 'Undo' function should be available. #sed":b" Break lines with embedded _CR characters. December 28-29. The matrix inversion routine Z<- #domino X causes run-time error for X <- ?4 4r2. Changed xmat.c. Also changed ../fxt/script.d4f, to use the version of DO in dsh.afn, and also added an alias for 'goto'. Path names. The .d4f files should really work well when in any directory. At the moment some of them require to be run in the CWD. Time management: modify keyboard routine to detect long wait, and invoke a screen saver, without losing any data. FEBRUARY 1998 Changes to the editor adversly affected the arabic capability. Printer driver works OK, so more need to be able to input arabic for demonstrations etc. It's most unfriendly editor possible, but traditionalists will insist that the Earth is flat, and that Arabic is meant to be written by hand. And it must only be the right hand as well. print.d4f -- for Citizen printer with 'epson' and 'ibm' features. delta.d4f -- Extensive addition to graphics capability. Draw lines and circles, and limited block fill functions. New reserved names $GZ and $GW for graphic cursor, and clipping window. The math functions sin and cos to be added when I get a better compiler. AXIS SELECTION The old-stype APL axis modifier (as in A<-B,[0]C for conctatenation) is written as +: where + is the operator. The functions are where it is applicable are , (concatenate), / (compress) and r (rank, or shape). A,:B is A over B. This works well with 2xN lists of (y,x) pairs. A/:B works on the vertical axis of B. N<-r:X gives the shape of X as a 1 x M matrix, or table. lex.c matop.c eval.c HEXAGONAL-TILING. What would the video look like if pixel co-ordinates were interlaced. The set (y,0) describes an axis sloping at sixty degrees. There are two close fits for a vertical line. CITY-SCAPE. Generate a city, and pan & zoom. VR works on fast processors, but coding can be done on a much slower machine. Still not done. MARCH 1998 Eliminated functions #keymap, #alpha for foreign languages. Use 'environment variables' instead, and enable the translations via the window 'mode' bits. The manual, <./d4.doc> is not clear. $KB 256 byte keyboard translation. $ALPHA Table for character composition. $BETA Table for character modification at cursor. Turbo-C compilation. D4 - Turbo C version. Different make syntax. Must specify target in command line. extensive differences from Microsoft C. rs232.c deleted, and fx_rs232() mapped to fx_nop. d4t.exe is slightly larger make.exe, tcc.exe, tlib.exe, tlink.exe. tlink is very cumbersome to use. fxker.c needed extensive modification. kjscr.c needed outp redifined as outportb. rs232.c deleted. Could use pcigc terminal mode. The program is slightly larger. It is possible to use d4t.exe as a shell for rather longer because Turbo-C gives better memory management. The make files are generated from TC.D4F. There is a slight aggravation with Turbo_C. The case of file-names is significant in make files, but DOS still folds file names to upper case. That is not the same as windows. This paragraph is written after a complete system failure, restored by the ERROR.CNT++ feature of the keyboard error handler. Sorting the result of #files"../font/*.bin" gives different results between MS-C and Turbo-C. This is true for A16LO.BIN and A16THIN.BIN. Why sorting goes wrong I do not know. in Turbo-C memcmp does return an integer, representing the difference of the first two non-matching characters in ANSI sequence. MS-C just gives 0,1,or -1. But the real error is a missing paramater from memcmp. If the source, na.c used #include the c-compiler would have given a warning. But if all the 'standard' files were included it would require lots of #ifdefs to change things when using a different compiler. APRIL Index A[:J]<-X does not work correctly. Must fix quickly. Reload and merge .d4f files needs a better scope mechanism. This should perhaps use different symbol tables on a per process system. Fixed index problem. Other mis-use of functions halt the system. CTRL-A problem. Logically CTRL-A maps all keys to ASCII+0X80. This means that without a translation table it is impossible to reset the keyboard, or give commands. The ESC key is mapped to 0X9B. Normally not tested. Add code to DSH at this stage. Mouse driver problem. The TC compiled version does something wrong when the mouse driver is installed via the #cmd command. #cmd"mouse /2" will fatally degrade the system. That means some routines are corrupting the memory somewhere. It may be good to compile mm_slice with DEBUG set. DATABASES Get rid of #dbtie #dbclose etc. completely. Replace with the #use function. No more files, only virtual arrays. Z<-"h:abc.dat r" #vfile "ABC" T<-ABC[I] read bytes specied by I I= start, size I= start, size, record Also get rid of functions #wput, #wget. Replace with M<-$screen[W] $screen[W]<-M AUGUST DOS: #disk function implements INT13H. Reset, Status, Read, Write. The functions are mostly untested on this machine. They are very dangerous to use, although they could help repair corrupted boot sectors. LINUX version under development. The SUN version did work on LINUX without modification, but there was a serious error with the concatenate function (,). There is also the improved syntax, and mini-shell facility. The main changes are in screen.lib and fxker.c. kjscr.c needs modifying for X-windows. Also desirable would be compiled in gzip decompression for objects. The LINUX version is compiled, and the DOS/WINDOWS test.afn file works with just a few modifications. There are big differences in the the treatment of terminals and directories. Keyboard handling is really kludgy with calls to the termios system, but hardcoded escape sequence recognition for just one machine (VT102, I think). Unfortunately the ESC key must be pressed twice, where once was enough, with unpredictable results when it is pressed just once. By now the edit function is compareable with 'vi', now called 'elvis' on LINUX. It also works on large terminal windows on X-Windows. The #sed function is virtually unchanged, but the underlying memory mapped display is simulated by an array. This array is in the symbol table, but it's name is not a valid identifier for an ordinary variable. Nevertheless the command #ex"$screen" would cause unpredictable results. Break in handling is also unpredictable, just as in the Turbo C programs used on RTI's old computers. Sometimes it works, and sometimes the program exits. For reliability more signal handling facilities should be added. Despite a slightly different result from the #files function the expansion of the directory tree can be obtained by SDSEL. The ASCII scrolling routines of sc.d4f work well enough. Testing them revealed a bug in the array subscripting routine. [ The possibility of handling very large lists in memory is attractive. The 32 bit version is about the same executable size as the DOS version. In LINUX the 'SIGINT' vector must be reset each time it is used, and the system detects CTRL-C. SEPTEMBER Manchester ISEA. Demonstrated software. john@pure.u-net.com. consolefonts not implemented properly on all LCD displays. Extra dots get added. This is a problem of SVGA emulation. Escape key 'hit twice' is now eliminated. This is done by using the number of bytes returned by low level n = read(tty, buf, size) request, and compare n with size. There is _no_ ioctl() call. The operator #cmd"shell_line" now has a new syntax, so that the result of #cmd" < command " is now a _CR delimited string giving the output of the command sub process. This allows access to any environment variables around. Ordinary X terminal does not display full font. Character set switching is not adequately displayed in the documentation. A function has been written to connvert .bin files to .bdf, but it seems a wasted effort. The Thai X-fonts are installed, so its just necessary to modify inlin() function. OCTOBER The keyboard routine keeps giving trouble. Normally the inkey function tests the length of the string given by n = read(tty, buf, sz). If n>1, then it's an escape sequence for a none alphanumeric key. This works fine on an old machine and it does not seem to break. But on this Olivetti, there is a problem. The edit function requires another window size in order to function well; but this seems to depend on the machine. It seems that not all installations of X-windows are equal. This bug depends on the number of lines; when #lines > 25, no problem. The #sed functions ":r", ":i", ":u", ":w" may be piped if required. The syntax is '{":r" | ":i} < shell_command' for input and '{":u" | ":w" | shell_command' for output. This means that .gz files may be edited directly with certain versions of WW.ED. Files with different mappings of the same character set may be edited in situ . The expansion of tabs may be treated by using the filters 'expand' and 'unexpand'. It is possible to use DATA #zsave "/dev/ttyp[n]" to write to other consoles. It is not possible to use this to write to the keyboard of another terminal. Here documents. NOVEMBER Use special array $$ to index $0, $1, ... $n lists. $$[idx] gives concatenated fields, separated by $OFS. $SCR[IDX]<- values 'Writes pixels' IDX Access file via $VA[] array. $VA[fnum, start, size, rp] <- DATA DATA <- $VA[fnum, start, size, rp] X<- #ifdef "string" gives value linked to string if string points to defined data, and an integer if string points to a nested array. JANUARY 1999 Changed names of file system functions to #open, #close, #read, #write, #fsize and #fnames. Wrote scripts using the #disk function in DOS/WINDOWS to look at hard disks by sector. Never tested the write option. Hard disk broken. Linux development stopped. MARCH 1999 Introduced mathematics functions in DOS version. Z<- #exp X, Z<- #ln X for exponential and logarithm. Z<- #sqrt X for square root. Z<- FC #circle X or Z<- FC o X for trig functions. FC = 1,2,3 for sin, cos, tan. FC = _1, _2, _3 for inverse of sin, cos, tan. 12 10 z 4*_3o1 gives 3.1415926536. i.e. 4*arctan(1). Error treatment is rudimentary, because there is very little documentation with the compiler. For example #sqrt _1 will produce an error message, and a silly answer, but it will not force an exit from the program. The program size increases by about 4 Kb for all these extra maths functions. Tar file unpacking is under development. It works well enough with GNU tar, but other versions need work. See d4ar.d4f. OCTOBER 1999: INTERNET EXPLORER PLUG-IN It is possible to embed D4 into the system viewer on Windows machines. A short script iex.afn facilitates this. The source files have the extension .d4i, but anything would do. html fragment sample .d4i file "sail.d4i" which is an ascii animation #copy"test.afn" |main file DO_DEFINE"v=10" DO_DEFINE"x=animate#sail" STARTUP I only know how to configure INTERNET EXPLORER by hand. (1) Go to the Options section of the View Button. (2) Go to Programs, then click on 'file types' in the Viewers Box. (3) Select 'New Type'. Fill in the form. Description d4 header Content type text Default Extension .d4i (4) Select New in the 'Actions' panel. Call the first action 'open' then fill in the form. Action open Application used .. c:\d4\cp\d4t.exe c:\d4\cp\iex.afn v=10 Confirm by clicking OK. (5) Close the options windows (6) Test all this by using INTERNET EXPLORER to view a .d4i file. It is also possible to do right to left editing on hebrew language files by specifying 'Open' and 'View' actions for files with a .heb extension. The command line for the application should look like: c:\d4\cp\d4t.exe c:\d4\cp\test.afn v=10 x=hebrew#vheb This action will open the file for editing in a green screen. It may be necessary to press ALT+ENTER to see the font. The keyboard mapping is cut from a LINUX file. NOVEMBER 1999 Download DJGPP to make 32 bit version. Will use memory mapped IO to VGA/TEXT for the time being. Try to use 16-bit io as much as possible, but with a single virtual screen and appropriate Get & Set Display functions. #kjput can be done with some go32 and dpmi calls. Very non-portable, but should allow chinese in Windows. It took about two hours to build d4x.exe with the DJGPP compiler. There were several places where #ifdef TC options had to be used rather than LINUX. At least the new version allows me to edit the 600Kb file 'libc.inf'. There were serious complaints by the compiler over the definition of lseek() because DJGPP uses a file offset type as an ordinary int. 'nfile.c' was hacked about. The ../screen library is pretty much the same as for Borland's 16-bit version of TURBO-C, which fits on about 40% of a floppy disk. The DJGPP distribution with documentation make and seperate 'dpmi' comes to about 3.5 floppy disks. 32-bit versions are to be called 'd4x.exe' and 'd4y.exe'. The make directory is ../gc. The same source code is used for 16 and 32 bit versions. To make the 32 bit version copy the files ma.c fdata.c and dojt.c to ..\gc and run the DJGPP make with the command:- make -f lek.mf Changes to source files inc\htext.h, inc\scrnio.h rts\fxker.c, rts\na_fio.c, rts\nfile.c screen\kb.c, screen\scrn_io.c, screen\wwmap.c gc\dojt.c, gc\ma.c 32-BIT VERSION CAUTIONS AND WARNINGS #cmd"chkdsk" and #cmd"scandisk" give warnings. This is to do with the way the DJGPP compiler deals with the 'system' call. DJGPP makes certain optimisations which probably conflict with WINDOWS. The same thing happens with 'format.com'. WARNING !!! Always use d4t.exe, the 16-bit version on 'rescue disks'. Memory mapped screen applications run rather slower than in the 16-bit version, and it is impossible to get soft fonts to work the same way. Program crashed first time run on native DOS, but after installing nov99.ar and running licence.afn. rts/sed.c contained junk code which appeared to work under WINDOWS (and LINUX ?), but not native DOS with the CWSDPMI extender. In fact most things worked except for a line #sed"X:d;$D;:od4.sig" and this used the junk code. It was possible to remake the program with GCC on the Compaq 486, and fix the error. It is quite possible that I should add a SIGSEGV handler to make such errors appear less alarming, but potentially more damaging. 32-bit program crashes every so often when 'cls' command is invoked after an error. The error occurs in lex.c, but it's the same as the LINUX version which did not appear to have the problem. December 1999 Changed .ar files to .4r files to avoid confusion with UNIX .ar files, and change installation to start off in top level directory d4. Tested ULAM SPIRAL. Does not work nearly so well as LINUX. 'cls' bug may be alleviated by redefining the 'cls' alias. cls| 1/_CLS Wrote BUSINESS PLAN SOFTWARE bizplan.d4f Allow scrolling wide files wouth mouse. See 'dsh.afn'. Modify ma.c, rts/use.c, screen/scrn_io.c inter alia. Try some info-style functions with embedded scripts. Self indexing text. Poor Text Format. Add junk to file. Make it self removing junk. I.e the .afn files can save all the text as plaintext. MULTIPLE PRECISION January 2000. Add multiple precision arithmetic. Use Lucas-Lehmer test for Mersenne primes up to 2**2281-1. Test against values supplied by Alex Lopez-Ortiz in the 1994 maths FAQ. UNESCO has made this World Maths Year. At least the Lucas-Lehmer test is available on laptops. The turbo-C compiler gave junk code for the expression:- for (si=start, n=nx; 0 cmd " #open N, 5 to write to a pipe. This appears to work with gnugo. MAY 2002 kb.c xterm & rxvt mouse. DECSET. \E[?Pmh DEC Private Mode Set (DECSET) (Ps = 9 ) -> Send Mouse X & Y on button press. (Ps = 1000 ) -> Send Mouse X & Y on button press and release. (Ps = 1001 ) -> Use Hilite Mouse Tracking. On button press, xterm sends \E[M Cb Cx Cy. Cb is button -1. All bytes are offset by 32. Cb takes the values 0 (left) 1 (middle) 2 (right) Mouse tracking is enabled by definition of $MOUSE. The result of mouse press is returned to the program by the inkey function: K<-k. Since this function returns an integer, the value K is made up of the four bytes 'M', Cb, Cx, Cy. In fact these values are made by shifting: the code should work independently of bytesex. Other parts may give problems. I must try & get access to a SUN. Wrote a gomoku game for rxvt terminal. Want to add 'select' style wait for the function K<-k timout_value. JUNE 2002 Added more control structures to defined functions. Determine that Z<- N #print STR function will crash the program whenever this is the first use of transcript 'N' and STR is an empty object. Also the old bug where a defined function that fails to return a value has come back with a vengeance. The interpretor now understands IF,WHILE,WEND,BREAKIF,REPEATIF APL 'goto' is extended to the ->STRING option where string is matched against labels consisting of string literals. This makes it like the case statement in the Bourne Shell. JULY 2002 Should fix bug in '#print X' where X is numeric. This crashes the program. The bug could be fixed in sed.c or sl_supp.c (sl_app). Added '#outer %' and '#outer #mod' in xmat.c to help compute sequences relatively prime to a set of numbers. Add a new function Z<-READ_TTY {prompt_string} for dumb terminals. More work still needs to be done on file control options and sockets. Added a file dummy.afn which passes all possible commands to the ordinary shell. Should obtain C source code to allow dummy to implement ftp and telnet as builtins. At least 'dummy.afn' will be OK for testing on new systems. AUGUST 2002 Marsaglia-Ziman pseudo random number stream. Must fix bug in X<-A[I]++. X should be A[I] and not A. More work needs doing on WINDOWS version. New script files do not always work as expected. DOS font stuff needs adjustment. SEPTEMBER 2002 Convert mandelbrot images to bitmaps using random number generated grey scales. Given n colours C={0, 1, 2.. n-1} set a pixel of colour k according to the following: k=0 pixel = 0 k>0 pixel = 1 with probability k/(n-1) NOVEMBER 2002 Fix bug so that #fstat "" does not crash system (Windows). DECEMBER 2002 Rush Hour Traffic Jam. Sheffield 2600 group discussion. The application, RTJ.D4F, shows up some errors. ** Frequent sigsegv crashes. The virtual array stuff. ** random number stream. Need a new function Z<-SRAND SEED. Change xx_fmt in matop.c for buffer overflow. ma.c mmsym.c scalop.c for SRAND function. Also use tables for initialisation of 'hard functions' and 'soft variables'. MARCH 2003 Construct DOS boot disks. Difficulty linking with -static on new versions of linux. This is needed for linux router project boot disks. JUNE 2003 TODO: (1) $FTIME for LINUX. (2) $ENV as an array to reflect environment variables. (3) Check out $INP and $OUTP routines. For Hw detection, etc. (4) Check out file handling. Problems with #cmd"string" because the environment is not correctly passed from within the script. This is a weird problem. The $ENVP[] array can be set up from *envp in main() then these variables are set by the program. This fixes the problem, but it may cause others. JULY 2003 The new linux version is working fine, but it brings ImageMagick to it's knees. With new work on xpm.d4f there are thousands of fractal wallpaper images in ../fractimg. The 'animate' and 'display' utilities do not seem to work as advertised. Animate failed on a line such as animate ../fractimg/*.xpm. The program took about ten minutes before giving up, but worse still the side effects of animate caused the machine to fail to boot the next day. The X server could not work because animate had filled up the /tmp/ directory giving 100% disk usage. The machine kept on trying to bring up X, and I could not get a console. It was necessary to bring up in failsafe mode, delete the junk files, and then reboot from scratch. The KDE window manager came back. AUGUST 2003 CGI stuff started. #rxsubs fails to notify errors. NOVEMBER 2003 Program crashes after changed window size. DECEMBER 2003 Program cannot run for 24 hours. Mysterious signal 'sigsegv' for no apparent reason. Also occasional failure of WHILE WEND loops with error 40. This occurs during count of 4x4 binary tiles. Fixes: (1) Retain exit message from d4x (2) run with different symbol table size. The default of 512 maybe too small for linux. This can be changed in ../inc/dt.h. Alternatively command line d4x N=2197 .... JUNE 2004 Downloaded RSA Challenge numbers for factorisation. The double to integer conversion is very bad. Integer matrix work is likely to be very innaccurate. The Fermat test a^N-1=0 (mod N) is very time consuming for large numbers with many hundreds of digits. At least these factorisation programs can run continuously for many days. It's necessary to big integer routines for elliptic curve stuff. X<- -"1" crashes the program. modify scalop.c to test for text type arguements, representing long int. SEPT 2004 Implemented Pollard method for factorisation. Nothing works faster or better than this at the moment. NOVEMBER 2004 Used the d4 to implement a p+/-1 method, CFRAC and Elliptic Curve Method (ECM). Managed to get ECM to work on a 40 digit number. The time was about 72 hours. MAY 2005 scalop.c requires changes to return error for incompatible sized arguements. Failure to do this results in programs running with huge pointers which could freeze or crash the machine. JUNE 2005 Sudoku solver written and bundled with the rest. On newer versions of linux ma.c fails to compile because the exit() function requires a return code and the new default for gcc makes it compulsory for exit() to have a paramater. The function keys get lost on newer versions. Ctrl-R and Ctrl-P are needed for F4 and F5. Despite loss of function keys new versions of the KDE terminal window and xterm are closer to the linux console which is fairly close to being hard coded in the keyboard input routine so that the editor works better than it used to. AUGUST 2005 Installed Mandrake Linux on a Toshiba laptop. Changes dsh.afn, script.d4f and dsh to make an installation which could run from /usr/local/bin. Terminal mode input is wrong. Sometimes read from stdin should echo the characters. The command H<-#read 0 should take this into account. See the file dummy.afn. Add a new function like SRAND. Z<-TTY_SET 0 line mode Z<-TTY_SET 1 screen mode use $VA[0 0 1] for single key input. HEISENBUG The system normally crashes when running a script which generates colour images from Wolfram style linear cellular automata. The bug showed as "Error [40] WEND:". Research with 'gdb' shows that the error occurs in NARGS, a function which processes numeric arguements in the GETOPTS function. The "Error [40] WEND:" problem is an example of a Heisenbug. The Heisenbug cannot be located even when efforts are made to find it. The bug is probably in the lexical analyser, 'lex.c'. Fix will involve rewriting the bit which deals with labels and WHILE WEND loops. Really WHILE and WEND should be compiled rather than interpreted. This would much more easily allow multiple levels in a loop, and it would also facilitate FOR (expr;expr;expr) {block}; loops. INCDEC Program crashes with expression like CNT-- when CNT not defined. SEPTEMBER 2005 Some compiled limits in the program are too small. Default number of symbols is ridiculous at 512. Most scripts run for later debugging have this number set higher, and then the bug goes away. Modify 'dt.h' for more stack and objects. The name list soon fills up with multiple applications loaded at the same time. JANUARY 2006 RSA-640 was factored last year. The method was 'NFS' or Number Field Sieve. The whole process took only a few weeks on a handful of high powered computers. From the RSA website I downloaded msieve. MSIEVE: A Library for Factoring Large Integers Jason Papadopoulos (jasonp@boo.net) 11/27/05 Getting msieve to compile with gcc v2.96 required a modification to tinyqs.c at line 617 .. move an inline declaration (accum) to just after a curly bracket. Also the macro PREFETCH needs to be dummyfied for early versions of this compiler. After these mods the compilation works. This is recent stuff. The source code for multiprecision should help me to speed up the multiple precision rooutines. First I will try recoding ds_divmod using the 'reciprocal' method. This will reduce digit by digit table searches by a kludgy looking iteration scheme to compute (10^2*N)%A X[n+1]<- 2*X[n]- (2*N) RSHIFT A*X[n]*X[n] here N is related to the length of A. The algorithm appears to work most times. Even so, using this method on decimal strings is tedious and does not improve on the current method. It may be better to try and speed up multiply. Writing loops to test times of new algorithms in C versus old algorithms written for the interpretor show almost no improvement. The reciprocal method is much slower than existing long division for decimal strings. The real reason why msieve is 10000000 faster than QUAD_SORT is not because msieve is written in C, but because it uses a much smarter algorithm. It uses multiple polynomials (ax+b), chooses multiply factors, and uses a factor base plus larger primes which are added to the factor base as required. FEBRUARY 2006 Tried compiling the stuff with Ubuntu distribution. Newer C compilers cause some warnings to become fatal errors, so sl_supp needed some changes. The default warning schemes have changed several times recently. There used to be warnings about unitialised variables, but not necessarily. scalop.c did not work on the other machine until I found a use of an uninitialised variable. MARCH 2006 Add new functionality to #mod. Z<- (BIG_INT X) #mod (int32 Y) gives int32 vector X #mod Y[i] Must add functionality to the div-mod functions so that negative numbers do not crash the system. This would speed up Elliptic Curve Method which extensively uses the workaround function:- Z<-X YMOD M |Modulus function including negative X IF "-" #ne 1tX; Z<-X #mod M & ->0 Z<-M-("0"-X) #mod M It has been possible to improve the quadratic sieve so that forty digit factorisations can be done at lowtech.org in a couple of hours. In the meantime I used ECM to factorize the fermat numbers F7 and F8 on the Toshiba. F7 appeared in George Szpiro's book on the Kepler Conjecture about sphere packing. Changing divmod is dangerous. It was very troublesome to make it work at all. Other necessary changes are as_comp which compares strings like "-34">"234" and gives random looking results. Allow easy sign testing of large decimal integers (LDI's) by extending use of monadic * function (signum). *A-B is 1,0 or -1 for A>B, A=B or A0. The function may be implemented for B<0 with special negative values being used as function codes being weird hash functions of the left arguement which could be any ascii string. Alternatively it could merely give a reasonable answer such as A #mod B = (-A) #mod |B| when B<0. With integer vectors the mod function is flakey for negative values. JULY 2007 Size limitation on console at 600x800 is too small. The size is defined in . Should be changed JANUARY 2009 Try to modify editor to allow paste. This could be quite complicated. Recompile on Acer netbook. Correct fxker.c. ambiguous coercion in #sleep. Modify sl_supp.c. Missing local declaration of sl_xl() FEBRUARY 2009 HTML converter. album.d4f, html.d4f. Assume all text files will be photo-essays with inserted images and logos. Do more work on auto title facility, since google is recruiting human volunteers for this. MARCH Maths drawings. Curve sketching + fourier series animations. Difficulties. dsh.afn, test.afn. Long shell scripts sometimes hang. Instabilities in WHILE, WEND loops. rxvt mouse works ok on unicode terminals but the mouse key packing can be confused with certain unicode input. Maths. spiral.df fs.df script.d4f Photos. album.d4f camera.d4f yakoma.d4f script.d4f Digital camera gives slightly different image names for different machines. The letters are capitalised on the Acer. Also copying images to a USB stick may change names from upper to lower case. SEPTEMBER 2009 Change xx_fmt matop.c Require change to ds_add in scalop.c (done). NOVEMBER 2009 The misuse of '/' freezes the machine. X<-"abc 123 44 77" /1 2 3 may cause the machine to require reboot. There are no sanity checks on the arguements to '/'. ma.c (mkobj 'F' ...) eval.c for complex numbers matop.c floating point format scalop.c complex numbers misuse of new floating point format crashes the program. DSH should allow input of long lines with trailing \ to request merge of one line with the next. This would help with entry of long arguement lists for the plotting functions. DECEMBER 2009 Virtual screen bug. After changes of screen size it is necessary to invoke XRESIZE to reset screen 'constants'. This often used to fail with rxvt terminals. Failure is much less common with the unicode screen. JANUARY 2010 Want to make some improvements. First look at quadratic sieve which died in later versions. Took out some 'print' statements, and it works on the Acer, but very slowly. F7=2^128+1= 340282366920938463463374607431768211457 = 5704689200685129054721 * 59649589127497217 Very slow running time. > 8 hours. E<-QUAD_MPQS"-fc 8 -b 6400 ",F7 G<-XYZ_FACTOR"-v -cnt 40 -b 6400 ",F7 $ G 5704689200685129054721 59649589127497217 Much faster. 25 iterations. About 90 minutes. Relies on luck. Desired to change program features. Array access. X*[J] or X,[J] treats J as an index to (,X). This allows more flexible treatment of XPM pixel data. This can be done by adding more info to the '[' token. Use the previous operator as long as at is not a ')' character; or just use designated pairs. WHILE ... WEND construct to allow nested loops. IF ... ELSE construct. Already done but occasional unwanted output. Add more complex number stuff. Use {J} as array indexing for strings and substrings. Replace A YDX J in scripts with A{J}. General changes are made to the Linux source files to eliminate warnings during compilations. Mostly this is done be eliminating local function type declarations and using #include "strings.h" etc. Fractal Generator. There is new function called MSET. Z<- {bailout} MSET XP returns a vector integers taking the values 0 <= Z[i] < bailout for each point P in XP which is a list of number pairs. There are also changes in color selection for the MK_XPM function. spiral.df XIANG QI Mon Jul 26 20:02:14 BST 2010 Digital fortress. The general's office may be invaded by horsemen, tanks, or suicide bombers. Long range attacks come from the cannon and the opposing general. See Tian Amen square and the portraits of Mao and Sun Yat Sen. They built an opera house in between. Random Xiang Qi with rooks and cannons is a high probability win for the first player. The first move in random play is a sure way to win, the way the program is written. The program may have bugs. The file is xq.d4f In random play the blind general suffers from cannon attack. This was a bug. For unicode it may be useful to re-instate the #zputs function. Thu Aug 12 16:34:12 BST 2010 #zputs works to display hanzi unicode strings. A new version of d4x called 'che' from che.c has a built in function Z<-XQ_MOVES G written in C (xq.c). The #nc function and #ex function give silly results when applied to hard coded functions. A line such as WEND<-0 will hang the program. A workaround in scripts could be to test the version string. A Xiang qi script could test the $VERSION soft variable to see whether it looks like: 'che(linux) ....'. The correct method of dealing with the problem is to give 'hard functions' a new name class in ../inc/na.h and to edit the function 'symop' in ../rts/fxker.c. The #nl name list function fx_nlist is in ../rts/mmsym.c. The existing #nl function gives perfectly sensible results. '#nl' gives a list of all entries in the symbol table including the stack, file handles, and suchlike. Sun Mar 27 10:54:41 BST 2011 CHE 车 d4x is now called che. This work is under progress. The main reason for change is to create che2011.tgz as source code for the postcard images generated by scene.d4f