Here's the scenario:
I have a parent script that calls about a dozen child scripts, one of which is a somewhat complex folder/file syncing operation. Each of the child scripts writes a variable to a batch file (e.g. variable.bat), which is then loaded by the parent script at next execution.
The folder syncing script chooses from a large list of folders based upon a parameter passed to it via the parent script.
The child script's SET command looks something like this:
ECHO SET pair-folder-%1=yes>>c:\variable.bat
This produces a variable at next run that is loaded by the parent script. Herein lies the rub: How do I script an action (via IF trap) that calls that variable the next time the child script comes around? I imagine my IF trap would look something like this:
IF %pair-folder-%1%=yes GOTO nopair
The problem is I can't seem to get the batch to interpret that correctly - I have tried nesting the variable a few different ways, using Delayed Expansion, etc. Is it necessary to map the parameter to a local variable first?
Basically, once the parent scripts calls variable.bat at next execution, how do I then reference that newly set variable from within the child script?
Since you are appending set pair-folder-%1=yes lines to variable.bat then you'll get varable.bat to establish an increasing set of pair-folder-* variables.
Now if you want to check whether pair-folder-% is set, then
if defined pair-folder-%1 ...
will do that for you.
If you want to find the value of pair-folder-%1 (ie it's not just set or not set) then
set "valuefound="
for /f "tokens=1*delims==" %%i in ( 'set pair-folder-%1 2^>nul' ) do (
if /i "%%i"=="pair-folder-%1" set "valuefound=%%j"
)
should do that - valuefound would be "set" to no value (ie undefined) if the variable is undefined else its value.
Related
While importing a csv file, a script that checks for additions/changes is triggered.
How can I skip this triggering? Or, how can I detect the Application import in my script to stop execution?
You could check whether interactive is true. For an Application Import, it will be false, like it is for all integration.
Alternatively, you could include an indicator in your data. For example, many objects have a SENDERSYSID attribute that you could set to IMPORT. Your script could then be adjusted to only do its job where sendersysid is null or sendersysid != 'IMPORT'.
To "include the indicator in your data", you will need to ensure the Object Structure you are importing against Includes, or doesn't Exclude, the attribute into which you will load your indicator. You then need to include that attribute in your data load with the value you use to indicate this record came from a data load.
For example, imagine you were loading work orders with an Object Structure called MXWODETAIL, and you were going to set SENDERSYSID to IMPORT. First, you would change your script to not do its processing when SENDERSYSID is set to IMPORT. Next, you would go to the MXWODETAIL Object Structure, load the Exclude/Include Attributes dialog and make sure SENDERSYSID does not have Exclude checked. Then, you would add the indicator to your data, like this:
SITEID,WONUM,DESCRIPTION,SENDERSYSID
BEDFORD,1010,"Your work order description",IMPORT
Now, when you load this data, your script will see your indicator and not do its processing.
I am trying to create a Lua program using Sublime and Corona. I want to fetch a webpage, use a pattern to extract certain text from the page, and then save the extracted text into a table. I am using the network.request method provided by Corona
The problem: The extracted text is not saving into the global variable I created. Whenever I try to reference it or print it outside of the function it returns nil. Any ideas why this is happening?
I have attached a screen shot of my event.response output. This is what I want to be saved into my Lua table
Event.response Output
Here is my code:
local restaurants = {}
yelpString = ""
--this method tells the program what to do once the website is retrieved
local function networkListener( event )
if ( event.isError ) then
print( "Network error: ", event.response )
else
yelpString = event.response
--loops through the website to find the pattern that extracts
restaurant names and prints it out
for i in string.gmatch(yelpString, "<span >(.-)<") do
table.insert(restaurants, i)
print(i)
end
end
end
-- retrieves the website
network.request( "https://www.yelp.com/search?
cflt=restaurants&find_loc=Cleveland%2C+OH%2C+US", "GET", networkListener )
This sounds like a scoping problem. From the output you give, it looks like networkListener is being called, and you are successfully adding the text into the restaurants table. Moreover, since you define restaurants as a table, it should be a table when you reference it, not nil. So by deduction, the issue must be that you are trying to access the restaurants table from somewhere where it is not in scope.
If you declare restaurants as "local" in the top level of a file (i.e. not within a function or a block), it will be accessible to the whole file, but it won't be accessible to anything outside the file. So the table.insert(restaurants, i) in your code will work, but if you try to reference restaurants from somewhere outside the file, it will be nil. I'm guessing this is the cause of the problems that you are running into.
For more details on scope, have a look at the Programming in Lua book. The book is for Lua 5.0, but the scoping rules for local variables have not changed in later versions of Lua (as of this writing, the latest is Lua 5.3).
I have a X12 file in which I have Batch Number at BHT03 which I need to put in flowVars. When I am trying to set it in a flow variable I am able to access the payload till 837 tree structure. The structure from Heading onwards doesnt appear when I enter a dot after "837". Even after writing the path manually it fetches null. Is there any constraint that we cannot set value in flowvars with tree structure?
The structure/path is as follows: (want to set the below value in flow vars)
#[payload.TransactionSets.v005010."837".Heading.0100_BHT.BHT03]
Able to set the flowvars value as below:
#[payload.TransactionSets.v005010.837]
Try using:
#[message.payload.'TransactionSets'.'v005010'.'837'.'Heading'.'0100_BHT'.'BHT03']
I have two transformations in the job.
In the first trasnformation - I get details about the file.
Now I would like to pass this information to the second transformation, I have set variable in the settings parameters of the trasnformation #2 and use Get Variables inside - but the values are not passed.
See attached sample: https://www.hightail.com/download/bXBiV28wMVhLVlZWeHNUQw
LOG_1 - displays file time, however LOG_2 and LOG_3 are not producing any value.
How can I pass variable across transformations and to parent job.
Try checking the box in the second transformation as below image:
Remove all the logs from the Job file you shared.
You may try reading this blog.
Hope this will resolve your issue :)
I have a series of 5 tasks, and would like guidance on how to run them in a specified order:
The order that I need:
Run the entire series.
And then only run these:
I checked out this and this resource, but am not sure how to apply them.
I would put all those tasks inside a For Loop Container. The iterations would be controlled by a simple Counter variable and limited for values 1 to 2.
Then for the last two tasks, I would set the Disable property using an expression, e.g.
#[User::Counter] == 2