[futurebasic] busy busy busy

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2002 : Group Archive : Group : All Groups

From: Bowerbird@...
Date: Fri, 7 Jun 2002 15:38:33 EDT
i said:

>   i'm more interested in source code that makes it work.

>   i've shown how to proceed with the resource-fork approach.

>   gnome, can you give us some routines that make flatfiles work?

gnome informs me backchannel that
he is "too busy with other stuff" to
provide us with any example routines
to implement his "flatfile" suggestion.

so i took a few minutes and wrote some myself...

appended you will find my sample program,
followed by the lines of a "datafile", which
-- as i specified recently -- should be able to
be sent via plain e-mail, as i'm doing here...

splice the program out of this e-mail and save it,
then do likewise with the datafile, as directed below.

the first time you run the program, it will read the data from 
"store.store" and reconstitute 3 pict files on your hard-drive.
double-click 'em to view in simpletext to see what they are.

then rename the 3 files from "filename.new" to "filename.pict",
and delete the "store.store" datafile.  then un-comment out the 
"fn store" line in the program, and run it again.  this time, it will
read the *.pict files in, write the data to "store.store", and then
(as it did the first time) restore the "filename.new" files for you.

i haven't tested this on a wide variety of pict files,
so there may be some bugs in it, but you get the idea.

-bowerbird


COMPILE 0,_caseinsensitive
WINDOW OFF
% _ACount,0
AUTOCLIP=0
WINDOW 1,"",(0,0)-(SYSTEM(_scrnwidth)-100,SYSTEM(_scrnheight)-100),_doc
END GLOBALS

CLEAR LOCAL FN dostore
  DEF OPEN "TEXTttxt"
  OPEN "O",#2,"store.store"
  FOR phile=1 TO 3
    LONG IF phile=1
      filename$="sound.button"
      OPEN "I",#1,"sound.button.pict"
    END IF
    LONG IF phile=2
      filename$="square.button"
      OPEN "I",#1,"square.button.pict"
    END IF
    LONG IF phile=3
      filename$="star"
      OPEN "I",#1,"star.pict"
    END IF
    IF phile<>1 THEN PRINT #2,""
    PRINT #2,"// filename$=";filename$
    z=0
    CLS
    WHILE NOT EOF(1)
      LINE INPUT #1,s$
      FOR x=1 TO LEN(s$)
        z=z+1
        cv$=MID$(STR$(ASC(MID$(s$,x,1))),2)
        WHILE LEN(cv$)<3
          cv$="0"+cv$
        WEND
        PRINT #2,cv$;
        PRINT cv$;
        IF (z MOD 20)=0 THEN PRINT #2,""
        IF (z MOD 20)=0 THEN PRINT
        IF WINDOW(_penv)>WINDOW(_height)-40 THEN CLS
      NEXT x
      eof1=0
      IF EOF(1) THEN eof1=1
      LONG IF LEN(s$)<>254 AND eof1=0
        z=z+1
        PRINT #2,"013";
        PRINT "013";
        IF (z MOD 20)=0 THEN PRINT #2,""
        IF (z MOD 20)=0 THEN PRINT ""
      END IF
      IF WINDOW(_penv)>WINDOW(_height)-40 THEN CLS
    WEND
    CLOSE #1
  NEXT phile
  CLOSE #2
  CLS
END FN

CLEAR LOCAL FN dorestore
  OPEN "I",#1,"store.store"
  DEF OPEN "PICTttxt"
  filename$=""
  WHILE NOT EOF(1)
    LINE INPUT #1,s$
    PRINT s$
    LONG IF MID$(s$,1,3)="// "
      IF filename$<>"" THEN CLOSE #2
      filename$=MID$(s$,14)+".new"
      OPEN "O",#2,filename$
      CLS
      PRINT filename$
    XELSE
      s2$=""
      FOR x=1 TO LEN(s$) STEP 3
        s2$=s2$+CHR$(VAL(MID$(s$,x,3)))
      NEXT x
      PRINT #2,s2$;
    END IF
    IF WINDOW(_penv)>WINDOW(_height)-40 THEN CLS
  WEND
  CLOSE #2
  CLOSE #1
