How to change the definition of a command to refer to a different action - inform7

I want to create a new action called washing, as follows:
Understand "wash [something] with [something]" as washing.
Understand the command "clean" as "wash".
However, the Inform7 standard rules define a number of synonyms for rub, one of which is clean:
Understand "rub [something]" as rubbing.
Understand the commands "shine", "polish", "sweep", "clean", "dust", "wipe" and "scrub" as "rub".
The result is that I get a compiler error:
Problem. You wrote 'Understand the command "clean" as "wash"': but 'understand the command ... as ...' is only allowed when the new command has no meaning already, so for instance 'understand "drop" as "throw"' is not allowed because "drop" already has a meaning.
How can I tell Inform to switch the meaning of the clean command from rub to wash without affecting the rest of the rub definition at all?

From section 17.3 of the manual, you use as something new:
Understand the command "clean" as something new.
This will remove the word from the dictionary, but leave the old synonyms in place, i.e., it won't affect the rubbing action. And afterwards you can then define it as a synonym for your new washing action.
However, consider that many of the rubbing verbs could apply to washing. Instead of reassociating the "clean" verb, you could just redirect the rubbing action to the washing action for certain objects:
Instead of rubbing the dishes:
try cleaning the dishes.
Then you'd get all the verbs. Some of them might not make full sense, but they're unlikely to be used by the player, and the parser accepting extra commands that don't quite make sense is nowhere near as big a problem as the parser rejecting commands that do make sense.

Related

effectively accessing first item in object

On input consider db-dump(from dbeaver), having this format:
{
"select": [
{<row1>},
{<row2>}
],
"select": {}
}
say that I'm debugging bigger script, and just want to see first few rows, from first statement. How to do that effectively in rather huge file?
Template:
jq 'keys[0] as $k|.[$k]|limit(1;.[])' dump
isn't really great, as it need to fetch all keys first. Template
jq '.[0]|limit(1;.[])' dump
sadly does not seem to be valid one, and
jq 'first(.[])|limit(1;.[])' dump
does not seem to have any performance benefit.
What would be the best way to just access first field in object without actually testing it's name or caring for rest of fields?
One strategy would be to use the —stream command-line option. It’s a bit tricky to use, but if you want to use jq or gojq, it’s the way to go for a space-time efficient solution for a large input.
Far easier to use would be my jm script, which is intended precisely to achieve the kind of objective you describe. In particular, please note its —-limit option. E.g. you could start with:
jm -s —-limit 1
See
https://github.com/pkoppstein/jm
How to read a 100+GB file with jq without running out of memory
Given that weird object with identical keys, you can use the --stream option to access all items before the JSON processor would eliminate the duplicates, fromstream and truncate_stream to dissect the input, and limit to reduce the output to just a few items:
jq --stream -cn 'limit(5; fromstream(2|truncate_stream(inputs)))' dump.json
{<row1>}
{<row2>}
{<row3>}
{<row4>}
{<row5>}

How to conditionally prevent an include file from being executed with Progress ABL?

To those who know,
How does one conditionally prevent an include from being executed in Progress ABL? Is that even possible? If not what do you purpose?
Based on user selection - here is an example:
If checkBox = yes then
{randomInclude.i}
Else
"Do remaining things"
You might need to share the code of your include file to make your request clearer to us.
TheDrooper's answer shows how to do it based on a compile time condition. Your sample seems to be based on a runtime solution. In that case I'd do:
If checkBox = yes then do:
{randomInclude.i}
end.
Else do:
"Do remaining things"
end.
The do-block is required as you just don't know how many statement are inside the include file.
When you define an include file in your program, the contents of the include are placed in your program at that position. In your example, whatever is in randominclude.i is stuck in the "then" condition. As Tom said, you probably just need to wrap it in a DO-END block. You can also put that in the include file.
You can also conditionally include a file at compile time. Suppose this is the contents of randominclude.i:
MESSAGE "Included" VIEW-AS ALERT-BOX INFORMATION.
You can define a preprocessor in your program to add the include:
&SCOPED-DEFINE UseIt
&IF DEFINED(UseIt) &THEN
{randominclude.i}
&ENDIF
Run that and you'll get an "Included" pop-up message. But change the preprocessor to this:
&SCOPED-DEFINE DontUseIt
Run the program now and nothing will happen because "UseIt" is no longer defined so randominclude.i is not included in the program.

How to dynamically search/replace text with update in XQuery (exist-db)

