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 7 years ago.
Improve this question
Everytime this program startup , the program runs after a server restart this error shows up:
startup:13: attempt to call nil
When i comment out that line of code the same happens to the line after that, and after that.
Until all those four lines are. (the round(math.floor) lines)
Then the program starts.
The four variables is needed in the program so it wont run well with them commented out.
If i now uncomment those lines the program starts perfectly and everything works.
Any reason what im doing wrong?
Functions must be defined before they are called (round is defined on line 72, but called on line 5). You can declare a function prior to defining it:
function program()
local round -- forward declaration
while true do
-- call function defined below
turbEnergy = round(math.floor(turbine.getEnergyStored())/100000,1)
-- function definition
function round(val, decimal)
end
Related
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 2 years ago.
Improve this question
As far I as my experience tells me, boolean variables usually named in format - is/has+noun/adj/verb, e.g isValid, isButton, hasClickedLink
But say there is the case where we have some flag which straightly tells whether to do something, like for example, clean to indicate that cleanup function should be automatically called in the end.
How to name such a booleans? Same clean - is ambiguous, looks like a method name more, but naming it toClean is, I don't know, too weird. Or should I name it like callCleanup?
Thanks in advance!
In this case i usually append the word wanted, which makes cleanWanted. In general, for boolean variables I also prefer to always let the last word be an adjective. This makes it very clear that it represents a truth value. The is/has prefix is often superfluous, as in hasClickedLink which is more concisely communicated with linkClicked.
methods are usually one word adjectives with a capitol at the start
maybe create a method that sets the flag
for example
void Clean(){
clean = True;
}
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 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 4 years ago.
Improve this question
I've just written this:
ldb.Update(emp.Code,emp.number, "text", String.Empty, "EMP", emp.scheme, emp.status, emp.tod, emp.timestamp, emp.Code, emp.oldfrmd)
Its far to wide! How can I shorten this method call? The problem is this isn't my method, so I can't edit it.
It depends on what your concern is:
Too many parameters? Can't really change that without changing the method, although you could introduce a proxying method containing fewer parameters, where each parameter may map to several of the original ones. It looks like you might want to make this a method on whatever the type of emp is, but it's hard to know without more information.
Just too wide on the screen? Use line continuations:
ldb.Update(emp.Code, emp.number, "text", String.Empty, "EMP", _
emp.scheme, emp.status, emp.tod, emp.timestamp, _
emp.Code, emp.oldfrmd)
(IIRC the "_" isn't actually needed in VB10.)
Too many characters? Introduce some local variables, potentially, shortening the eventual call to something like:
ldb.Update(code, number, "text", "", "EMP", scheme, status, _
tod, timestamp, code, oldfrmd)
(Although your overall code will be bigger, of course.)
Since you can't change the method signature, you must really be passing all those fields of emp into it. I would tend to write my own function (pardon my terribly rusty VB; I'm sure there's something wrong with this):
updateLdb(Employee e)
which simply called ldb's function and did nothing more. Using a single letter for a variable name is generally a bad idea, but in this case it saves your line 16 characters, and in a one-line function, "e" isn't particularly less informative than "emp". As Jon says if you move this function into the Employee class, you can get rid of another 16 characters - and it does appear to really belong there.
I would not use "e" as a variable or parameter name in any function that is longer than one or two lines, but in that small a scope, I think you can get away with it without significantly sacrificing readability.