
Technically the shortfunctionsecond() does not need to create a deferred and return a promise, but I fell in love with promises and tend to implement everything with promises, sorry. It is the command d.resolve() in longfunctionfirst() that give the signal to start the next function. then() you ensure that the second function will be executed only after the first one has executed SetTimeout('alert("second function finished") d.resolve()',200) īy implementing a promise and chaining the functions with. SetTimeout('alert("first function finished") d.resolve()',3000) Promise = longfunctionfirst().then(shortfunctionsecond) The only library implementing promises I know is jquery so here is how I would solve the question using jquery promises : There are exhaustive explications of promises at : Promises/A and Promises/A+ The only way to force a javascript sequential execution that I know of is to use promises. I am back to this questions after all this time because it took me that long to find what I think is a clean solution : So that was a rubbish example but thanks to David Hedlund I see with this new example that it is indeed synchronous (along with crashing my browser in the test process!): Īs my ACTUAL issue was with jQuery and IE I will have to post a separate question about that if I can't get anywhere myself!

In this, the second function completes before the first function what is the simplest way (or is there one?) to force the second function to delay execution until the first function is complete? SetTimeout('alert("second function finished") ',200) SetTimeout('alert("first function finished") ',3000) I think callbacks may be useful but I cant seem to apply these in the simplest context. PERFORM READ-BOTH-FILES UNTIL EOF1='Y' or EOF2='Y'.I've only found rather complicated answers involving classes, event handlers and callbacks (which seem to me to be a somewhat sledgehammer approach).
#Sequential search in javascript download
it says-"Sorry but you are not authorized to view or download this Attachment".Īs told by dick you need to sort input files first Here is the link:īut am not able to view/download the code.

Download that source file to your system, review it and modify it to do what you need.
#Sequential search in javascript code
You need to sort both files in the same sequence (whatever you are trying to match on) if they are not already in this sequence.Īt the top of this COBOL part of the forum is a "Sticky" that contains working code for what you want to do. What you need is a 2-file match/merge that only reads each file one time.

Possibly the worst possible performance choice. I guess, neither the cobol table could be used as the number of records in both the files are not constant. Is there any method so that this opening and closing could be avoided? I am opting for a simple sequential search(reading 1 record from file1 and comparing with all the records in file2) and its consuming lot of time as the files are huge.Įach time end of file2 is reached am closing and reopening it so that the first record is fetched for the next iteration. I need to search whether the record present in file1 is also present in file2 and write the same to o/p. I have two flat files (file1 & file2) which i use in a program.The number of records in both the files are not constant (as they are daily updated). Sequential search without closing and reopening of a file Sequential search without closing and reopening of a file -IBM Mainframes
