In my program getsizes i get this CLI response
25.Amiga OS 4:> ram:getsizes mywindow SCREEN Workbench ACTIVE
wrong number of arguments
usage: WINDOW/A,SCREEN/K, ACTIVE/S
Why do i get that error?
I would expect the command to be correct
In my program getsizes i get this CLI response
25.Amiga OS 4:> ram:getsizes mywindow SCREEN Workbench ACTIVE
wrong number of arguments
usage: WINDOW/A,SCREEN/K, ACTIVE/S
Why do i get that error?
I would expect the command to be correct
Maybe you have some typo in your code ;-)
Can you post the ReadArgs() codelines you're using?
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
I have this
Try removing the space in the TEMPLATE string before "ACTIVE/S".
Also some other unrelated notes:
Don't use strncpy()/strncat() unless you really need their weird behaviors for some reason, use the more sane strlcpy()/strlcat() instead (these are also available in utility.library as Strlcpy() and Strlcat() BTW).
Your args array has only room for two elements yet you need room for three. Also I suggest defining the arg indexes as an enum rather than hardcoding the numbers directly in your code:
Then you can define your args array simply as:
@JosDuchIt
Again, IIRC the problem is in this line:
where there is a space between a comma and a keyword.
There may be a space leading the comma, but not trailing.
Years ago I've constructed some testing examples about some DOS-functions, o.a. concerning ReadArgs(). It has been long since, but I think they're to be found in this archive: http://www.os4depot.net/index.php?function=showfile&file=development/example/dostutorials.lha
Hope I could help you out
OldFart
P.s.: ever thought of 'just in time' declaration of variables? You declare them first thing in this function, but as the function 'ReadArgs()' fails, they've been declared for naught.
Same goes for FreeArgs(), which is called whether ReadArgs() returns fine or not. It only needs to be called when ReadArgs() returns with a value.
@all
thanks for the hints
@Oldfart
Not yet. I am a "one-pogram" maintainer & i copied the style from the source i inherited.
There are some advantages to this style too:
i can easily enter (copying) debugging statements without worrying if the variables are blocklocal
as i am coding on my SAM without a debugger, it saves me time.
It is easier too see what variables are used too.
I am a bit lazy probably.
@salas00
Using the enum: I don't quite see how to modify my source. This is how it looks now. (Works OK.)
Could you modify it as you suggest? Thanks in advance.
The new template works fine
examples:
getsizes W NotePad S OrigynWebBrowser // ok
getsizes S OrigynWebBrowser // no active window there
getsizes S Workbench // my active shell
getsizes W "" S Workbench // my active shell
getsizes W CM.gc // ok
I rewrote your getsizes program for you as you asked me to:
https://dl.dropboxusercontent.com/u/26599983/getsizes.c
I removed the scrnname parameter from the get_active() function as it was not used for anything meaningful. I also made the window list scanning and window structure reading safer by surrounding this whole code section with LockIBase()/UnlockIBase() which in turn made it necessary to copy the data into a temporary data structure (struct WindowData) for printing later with print_wdata().
I also added the commandline I used for compiling to the source code. I recommend always using the following options "-Wall -Werror -Wwrite-strings" when compiling your own code using gcc. The -Wall and -Wwrite-strings are for enabling useful compiler warnings and the -Werror makes the compiler treat them as errors (especially useful when building larger projects where it can be easy to miss some warnings if there are a lot of different files to compile).
@salass00
Thanks for help & friendly coding lesson