error procedure
modou
macro test()
variable a,b,c,var1
variable/C cvar1
Make wave1
a=1
b=2
c=3
var1=a*b
cvar1=c*complex(a+1,b-1)
wave1=var1+real(cvar1)
variable a,b,c,var1
variable/C cvar1
Make wave1
a=1
b=2
c=3
var1=a*b
cvar1=c*complex(a+1,b-1)
wave1=var1+real(cvar1)
<pre><code class="language-igor"></xml> and <xml></code></pre>
tags to mark code; it is better to read.I'd advise to use functions instead of macros.
The 'procedure' should be terminated by an
end
.Please turn on the debugger (right click on the code window -> Enable Debugger); it might be helpful
Complex
declares a variable (see manual) I guess you are looking forcmplx
Change
Make wave1
toMake /O wave1
to overwrite the wave. It will prevent the "wave already exists error".Keep going,
HJ
January 26, 2017 at 07:17 am - Permalink
* Please learn how to post Igor Pro code in < igor >< /igor > tags.
* Please provide more details beyond the statement "This is broken, how do I fix it". What is the exact error message?
* Please learn how to use the debugger to track where the error arises. Include that with your posting.
* Please learn how to post the complete function. Yours has no return or end.
* Consider using Functions rather than Macros.
Now ... I see perhaps a few mistakes. The
make wave1
command makes a real wave with default dimensions. Is this a problem? Alternatively, thewave=...
command has no running index, so the wave will be entirely filled with the same value. Is this a problem?--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
January 26, 2017 at 07:25 am - Permalink
To the original poster: since it has no End statement, it seems like you didn't post the entire macro. If that is all your code, then the lack of End is at least the most basic problem. Please tell us what you are trying to accomplish and what the error is.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 26, 2017 at 10:16 am - Permalink
@JW: I assume the intention is to learn ;-)
Cheers,
HJ
January 26, 2017 at 11:47 am - Permalink
Yep. Duly noted.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
January 26, 2017 at 08:20 pm - Permalink
Are you referring to my editing of his post to add the tags? Point taken, but if I'm not mistaken, you folks lose the ability to edit your posts after some time passes. I can do it any time I like :)
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 27, 2017 at 10:20 am - Permalink
I just pointed out that this is most likely not real-world problem to be solved but rather a broken example how to get started.
Sometimes experienced folks tend to find solutions to problems that are just simple questions ;-) (happened to me last week...)
I think it's a good idea that 'we' loose the edit-option after some time; Otherwise, it usually leads to misunderstandings, confusion, misuse, and the end of the universe.
HJ
January 27, 2017 at 11:18 am - Permalink
macro test()
variable a,b,c,var1
variable/C cvar1
Make wave1
a=1
b=2
c=3
var1=a*b
cvar1=c*complex(a+1,b-1)
wave1=var1+real(cvar1)
edit wave1
end
There are always error in Procedure test
January 30, 2017 at 03:11 am - Permalink
end
problem?January 30, 2017 at 03:31 am - Permalink
This version of your macro works for me and returns the value "8" for each row in the wave. This is the expected result.
The primary change is to substitute "cmplx" for "complex" in line 9;
cmplx
is the Igor function for returning a complex number. (I think this was suggested by another reply to your post.) Also, I added the flag "/O" to the Make wave1 operation so that there is no error if you run the macro multiple times. This command instructs the interpreter to overwrite wave1 if it already exists; otherwise execution will stop with an error at that operation.Finally, as suggested before, put
<pre><code class="language-igor"></xml> before the first line of Igor code in your posts to this site and then put <xml></code></pre>
after the last line of code. Then the code will display as shown below. This has the effect of highlighting code, making it easier to read and prevents your code from being cut off because of the way this site interprets "<" and ">" symbols.variable a,b,c,var1
variable/C cvar1
Make/O wave1
a=1
b=2
c=3
var1=a*b
cvar1=c*cmplx(a+1,b-1)
wave1=var1+real(cvar1)
edit wave1
end
January 30, 2017 at 07:07 am - Permalink