Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

try code for 10 seconds, catch if not

Engaged ,
Jan 29, 2020 Jan 29, 2020

Hello everyone,

 

I wrote this code that works and does what I've wanted.

I want to add try/catch or something similar to that which will to execute a code and finish it within 10 seconds, if it isn't finished in 10 seconds then do something else.

 

Any help please?

TOPICS
Actions and scripting , Windows
587
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 29, 2020 Jan 29, 2020

Instead of alert() in bridge talk use your photoshop function:

 

function BT() {
	nD = new Date(); for(i = 0; i < 10; i++) {
		if (i < 10 && new Date() - nD < 10000)
			alert(i) else return false;
	}
	return true
}

(bt = new BridgeTalk()).target = 'photoshop', bt.body = 'BT = ' + BT.toSource()
+ '; BT()', bt.onResult = function(v) {return res = v.body} bt.send(10)

res ? alert('function A') : alert('function B')
Translate
Adobe
LEGEND ,
Jan 29, 2020 Jan 29, 2020
LATEST

Instead of alert() in bridge talk use your photoshop function:

 

function BT() {
	nD = new Date(); for(i = 0; i < 10; i++) {
		if (i < 10 && new Date() - nD < 10000)
			alert(i) else return false;
	}
	return true
}

(bt = new BridgeTalk()).target = 'photoshop', bt.body = 'BT = ' + BT.toSource()
+ '; BT()', bt.onResult = function(v) {return res = v.body} bt.send(10)

res ? alert('function A') : alert('function B')
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines