Erlang store file contents in a list [closed] - binary

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
code
read_CNF_File(FileName)->
case file:read_file(FileName) of
{ok, Data} -> print(binary:split(Data, [<<"\n">>], [global]));
{error, Reason} -> Reason end.
print([]) -> ok;
print([L|List]) ->
L,
print(List).
[Pic Related] How do I store contents from a file into a list (ideally a list of every line), if I try to io:fwrite As in read_CNF_File it seems to store it the way I want, however once I try to call print with that it just passes As as an empty list, thanks.

It is your print function that does nothing.
If you pass it à non empty list, it removes the first element (A in your code), the statement A, does nothing, and then recursively call itself with the tail of the list, until it is empty a' finally returns OK.

Related

How to set more than one potential arguments for Keyword Element Should Contain from SeleniumLibrary in Robot Framework [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Could anyone help me with the following situation:
I need to check the value of a status cell in a table on a web page that can potentially have one of several different values (strings), for example: imported, done, failed.
I am using the keyword Element Should Contain from the SeleniumLibrary and would like to validate as a positive result, if the value is either imported, or done.
So far I only know how to check only for one of those, for example for imported, by using as an argument for the expected result - imported, however I need that in both cases, either imported or done, to be considered as passed.
Thank you very much in advance!
Suppose you can use for your purpose something like the following:
*** Settings ***
Library SeleniumLibrary
Test Teardown Close Browser
*** Variables ***
${BROWSER} Chrome
${URL} https://stackoverflow.com/questions/64679739/how-to-set-more-than-one-potential-arguments-for-keyword-element-should-contain
${ELEMENT_LOCATOR} //*[contains(text(), 'Ask Question')]
${EXPECTED TEXT 1} Ask Question
${EXPECTED TEXT 2} Anything else
*** Test Cases ***
Test with two acceptable values
Open Browser url=${URL}
... browser=${BROWSER}
${element}= Get webElement locator=${ELEMENT_LOCATOR}
${bool_result}= Set variable if '${element.text}' == '${EXPECTED TEXT 1}' or '${element.text}' == '${EXPECTED TEXT 2}'
... ${True}
... ${False}
Should be true ${bool_result}
... msg=Expected that element with locator '${ELEMENT_LOCATOR}' contains text '${EXPECTED TEXT 1}' or '${EXPECTED TEXT 2}', but got '${element.text}'
Close Browser
Here I've just created the boolean variable with the result of the comparison of my element's text and the acceptable two values (${EXPECTED TEXT 1} and ${EXPECTED TEXT 2}).

run function in function [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm new to Octave and I've a script that work in matlab that have following structure :
function []=myFunctionName()
...
a='path';
b=2;
c=5
d='x';
[x,y]=lecFunc(a,b,c,d);
plot(x,y);
...
function [k,t]=lecFunc(pt, nF, nS, val)
....
fid=fopen(pt,'r');
k=fread(fid,[1,N],'real*4');fclose(fid);
t=linspace(tmin,tmax,nt);
etc ...
And I get the error :
error: 'lecFunc' undefined near line 141 column 10
I couldn't understand why... I try to seprate the functions with endfunction and also put the function lecFunc at the top, but it still not work...
Could someone help me to understand this difference between matlab and octave ?
Thanks a lot !
You use lecFunc in myFunctionName. Try to define lecFunc before defining myFunctionName

invalid command name in TCL [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
invalid command name "if{0}{"
Giving me an error, for that I have find how many cell in the file.
Where am I making a mistake?
Update::::::::::::::::::::::::::::::::::::::::::::::::::::::::
I am having an issue while sorting an array...
It says
enter image description here
Since the last element is integer, still it says "expected integer but got...
Where am i making mistake?
You must place a space between 'if' and the opening brace.
Basicly, the Tcl interpreter tokenizes commands by searching for whitespace, while at the same time substituting stuff inside []. So first, the regexpr is evaluated, yieling 0 and togehter with the remaining characters this yields the command name.

How to write a function output into .txt file? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have to write a function that produces random(parameter) integers i have to write random output of this funtion into .txt file. Also i have to find max and min integers from this function (write them into .txt too)
I cant find any tutorial about this subject. Want to use "a+" as writer.
Firstly, please have a look online for tutorials on how to write to a file. There are loads of free resources online.
You have already done a lot of the work and only needed few more lines
import random
def createRandomNumberFile(min, max, count, outputFileName):
outputFile = open(outputFileName, 'a+')
for item in range(0, count):
randomNumber = random.randint(min,max)
outputFile.write(randomNumber)
outputFile.close
Explanation - As you have assigned the file using the 'a+' mode (appending mode) to a variable (outputFile) you can simply use this variable to write to the file and then later close file (closing the file isn't always necessary but is good practice).
Hope that helps

Remove element from JSON object by value [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have the next JSON object
console.log:
Object {0: "/files/f6/bd/05/a9/medium/f6bd05a970c63b77eae164a607441818.jpeg",
1: "/files/ff/54/e3/17/medium/ff54e317d47631661eafeec6638ec530.jpeg",
2: "/files/b3/27/63/17/medium/b3276317020322ef77ac39447075286e.jpeg"}
And I need to remove element from this object by this string:
/files/f6/bd/05/a9/medium/f6bd05a970c63b77eae164a607441818.jpeg
I read a plenty of solutions for this question but all of them was about object with not numeric indexes. I use jQuery for it.
Please help me with function for my trouble. Thanks in advance.
Iterate through the object to find the value and delete the key once found:
// Assuming your object is called "foo":
for ( var k in foo ) {
if (foo.hasOwnProperty(k)) {
if (foo[k] === '/files/f6/bd/05/a9/medium/f6bd05a970c63b77eae164a607441818.jpeg') {
delete foo[k];
}
}
}
console.log(foo);