I would like to know, if you have any idea of a routine to open all the tables of the Dictionary, to create them.
Without it being one by one
You could create a template that makes a procedure, and in that you just have something like:
#FOR(%File)
CREATE(%File)
#ENDFOR
In abc template, file control tab, unticking ‘defer opening files until accessed’ should open all dct files. You then need to rely on the dct file having the create option ticked.
Otherwise you’ll have to roll you own template
#code(createfiles,'create file')
#for(%file)
Create(%file)
#endfor
CREATE() would erase any existing files.
You may want to try to Open it First e.g.
#FOR(%File)
OPEN(%File, ReadOny+DenyNone)
IF ERRORCODE() = 2 THEN !File Not Found
CREATE(%File)
CntCreate += 1
ELSIF ERRORCODE()
CntError += 1
Message('Unexpected Error on file .... ')
ELSE
CntExists += 1
!No Close(%File) <-- ABC will trap this in a callback and show a message?
!Just force a shutdown (i.e. HALT) at the end to close all files
!If files are All Threaded and this was START() then they are closed
END
#ENDFOR
STOP(CntCreat &' Files were Created, '& CntExists &' Skipped that existed, '& CntError &' Errors?')
You usually cannot use IF Exists( Name(%File) )
because the NAME() normally does not have the file extension.
You would not want that exact code since it would duplicate those 9 lines for all Files. Instead either call a CreateFile Procedure(*FILE File2Create)
.
Or better add all the Files to a Queue. Then you could Loop the Queue to process them. Plus show it in a LIST so you can see what it will do, then know what it did. That’s what I would do a #CODE
template to add various %File attributes to a Queue.
100% agree that a create without a check for existence is dangerous. I’d go further and say that a create attribute on a clarion file which even allows clarion to create a file is dangerous. I’m assuming that Thales wants this to create a database initially. Personally I don’t like letting clarion decide what datatypes things are going to be, and I’d be writing a script and having clarion execute that.
The DCT can be setup with CREATE the way you typically want it, i.e. as you prefer usually OFF, but you may have some work/temp files with Create ON.
To create All the Files make a separate APP that builds as an EXE.
In Global File Control you can override the DCT so All Files have CREATE.