I am relatively new to razor, so there is probably a lot wrong with this code, but I cannot get it to work. I am trying the grab the full path of a file, and get a loop of all files in that specific folders, and to output the name of the files in a list
First I declare a variable with the full path to a file like this: folder/folder/filename.jpg
Then I try to get the substring to this like folder/folder
Last I try to loop through the files in the folder, and output the full path to the files.
My code is
#foreach (LoopItem i in GetLoop("Products")){
string input = i.GetValue("Ecom:Product:Field.Images.Clean");
string folder = input.Substring(0, input.LastIndexOf("/"));
foreach(var file in GetLoop(folder.ListOfFiles)){
GetValue(folder)/file.GetValue(folder.FileName);
}
}
Error message I get is:
Line 28: Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
Line 32: 'string' does not contain a definition for 'ListOfFiles' and no extension method 'ListOfFiles' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
Related
trying to deploy resource group but getting below error
Error: Unsupported argument
on auto.tfvars.tf line 1:
1: resource_group = "india1111"
An argument named "resource_group" is not expected here.
code
code attached
You could specfiy the variable values with file .auto.tfvars instead of auto.tfvars.tf.
For example, the content of the variables.tf file.
variable "resource_group" {
type = string
}
The content of the .auto.tfvars file.
resource_group = "trafff"
To specify variable values in a variable definitions file (with a filename ending in either .tfvars or .tfvars.json) and then specify that file on the command line with -var-file:
terraform apply -var-file="testing.tfvars"
Terraform also automatically loads a number of variable definitions files if they are present:
Files named exactly terraform.tfvars or terraform.tfvars.json.
Any files with names ending in .auto.tfvars or .auto.tfvars.json.
Ref: https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files
I run my .fsx file like
>fsi A.fsx
In this file I read csv with CsvProvider that has to have path to csv data.
type Data = CsvProvider<"my_data.txt", ";", Schema
I need to pass file name as command line argument and it is possible
>fsi A.fsx my_data.txt
I can read it like
let originalPath = fsi.CommandLineArgs.ElementAt(1)
Problem is, that file name used in CsvProvider constructor needs to be constant and command line argument is not. How I can initialize CsvProvider from command line argument?
The value inside the angle brackes <"my_data.txt"...> specifies an example format file and is checked at compile time, hence the need for it to be a constant string. Assuming your .fsx script merely wants to load a different CSV file of the same general format, you would use
let contents = Data.Load(originalPath)
I am doing my project on incremental deep drawing using ABAQUS.
I am trying to import a text file of loop program into abaqus script so that there is no need of entering amplitude values manually.
But I am getting an error when trying to import the data using the following code
f = open('data_x', 'r')
values=f.read()
values=f.readline()
Error:
data_x is not defined
Error NameError: name 'data_x' is not defined points that you are using data_x as a name in your code, not as a string (with quotes).
This means that in your code, you probably have something like
f = open(data_x)
Python is trying to figure out which value is associated with data_x, which is a Python name, not a string. Since it's not defined before getting to that line, you are getting an error.
If you want to store the name of a file and then open a file, write
data_x = 'data_x.txt'
f = open(data_x)
You could also directly write
f = open('data_x.txt')
Whichever solution you adopt, make sure that a correct path to the file is passed to the function open, so that it could find the file.
I got a problem with setting a path to image within the resource file (.rc).
For some reasone it was not possible to concatenate defined string and the text.
e.g.
File1:
#define Path "Brand_1"
File2:
#include File1
Logo BITMAP Path "\Logo.bmp"
Borland resource compiler (5.4) throws error message: 39: Cannot open file: Brand_1
EDIT:
My question would be: Is is possible to combine the path for loading image using resource string variable and a string (file name).
Also, project I'm working on relates to a file (Logo.bmp) being present in two locations. I would like to have a switch (.bat file) to generate a different resouce file depending on requirements.
Thanks.
BRCC32 accepts -i as search path seperated by semicolon, so you could create a bat file like this
compile_res.bat
brcc32 -ic:\mypath1;c:\mypath2 resource_script
and you define your resource_script as normal, for ex:
resource_script.rc
myImg BITMAP Logo.bmp
myDOC RCDATA mydoc.doc
when you run the compile_res.bat, it will run the brcc32.exe with the search path, and having the bat file saves you from retyping the search path every time.
You're not concatenating anything. You're compiling to Logo BITMAP "Brand_1" "\Logo.bmp", and "Brand_1" isn't a valid path to a bitmap file.
#define in the resource compiler acts sort of like find/replace in a text processor - not exactly, but close enough in this case.
You might get by (untested) with removing the quotes and space between them, as long as there are no space characters in either the path or filename; otherwise, you're probably out of luck. (Not sure what you're trying to accomplish, anyway.)
I am generating static files on the fly but cannot get the URL function to work:
NB: here filename is a key-value returned by the controller
{{=P(A('Download ', filename,_href=URL('static', filename)))}}
generates an error:
type 'exceptions.SyntaxError'> when calling URL, function or function name required
However if I replace the filename variable with a string (as follows) the link is generated OK
{{=P(A('Download ', filename,_href=URL('static', 'abcis_data_42Data_.NO2.__.zip')))}}
Any ideas?
OK solved. filename is of type unicode and using str(filename) solves the problem.
I think what you might have to do here is go down the MVC hierarchy, so your code might look like:
{{=P(A('Download',filename,_href=URL(r=request,c='static',f=filename)))}}