My intention is to somehow clean source files automatically. How to do that in XQuery? (I am not interested in reconstructing the document in memory and storing it as a new one.) It is quite easy to do something similar in case of short and simple elements addressed directly, however, I can’t figure out how to do that dynamically for all the text nodes, if possible.
I would expect something like this could work:
update replace $div[contains(., 'chapter')] with replace(., 'chapter', 'Chapter')
This throws err:XPDY0002 Undefined context sequence for 'self::node()' [source: String]
Apparently, there is a problem in addressing the context with . in the replacing function. But maybe I don’t understand the update thing in general. I am only inspired by the bottom of this article.
Expression to the right of with is independent from expression to the left. So an explicit node/context is needed on both part :
update replace $div[contains(., 'chapter')] with replace($div, 'chapter', 'Chapter')

How to get and set the default output directory in Robot Framework(Ride) in Run time

I would like to move all my output files to a custom location, to a Run directory created based on Date time during Run time. The output folder by datetime is created in the TestSetup
I have function "Process_Output_files" which will move the files to the Run folder(Run1,Run2,Run3 Folders).
I have tried using the argument-d and used the function "Process_Output_files" as suite tear down to move the output files to the respective Run directory.
But I get the following error "The process cannot access the file because it is being used by another process". I know this is because the Robot Framework (Ride) is currently using this.
If I dont use the -d argument, the output files are getting saved in temp folders.
c:\users\<user>\appdata\local\temp\RIDEfmbr9x.d\output.xml
c:\users\<user>\appdata\local\temp\RIDEfmbr9x.d\log.html
c:\users\<user>\appdata\local\temp\RIDEfmbr9x.d\report.html
My question is, Is there a way to get move the files to custom location during run time with in Robot Framework.
You can use the following syntax in RIDE (Arguments:) to create the output in newfolders dynamically
--outputdir C:/AutomationLogs/%date:~-4,4%%date:~-10,2%%date:~-7,2% --timestampoutputs
The above syntax gives you the output in below folder:
Output: C:\AutomationLogs\20151125\output-20151125-155017.xml
Log: C:\AutomationLogs\20151125\log-20151125-155017.html
Report: C:\AutomationLogs\20151125\report-20151125-155017.html
Hope this helps :)
I understand the end result you want is to have your output files in their custom folders. If this is your desire, it can be accomplished at runtime and you won't have to move them as part of your post processing. This will not work in RIDE, unfortunately, since the folder structure is created dynamically. I have two options for you.
Option 1: Use a script to kick off your tests
RIDE is awesome, but in my humble opinion, one shouldn't be using it to run ones tests, only to build and debug ones tests. Scripts are far more powerful and flexible.
Assuming you have a test, test2.txt, you wish to run, the script you use to do this could be something like:
from time import gmtime, strftime
import os
#strftime returns string representations of a date-time tuple.
#gmtime returns the date-time tuple representing greenwich mean time
dts=strftime("%Y.%m.%d.%H.%M.%S", gmtime())
cmd="pybot -d Run%s test2"%(dts,)
os.system(cmd)
As an aside, if you do intend to do post processing of your files using rebot, be aware you may not need to create intermediate log and report files. The output.xml files contain everything you need, so if you don't want to create superfluous files, use --log NONE --report NONE
Option 2: Use a listener to do post processing
A listener is a program you write that responds to events (x_start, x_end, etc). The close() event is akin to the teardown function and is the last thing called. So, assuming you have a function moveFiles() you simply need to create a listener class (myListener), define the close() method to call your moveFiles() function, and alert your test that it should report to a listener with the argument --listener myListener.
This option should be compatible with RIDE though I admit I have never tried to use listeners with the IDE.
At least you can write a custom run script that handles the moving of files after the test case execution. In this case the files are no longer used by pybot.

Lotus Notes #formula language: Order of Actions wrong?

I have defined an action with the following two commands:
#Prompt([...]; "1");
#Command([ToolsRunMacro];"(AGENT)");
#Prompt([...]; "2");
#If(#GetProfileField("PrivateProfile";"LENGTH";#UserName))>0;#PostedCommand([Compose];"FORM");"");
#Prompt([...]; "3");
But with the #Prompt commands I found out, that first of all each of the #Promptmessages (1-3) are displayed and after that the AGENT runs. But as the AGENT manipulates the LENGTHfield, the #IF statement compares an 'obsolete' value.
Maybe each statement is executed at once? If yes: how can I prevent the agent from this behavior?
I would appreciate any help!
The [ToolsRunMacro] command will always run after all #Functions have executed first. There is no way to change this.
You can get a list of what commands will execute straight away vs after other functions that execute at the end, in the infocenter documentation.
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_COMMAND.html
Also something to be aware on your code is that Profile documents are cached. So you might not in all cases see any changes made to the document straight away.

Resources