Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am getting syntax error on the line "module usingTable : TABLE =" and the word usingTable is highlighted red when I try to run this code in oCaml. I want to create table of the format as in the execution example bellow. What is wrong with it? The environment I am using is this one https://try.ocamlpro.com/fun-demo/tryocaml_index.html#path%3Dtries as I couldn't understand how to use cygwin or oCaml Bash in windows.
module type TABLE =
sig
type table
val emptyTable : table
val printTable : table -> string
val create_table : string * string list * (string list) list -> table
end;;
module usingTable : TABLE =
struct
let emptyTable = ()
let table = (string * (string * string list) list)
let rec printTable aTable = match aTable with
()->""
| (title, [data]) -> "\n"^title^"\n\n"^printTable(data)
| [(col,cont)::t] -> col^" "^printTable([t])
end;;
let atable = usingTable.emptyTable;;
let atable = ("Student", [("Id", ["2";"4";"7";"9"]);
("Name", ["Jim";"Linnea";"Steve";"Hannah"]);
("Gender",["Male";"Female";"Male";"Female"]);
("Course",["Geography";"Economics";"Informatics";"Geography"])
]);;
print_string (usingTable.printTable atable) ;;
As suggested in my comment, you may want to take a look at some additional references before focusing again on this code example (which contained not only syntax errors but also type errors).
For example, I'd suggest the following links:
the official OCaml tutorials, in particular you may first look at:
https://ocaml.org/learn/tutorials/functional_programming.html
https://ocaml.org/learn/tutorials/data_types_and_matching.html
https://ocaml.org/learn/tutorials/a_first_hour_with_ocaml.html
the so-called 99 problems in OCaml (a collection of quite standard exercises);
the Real World OCaml (an online book providing a comprehensive insight on OCaml);
the official OCaml reference manual;
and it might also be useful to have by hand the URL of the doc of the Stdlib module (i.e., the module of the standard library that is always loaded by default);
finally the OCaml programming guidelines page may be of some help if you are looking for a compilation of "standard style recommendations / best practices".
Related
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 2 years ago.
Improve this question
I tried to make a custom record type in order to store information of a product and call it in functions and procedures when needed. The code is written in a script compiler of a Delphi based ERP program. The problem I'm facing is that I get a syntax error on the record type definition when I execute the script.
I searched the internet for an hour or so, but wasn't able to find a solution. My script is as next:
Unit Paneelwand;
interface
Uses System, Classes, DB, SysUtils, Graphics, Types;
type
TPanel = record
Ref, PType : string;
Width, Heigth, Thickness, PriceSheets, PriceBitum, PriceHardboard, PricePermmFrameWidth, PricePermmFrameHeigth : float;
end;
implementation
//rest of the code
The syntax Error is on line 6 "TPanel = record". I can't find what I did wrong. Please, help?
By the way: the script is saved as a .psc file and referenced to in another script with its filename as a reference in the uses section. This works fine with other scripts I wrote. I also never had to add a unit line as the scripts are called by the file names.
I updated the script, by deleting the part that is not part of the problem and added the changes that were suggested below by the great people that try to help me. However, the error remains on the same line --> 'TPanel = record;'.
"Type" is reserved word. try other word
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
I am trying to compile C code and integrate it with Objective-C and Swift. The C code is the ImageMagick library.
typedef struct _ChannelMoments
{
double
I[32];
PointInfo
centroid,
ellipse_axis;
double
ellipse_angle,
ellipse_eccentricity,
ellipse_intensity;
} ChannelMoments;
The errors are on the line I[32];
Expected member name or ';' after declaration specifiers Expected ')'
Here are two photos of the issue
I don't see anything wrong with that line, but of course, I don't see the whole picture. A few things to try:
Delete everything between double and I, insert just a single
space and see if that changes anything.
Rename I to something else, e.g. JUNK, and see if that error goes
away. Other errors are likely to show up, though. It is possible
that I is #defined somewhere in some strange way.
Change PointInfo to some other type, e.g. int. Again, this will
break the code elsewhere, but this is a test to see if PointInfo is
the problem.
A word of warning: if you are trying to integrate C with Swift, you are likely to run into problems more interesting than this one. Good luck.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have table like this:
TABLE:
LOAD * INLINE [
SERVER
'SERVERNAME1'
'SERVERNAME2'
...
];
and loop:
FOR i = 1 to NoOfRows('TABLE')
LET v_TABLE = Peek('SERVER', $(i), 'TABLE');
LET v_SPECIFICATION = FieldName(1, $(v_TABLE));
trace $(v_TABLE);
...
STATEMENTS
...
NEXT
If I reload it, nothing happen, although for cycle runs thousand times, because the result of Peek() funcion is always NULL, not the value from table. Is the syntax incorrect, or is there some other mistake?
Sorry, my question was wrong. In Peek() function the third parameter wasn't string, but a variable (I didnt know that this will be mistake) and after many tries, I found out two things:
in my QV version 11.20 I have to call functions with variable parameter e.g. v_SPECIFICATION, not $(v_SPECIFICATION) (but not variable $(i), why???)
and rows in tables are numbered from zero (sometimes, as well), so this works for me:
LET v_TABLE = Peek('SERVER', $(i) - 1, v_SPECIFICATION);
Its really strange for me, but learning by doing...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to convert a SQL connection string into a String.Format line
The line that I need to convert is this:
WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID
Both thefull_name and cemetery_id are variables, but I have not idea how to construct the
String.Format line.
Seems you are looking for
Dim selectCommand = "SELECT * FROM mytable WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID"
Dim cmd = New SqlCommand(selectCommand, yourconnetion)
cmd.Parameters("#FullGraveNumber").Value = value1
cmd.Parameters("#CemeteryID").Value = value2
or
cmd.Parameters.AddWithValue("#FullGraveNumber", value)
First of all, ConnectionString is already a String with no parameters, it does not need to converted using String.Format. Usually stored in app.config, you feed it directly into SqlConnection object upon creation.
Part of the query that you have is also a String, but this time it may be substituted with parameters. However, please don't do so and use SQL parameters instead (see #huMpty's answer).
full_name and cemetery_id are SQL parameters, variables is something else.
My suggestion it to learn the terminology first, before you do any coding. No offense, it would benefit you a lot, because you would be able to ask a proper question. Proper question means a fast and qualified answer. Improper questions are usually closed. These are the rules of StackOverflow.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Which computer languages will allow code that dynamically extracts a variable name from a string, like user types in an argument "hhh", and the code then knows to reference a variable with the identifier: hhh? Thanks for your help.
Not exactly "dynamic variable creation", but you can get pretty much the same effect by using an associative array (a.k.a. dictionary or map). For example, in Python:
vars = {}
vars['x'] = 'hello'
vars['y'] = 10
With the above code, the keys 'x' and 'y' in the dictionary are like dynamic variables for all practical purposes, for example:
print vars['x']
> hello
vars['y'] + 6
> 16
As a matter of fact, under the hood many programming languages (Python, JavaScript, etc.) use a dictionary of bindings for implementing variables and scoping rules.
The associative array is probably a better idea to use, but just in case, php supports this without putting the code inside an eval function:
<?php
class ff {
var $u = "aagg";
}
$y = new ff();
$i = "u";
echo $y->$i;
?>