Skip to main content
DenisKrumov
Participating Frequently
January 7, 2021
Question

Indesign progress bar doesn't show value

  • January 7, 2021
  • 2 replies
  • 942 views

Hi, guys!

I am trying to create a script that is searching for some images in over 100 fodlers. Since it takes much time to complete it, it would be nice the user to have a progress bar. I read the documentation for indesign scripting and also searched for some pregress bar scripting examples over the web, but it still seems I am doing somethig wrong - my progress bar does not show value.

 

I tried to:

alert the value of the progress bar, just to see if it is changeing - it does;

tried to hide/show the progress bar, hoping that it will refresh and will change it's value - still doesn't;

tried to use window.update() method - still nothing;

I even set a value bigger than 0 in the beginning just to see if is shows something, but it stil doesn't work...

 

Can some more experienced than me (I am relatively new to scripting) have a look at the code and maybe point out my mistake?

 

    var ArchCats = ArchFolder.getFiles()

    var ProgBarWin = new Window("window","Progress",[0,0,500,150])
    ProgBarWin.CatProgText = ProgBarWin.add("statictext",[50,20,450,40],"")
    ProgBarWin.ProgText = ProgBarWin.add("statictext",[50,60,450,80],"")
    ProgBarWin.progBar = ProgBarWin.add("progressbar",[50,100,450,130],0,ArchCats.length)

    ProgBarWin.center()
    ProgBarWin.show()

    for (j=0;j<ArchCats.length;j++) {
        ProgBarWin.CatProgText.text = "Searching cat "+j+" out of "+ArchCats.length
        ProgBarWin.progBar.value = j+1

        var ArchCat = ArchCats[j]
        if (ArchCat instanceof Folder) {
            var _sentFolders = ArchCat.getFiles("_sent")
            if (_sentFolders.length<1){
                alert("There is no _sent folder in catalog "+ArchCat.name+" It will not be processed")
                continue;
            }
            else {
                var ArchPages = _sentFolders[0].getFiles()
                for (arp = 0;arp<ArchPages.length;arp++) {
                    ProgBarWin.ProgText.text = "Searching page "+arp+" out of "+ArchPages.length
                    DefineFoldersAndSearch(ArchPages[arp])
                }
            }
        }
    }

 

 

Thanks in advance,

Denis.

This topic has been closed for replies.

2 replies

brian_p_dts
Community Expert
Community Expert
January 7, 2021

Try creating it as a palette instead of window. 

var ProgBarWin = new Window("palette","Progress",[0,0,500,150])
DenisKrumov
Participating Frequently
January 8, 2021

Thank you for your response, Brian!

 

I tired, but it still doesn't work. The strange thing to me here is that if  I "alert" the value of the progress bar, it changes, but the progress bad does not show it itself - stays "empty". Even if I set its starting value at somehing higher than 0, it doesn't change...

SychevKA
Inspiring
January 8, 2021

Hi, below script shows all files from specified folder,

maybe this is what you are looking for.

$.sleep(1000) - one second delay for demonstrates working

function get_files(path){
	var folder = Folder(path).getFiles()
	for(var i = 0; i < folder.length; i++){
		if(File(folder[i]).constructor.name == 'Folder'){get_files(folder[i])}
		else{ArchCats.push(File(folder[i]).fsName)}
	}
}

var ArchCats = []
get_files('C:/Download/')

var winbar = new Window('palette','Progress')
winbar.pro = winbar.add('progressbar', undefined, 0, ArchCats.length)
winbar.pro.preferredSize = [300,20]
winbar.pro_text = ''
winbar.pro_static = winbar.add('statictext', [10, 10, 310, 25], winbar.pro_text)
winbar.pro_count = 1
winbar.show()

for(var i = 0; i < ArchCats.length; i++){
	winbar.pro_static.text = ArchCats[i]
	winbar.pro.value = winbar.pro_count
	winbar.pro_count++
	winbar.update()
	$.sleep(1000)
}
winbar.close()

 

 

Legend
January 7, 2021