hexagon logo

VBScript Dir command returning incomplete results

Dear experts,

I have a PC-DMIS form with a ComboBox (named fd_ifoname) which I'm trying to populate with results from a Dir() file system call by means of the following super simple VBScript in the window's initialize event:

file = Dir(".\*")
While file <> ""
    fd_ifoname.AddString file
    file = Dir()
Wend​


It's working in principle, but the thing is that the results are incomplete. In particular, I'm trying to read out the contents of a subfolder of PC-DMIS's own routines, but it's only returning two *.MiniRoutines.xml files of the 21 non-hidden files (including *.prg, *.cad, and some more *.MiniRoutines.xml files). I'm having similar issues with almost every folder on our C and D drives (two partitions of the same SSD) with most folders appearing completely empty, but on the other hand, the Dir() function seems to be working just fine when listing files from a network drive. That's all the drives I was able to test with on our cleanroom PC and, in case you're wondering, the SSD is working perfectly fine. Also, I modified the above code to force the loop to go beyond the case of file == "" just to see what might still be coming, but the results stay empty.

Has anyone of you encountered this strange behavior and know a way around it? If not, can you think of another (preferably convenient) way to read out a list of files from within a form?

Thanks everyone!
Parents
  • Well, your thread title is VBScript... ;P

    Anyway, you could make a VBS that dumps the folder contents into a textfile that you then read from your form.

    Form -> Call dumpfolder.vbs
    Dumpfolder.vbs creates a textfile with the folder content
    Form -> read the textfile to get the folder content
Reply
  • Well, your thread title is VBScript... ;P

    Anyway, you could make a VBS that dumps the folder contents into a textfile that you then read from your form.

    Form -> Call dumpfolder.vbs
    Dumpfolder.vbs creates a textfile with the folder content
    Form -> read the textfile to get the folder content
Children
  • Am I missing something here? My understanding was PC-DMIS won't run a VBS. I end up always having to shell it with a BAT file. ex.

    @echo off
    cscript //nologo c:\cmm\scripts\script.vbs %1 %2



    Is there a simple way to run a VBS from within PC-DMIS?
  • I chose the thread title because it was my understanding that form events use the VBScript language. So, I take it that form event handlers have only a limited set of VBScript features available to them? Anyway, thanks a lot for your suggestion! I'll give it a try and report back if it'll work.

    In the manual I saw a way to trigger "BASIC scripts" from PC-DMIS directly. I don't know if this is the same thing as a VBScript (maybe without GUI-related stuff) or not. As far as I can tell from my very limited VBScript experience, the BASIC script example code in the manual looks an awful lot like it even though the file extension is different (*.bas). If I cannot get it to work through the BASIC script mechanism, you already provided me with an alternative triggering mechanism. Thanks you very much!