END FN

REM   FN dostore : REM use the datafile below to create the picts first.
FN dorestore
PRINT
PRINT ,"all done.  press command-period."
DO
  HANDLEEVENTS
UNTIL 0


starting with the next line, save this as a textfile named "store.store"
// filename$=sound.button
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000002224000000000000000028
000034000017002255012000255255255255000000000000000000000000
000034000000000028000000000000000000000160000130000160000142
000030000001000010000000000000000028000034000152128022000000
255255000028000041000000000000000000000000000072000000000072
000000000000000004000001000004000000000000000000033012000000
000000000000005002128000000015008000255255255255255255008000
252000243125005047008000255255100138002140008000221107008194
006162008000242215008086132236032000221221221221221221032000
170170170170170170000000002065171084234255000000031033183147
020049000000000000100175017176000000086000044157005036000000
144215113096058052000000188202160028208215000000128000128000
128000000000064000064000064000008000000000000000000000000000
000000000028000034000000000000000028000034000000008000208241
085000109253221008000213241102000253253221009000213242102001
109253253221009000213242102001109253253221013000213250102000
111250102001109253253221017000213250102000255254102000111254
102001109253253221017000213251102001111223253102004246102102
109253253221018000213251102010253223102102111102111102102109
253253221019000213252102002111221223254102005246102246102109
253253221019000213252102011253221223102111102111102246102109
253253221020000213253102012111221221223102102246111102246102
109253253221021017213102111255255253221221223102102246111102
111102109253253221019002213102111252221009223102102111102246
111102109253253221019002213102111252221009223102102111102246
111102109253253221019002213102111252221009223102102111102246
111102109253253221019002213102111252221009223102102111102246
111102109253253221021017213102111255255253221221223102102246
111102111102109253253221020000213253102012111221221223102102
246111102246102109253253221019000213252102011253221223102111
102111102246102109253253221019000213252102002111221223254102
005246102246102109253253221018000213251102010253223102102111
102111102102109253253221017000213251102001111223253102004246
102102109253253221017000213250102000255254102000111254102001
109253253221013000213250102000111250102001109253253221009000
213242102001109253253221009000213242102001109253253221009001
213109242221000253253221008000214241255000253253221000000160
000143000160000131000255
// filename$=square.button
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000010040000004000015000031
000077000017002255012000255255255255000015000000000004000000
000077000000000031000000000000000000000160000130000160048057
000160000142000001000010000000000000002232002083000152128070
000004000015000031000084000000000000000000000000000072000000
000072000000000000000008000001000008000000000000002139004052
000000000000000000000008128000000255000000255255255255255255
000000255255255255204204000000255255255255153153000000255255
255255102102000000255255255255051051000000255255255255000000
000000255255204204255255000000255255204204204204000000255255
204204153153000000255255204204102102000000255255204204051051
000000255255204204000000000000255255153153255255000000255255
153153204204000000255255153153153153000000255255153153102102
000000255255153153051051000000255255153153000000000000255255
102102255255000000255255102102204204000000255255102102153153
000000255255102102102102000000255255102102051051000000255255
102102000000000000255255051051255255000000255255051051204204
000000255255051051153153000000255255051051102102000000255255
051051051051000000255255051051000000000000255255000000255255
000000255255000000204204000000255255000000153153000000255255
000000102102000000255255000000051051000000255255000000000000
000000204204255255255255000000204204255255204204000000204204
255255153153000000204204255255102102000000204204255255051051
000000204204255255000000000000204204204204255255000000204204
204204204204000000204204204204153153000000204204204204102102
000000204204204204051051000000204204204204000000000000204204
153153255255000000204204153153204204000000204204153153153153
000000204204153153102102000000204204153153051051000000204204
153153000000000000204204102102255255000000204204102102204204
000000204204102102153153000000204204102102102102000000204204
102102051051000000204204102102000000000000204204051051255255
000000204204051051204204000000204204051051153153000000204204
051051102102000000204204051051051051000000204204051051000000
000000204204000000255255000000204204000000204204000000204204
000000153153000000204204000000102102000000204204000000051051
000000204204000000000000000000153153255255255255000000153153
255255204204000000153153255255153153000000153153255255102102
000000153153255255051051000000153153255255000000000000153153
204204255255000000153153204204204204000000153153204204153153
000000153153204204102102000000153153204204051051000000153153
204204000000000000153153153153255255000000153153153153204204
000000153153153153153153000000153153153153102102000000153153
153153051051000000153153153153000000000000153153102102255255
000000153153102102204204000000153153102102153153000000153153
102102102102000000153153102102051051000000153153102102000000
000000153153051051255255000000153153051051204204000000153153
051051153153000000153153051051102102000000153153051051051051
000000153153051051000000000000153153000000255255000000153153
000000204204000000153153000000153153000000153153000000102102
000000153153000000051051000000153153000000000000000000102102
255255255255000000102102255255204204000000102102255255153153
000000102102255255102102000000102102255255051051000000102102
255255000000000000102102204204255255000000102102204204204204
000000102102204204153153000000102102204204102102000000102102
204204051051000000102102204204000000000000102102153153255255
000000102102153153204204000000102102153153153153000000102102
153153102102000000102102153153051051000000102102153153000000
000000102102102102255255000000102102102102204204000000102102
102102153153000000102102102102102102000000102102102102051051
000000102102102102000000000000102102051051255255000000102102
051051204204000000102102051051153153000000102102051051102102
000000102102051051051051000000102102051051000000000000102102
000000255255000000102102000000204204000000102102000000153153
000000102102000000102102000000102102000000051051000000102102
000000000000000000051051255255255255000000051051255255204204
000000051051255255153153000000051051255255102102000000051051
255255051051000000051051255255000000000000051051204204255255
000000051051204204204204000000051051204204153153000000051051
204204102102000000051051204204051051000000051051204204000000
000000051051153153255255000000051051153153204204000000051051
153153153153000000051051153153102102000000051051153153051051
000000051051153153000000000000051051102102255255000000051051
102102204204000000051051102102153153000000051051102102102102
000000051051102102051051000000051051102102000000000000051051
051051255255000000051051051051204204000000051051051051153153
000000051051051051102102000000051051051051051051000000051051
051051000000000000051051000000255255000000051051000000204204
000000051051000000153153000000051051000000102102000000051051
000000051051000000051051000000000000000000000000255255255255
000000000000255255204204000000000000255255153153000000000000
255255102102000000000000255255051051000000000000255255000000
000000000000204204255255000000000000204204204204000000000000
204204153153000000000000204204102102000000000000204204051051
000000000000204204000000000000000000153153255255000000000000
153153204204000000000000153153153153000000000000153153102102
000000000000153153051051000000000000153153000000000000000000
102102255255000000000000102102204204000000000000102102153153
000000000000102102102102000000000000102102051051000000000000
102102000000000000000000051051255255000000000000051051204204
000000000000051051153153000000000000051051102102000000000000
051051051051000000000000051051000000000000000000000000255255
000000000000000000204204000000000000000000153153000000000000
000000102102000000000000000000051051000000238238000000000000
000000221221000000000000000000187187000000000000000000170170
000000000000000000136136000000000000000000119119000000000000
000000085085000000000000000000068068000000000000000000034034
000000000000000000017017000000000000000000000000238238000000
000000000000221221000000000000000000187187000000000000000000
170170000000000000000000136136000000000000000000119119000000
000000000000085085000000000000000000068068000000000000000000
034034000000000000000000017017000000000000000000000000238238
000000000000000000221221000000000000000000187187000000000000
000000170170000000000000000000136136000000000000000000119119
000000000000000000085085000000000000000000068068000000000000
000000034034000000000000000000017017000000238238238238238238
000000221221221221221221000000187187187187187187000000170170
170170170170000000136136136136136136000000119119119119119119
000000085085085085085085000000068068068068068068000000034034
034034034034000000017017017017017017000000000000000000000000
000004000015000031000077000004000015000031000077000000006196
247000250249000007197247001250250249000011001247247200043002
249250250249000013002247247043202246003248249250250249000015
003247247043246204245004248248249250250249000016004247247043
246245205043004248248249250250249000016004247247043246245205
043004248248249250250249000016004247247043246245205043004248
248249250250249000016004247247043246245205043004248248249250
250249000016004247247043246245205043004248248249250250249000
016004247247043246245205043004248248249250250249000016004247
247043246245205043004248248249250250249000016004247247043246
245205043004248248249250250249000016004247247043246245205043
004248248249250250249000016004247247043246245205043004248248
249250250249000016004247247043246245205043004248248249250250
249000016004247247043246245205043004248248249250250249000016
004247247043246245205043004248248249250250249000016004247247
043246245205043004248248249250250249000016004247247043246245
205043004248248249250250249000016004247247043246245205043004
248248249250250249000016004247247043246245205043004248248249
250250249000014004247247043246245203248002249250250249000013
003247247043246202248002249250250249000012003247247043250201
249001250250249000007001247247197250249000006000247196250249
000000000160000143000160000131000255
// filename$=star
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000003076255255255255000063
000066000017002255012000255255255255255255000000255255000000
000066000000000063000000000000000000000030000001000010255255
255255000063000066000007000000000000000034002107001017000000
000161000182000004000001000001000161000182000004000001000001
000001000010000000000000000061000064000034002085000054000000
000161000182000004000001000001000161000182000004000001000001
000160000140000001000010000001000001000059000062000034000002
000002000000000035000000000161000182000004000001000001000034
000051000012000000000035000000000161000182000004000001000001
000160000160000161000164000001007000000007000001000001000008
000023000035004005000035000000000035016244000035000000000035
016012000035000000000035250237000035000000000035016244000035
000000000035252252000035000000000035239000000035000000000035
251242000035000000000035252251000035000000000035250019000035
000000000035236000000035000000000035016011000035000000000035
250019000035000000000132000010000002000002000002000002000160
000163000160000190000008000008000113000066000002000002000056
000058000051000012000056000016000044000032000056000048000037
000042000025000058000021000054000021000037000007000032000002
000028000021000022000021000002000032000018000051000012000007
000000000000000035000000000161000182000004000001000001000007
000001000001000112000066000002000002000056000058000051000012
000056000016000044000032000056000048000037000042000025000058
000021000054000021000037000007000032000002000028000021000022
000021000002000032000018000051000012000160000191000160000161
000007000000000000000035000000000161000182000004000001000001
000034000002000028000000000035000000000161000182000004000001
000001000160000160000161000164000001007000000007000001000001
000008000023000035250019000035000000000035236000000035000000
000035016011000035000000000035250019000035000000000035016245
000035000000000035016011000035000000000035250237000035000000
000035016245000035000000000035236000000035000000000035250237
000035000000000026255255204204000000000132000010000002000002
000002000002000160000163000160000190000008000008000113000054
000002000002000051000054000002000028000021000022000021000002
000032000018000051000012000040000028000051000044000032000038
000021000054000021000034000002000028000007000000000000000035
000000000161000182000004000001000001000026000000000000000000
000007000001000001000112000054000002000002000051000054000002
000028000021000022000021000002000032000018000051000012000040
000028000051000044000032000038000021000054000021000034000002
000028000160000191000160000161000160000141000255