How create a print loading text like a linux terminal in Kotlin? - kotlin

Im tryng create a print effect who looks like a Loading Linux Terminal using the Koltin language.
I want a print show the sequence of a spin:
-\|/-\|/-
So after the sequence the word "-" will be fixed and print the next spin.
I want a print for 10 times.
OUTPUT:
--------/

Related

How to print the variable loaded and assigned from file

I am just learning machine learning using Octave. I want to load the data from the file and assign the data to one variable, then I just want to print the data to the console.The data in data.txt file is several-rows and two-columns matrix.
data = load('data.txt');
x = data(:, 1);
y = data(:, 2);
printf x;
printf y;
After executing the code, x and y will show up on the console, it is not what I expected, I just want to check the data loaded from the file, how to print this? Do I use wrong command?
Just type data in console and press enter . This will print the contents of the data variable with all its elements. Do NOT add a semicolon at end of line. This would suppress output.
The explicit way doing this is the command
display(data)

How to store a result to a variable in HP OpenVMS DCL?

I want to save the output of a program to a variable.
I use the following approach ,but fail.
$ PIPE RUN TEST | DEFINE/JOB VALUE #SYS$PIPE
$ x = f$logical("VALUE")
I got an error:%DCL-W-MAXPARM, too many parameters - reenter command with fewer parameters
\WORLD\
reference :
How to assign the output of a program to a variable in a DCL com script on VMS?
The usual way to do this is to write the output to a file and read from the file and put that into a DCL symbol (or logical). Although not obvious, you can do this with the PIPE command was well:
$ pipe r 2words
hello world
$ pipe r 2words |(read sys$pipe line ; line=""""+line+"""" ; def/job value &line )
$ sh log value
"VALUE" = "hello world" (LNM$JOB_85AB4440)
$
IF you are able to change the program, add some code to it to write the required values into symbols or logicals (see LIB$ routines)
If you can modify the program, using LIB$SET_SYMBOL in the program defines a DCL symbol (what you are calling a variable) for DCL. That's the cleanest way to do this. If it really needs to be a logical, then there are system calls that define logicals.

AMPL:How to print variable output using NEOS Server, when you can't include data and model command in the command file?

I'm doing some optimization using a model whose number of constraints and variables exceeds the cap for the student version of, say, AMPL, so I've found a webpage [http://www.neos-server.org/neos/solvers/milp:Gurobi/AMPL.html] which can solve my type of model.
I've found however that when using a solver where you can provide a commandfile (which I assume is the same as a .run file) the documentation of NEOS server tells that you should see the documentation of the input file. I'm using AMPL input which according to [http://www.neos-guide.org/content/FAQ#ampl_variables] should be able to print the decision variables using a command file with the appearance:
solve;
display _varname, _var;
The problem is that NEOS claim that you cannot add the:
data datafile;
model modelfile;
commands into the .run file, resulting in that the compiler cannot find the variables.
Does anyone know of a way to work around this?
Thanks in advance!
EDIT: If anyone else has this problem (which I believe many people have based on my Internet search). Try to remove any eventual reset; command from the .run file!
You don't need to specify model or data commands in the script file submitted to NEOS. It loads the model and data files automatically, solves the problem, and then executes the script (command file) you provide. For example submitting diet1.mod model diet1.dat data and this trivial command file
display _varname, _var;
produces the output which includes
: _varname _var :=
1 "Buy['Quarter Pounder w/ Cheese']" 0
2 "Buy['McLean Deluxe w/ Cheese']" 0
3 "Buy['Big Mac']" 0
4 "Buy['Filet-O-Fish']" 0
5 "Buy['McGrilled Chicken']" 0
6 "Buy['Fries, small']" 0
7 "Buy['Sausage McMuffin']" 0
8 "Buy['1% Lowfat Milk']" 0
9 "Buy['Orange Juice']" 0
;
As you can see this is the output from the display command.

Selenium IDE - storeval- how to copy and paste

3 security questions appearing on the screen like in random order like 1,3,2 or 2.1 and then 3:
Pets name? 2. City you were born? 3. School you attend?
Lets say that answer is a last word of each question. How to code it in Selenium ide. I guess to use GoToif, GotoLabel and StoreEval? Also, the answer should be stripped to one last word without space and "?"
You can store text or value in Selenium IDE.
The Command : storeText | storeValue (or storeAttribute if you want to stora an attribute of the element)
The Target must be a css or an xpath expression which can localize the appropriate element
The Value is the name of the new local variable in your Selenium IDE script
After using store command you can use your new variable like this: ${yourNewVariable}
For example:
storeAttribute xpath=//div[#id='name-day']#name nameday
echo ${nameday}
You can use while loop and goto function in selenium ide with this addon : https://addons.mozilla.org/en-us/firefox/addon/flow-control/
Some commands:
gotoif
while
gotolabel
Example:
store 1 answers
while storedVars.answers <= 3
echo ${answers}
...
store javascript{storedVars.answers++;}
endWhile

Android MonkeyRunner unable to enter text

I recently started using MonkeyRunner to test the UI of my Android application (I am also using Espresso but wanted to play around with MonkeyRunner). The problem that I am having is that I am unable to enter text into EditText fields using the automation script.
The script navigates through my app perfectly but it doesn't seem to actually enter any text on call of the MonkeyRunner.type() command.
Please find my script below.
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice, By
import commands
import sys
import os
# starting the application and test
print "Starting the monkeyrunner script"
# connection to the current device, and return a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
easy_device = EasyMonkeyDevice(device)
apk_path = device.shell('pm path com.mysample
if apk_path.startswith('package:'):
print "application installed."
else:
print "not installed, install APK"
device.installPackage('/MySample/MySample.apk')')
package ="com.mysample"
activity = ".SampleActivity"
print "Package: " + package + "Activity: " + activity
print "starting application...."
device.startActivity(component=package + '/' + activity)
print "...component started"
device.touch(205,361, "DOWN_AND_UP")
device.type("This is sample text")
MonkeyRunner.sleep(1)
result = device.takeSnapshot()
result.writeToFile("images/testimage.png",'png')
As you can see from the script above the text This is sample text should be placed in the EditText box. Both the emulator and screenshot that is taken show no text in the text field.
Am I missing a step or just doing something incorrectly?
Any help would be greatly appreciated!
I would rather use AndroidViewClient/culebra to simplify the task.
Basically, you can connect your device with adb and then run
culebra -VC -d on -t on -o myscript.py
The script obtains references to all of the visible Views. Edit the script and add at the end
no_id10.type('This is sample text')
no_id10.writeImageToFile('/tmp/image.png')
No need to worry about View coordinates, no need to touch and type, no need to add sleeps, etc.
NOTE: this is using no_id10 as an example, the id for your EditText could be different
First of all, I would not use the MonkeyRunner.sleep command, but I would rather use the time package and the time.sleep command. Just import the package
import time
and you should be good to go.
Moreover, I suggest you should wait some time between device.touch and device.type. Try with
device.touch(205,361, "DOWN_AND_UP")
time.sleep(1)
device.type("This is sample text")