JasonHippy 739 Practically a Master Poster

BTW: Regarding the error where the compiler was complaining about not being able to find iostream, #include <iostream> may just need to be put at the top of your list of #includes.

Although that said, <stdlib> and <conio> are old C headers, they don't exist in C++ (well, they do, but not as <stdlib> or <conio> as I'll explain shortly!).

The very fact that the compiler is complaining that <iostream> cannot be found and at the same time isn't complaining about <stdlib> and <conio> not being found; leads me to believe that you may have set up a C project in Code::Blocks rather than a C++ project, which could also explain your problems! Are you 100% sure that you're working with a C++ project in C::B??

To check, you could try using the new project wizard in C::B to create a new C++ console project and then either paste your code in the generated main.cpp (but don't forget to qualify std::cout as outlined in my previous post!) or paste one of the snippets from my previous post into main.cpp and see how you get on.

If you do need to use any of the old C functions in stdlib and/or conio in a C++ project you'd typically need to use:

#include <cstdlib> // correct C++ header for the C stdlib.h
#include <conio.h> // uses the old C header, but requires .h at the end!

Also you should be aware that stdlib (or cstdlib) and conio …

JasonHippy 739 Practically a Master Poster

The thing you're forgetting here is that cout is a member of the std:: namespace, so you either need to explicitly resolve that cout is part of the std:: namespace by specifying std::cout every time you use it e.g.

std::cout << "\nhello";

Otherwise, to avoid having to explicitly resolve the namespace each time you use cout you can use a using statement. e.g.

#include <iostream>

using std::cout;

int main()
{
    cout << "\nHello";
    return 0;
}

Doing this will mean that you can use cout << "whatever"; rather than having to type std::cout << "whatever"; each time!

A lot of people also use using namespace std; This exposes the entire std:: library's namespace to your application, so you can use any of the std::library classes without having to qualify them with std:: e.g.

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string msg("\nHello");
    cout << msg << endl;
    return 0;
}

The above snippet uses std::string, std::cout and std::endl, but because we used using namespace std; , we don't need to resolve them.

Doing this is completely fine if you're using nothing but the std:: library in your program. But if you are using several libraries/namespaces, you need to be aware that some libraries could potentially contain classes with the same names as classes in other libraries/namespaces you are using. In which case, you run the risk of encountering namespace clashes/resolution errors. So the using namespace keyword should be used carefully!

Generally …

JasonHippy 739 Practically a Master Poster

Well, if you plan to write programs for Linux the choice is yours. You can use virtually any programming language, be it a popular modern language or a really old obscure one.

The real hard-core *nix programmers use a text editor like vi, scite or emacs to write their source-files and use the command-line to compile/build their programs. But there are IDE's available for most languages too, so you don't have to work with the command line if you don't want to!

If you're used to using an IDE like Visual studio. Then there are things like Monodevelop for C#, Code::Blocks for C/C++, Eclipse/Netbeans for Java, Idle for Python, Gambas for BASIC etc.

Most of the IDE's that I've seen in *nix are fully featured, generally well documented and pretty easy/intuitive to use. And there are plenty of learning resources posted all over the web for most languages too!

With regards to which languages are typically used for what in Linux:
Much of the underlying system is written in C and assembly (e.g. the Kernel and the core Linux OS components/tools). So if you plan to do low-level OS stuff (kernel modules, drivers etc) then C is a must and some knowledge of assembly may help too!
nasm is the main compiler used for assembly AFAIK.

The core of the Gnome desktop environment is C based.
The core of the KDE desktop environment is C++ based.

User-space/desktop applications can be programmed …

n_e commented: Good detailed answer +2
JasonHippy 739 Practically a Master Poster

As sergent and WaltP have pointed out:
Using standard C/C++ as far as possible is the best way of ensuring code portability.

At the risk of going off topic, using other cross-platform libraries/frameworks (boost, wxWidgets, GTK, QT etc.) can also make it easier to create cross-platform applications without using non-portable code (Obviously, this would only work if the libraries you're using are available on all platforms you intend to target!)

But in cases where very specific functionality is required, you may also have to do a bit of conditional compilation.
With conditional compilation you can enclose non-portable code with conditional pre-processor statements, so non-portable/platform-specific code is only compiled when the code is compiled on a particular operating system and/or using a particular compiler.

The only downside to conditional compilation is it can make the code a little messy and hard to read/understand. Especially if you plan to support a lot of different OS'es and compilers. It can also become a bit of a maintenance burden!


e.g. conditional compilation dependent on the operating system:

// use preprocessor to determine the platform:
#if defined(unix) || defined(__unix__) || defined(__unix)
# define PREDEF_PLATFORM_UNIX
#elif defined(_WIN32)
# define PREDEF_PLATFORM_WINDOWS
#endif

// standard C++ headers (should be cross-platform)
#include <iostream>
#include <string>
// ...
// Other standard headers here...
// ...

// platform dependant #includes
#if defined PREDEF_PLATFORM_UNIX
#include <unistd.h>
// ... 
// other Unix/linux specific headers
// ...
#elif defined PREDEF_PLATFORM_WINDOWS
#include <windows.h>
// ...
// …
JasonHippy 739 Practically a Master Poster

ok. I must really be missing something because when i put in a number the program runs but when i put in what is being passed (which is random numbers) it gives

Ex.

Point Point::midpoint( const Point &midPoint)
{

    Point middle;

    middle.setX(/* it only lets me set numbers, like 5, not what is being passed*/);
    middle.setY(/*same problem as above*/)

    return middle;
}

these are the errors it gives

Point.cpp:82: error: ‘number1’ was not declared in this scope
Point.cpp:83: error: no matching function for call to ‘Point::setY()’
Point.cpp:53: note: candidates are: void Point::setY(double)

this is where i set the random numbers

srand(time(0)); 
    number1 = rand() % 1000 ;
    number2 = rand() % 1000 ;

    pt1.setX(number1);
    pt1.setY(number2);
    pt1.print();

and when i try and set pt1 to the random numbers like you did with pt1(2.0,2.0) I get

Point.cpp:82: error: no matching function for call to ‘Point::setX()’
Point.cpp:48: note: candidates are: void Point::setX(double)
Point.cpp:83: error: no matching function for call to ‘Point::setY()’
Point.cpp:53: note: candidates are: void Point::setY(double)
make[2]: Leaving directory `/home/dcornell/2004/hw/HW6'

Sorry, I was running under the assumption that you were using a double to represent your x and y variables in your Point class and therefore assumed that your setX and setY member functions would also take doubles as parameters.

When calling your classes setX and setY functions, you need to make sure you are passing whatever type of values the functions are expecting.

Also what types are 'number1' and 'number2'? From what I can see there you haven't specified their type, which …

JasonHippy 739 Practically a Master Poster

Assuming that I properly understand what you're trying to do (I think I do!); Although the maths is basically correct, as this is a member function of your class, you'd probably be better off rethinking your function somewhat. Try to take a slightly more object-oriented approach.

Ignore the origin and the midpointX and midpointY things for now too, they are just background things that you are concentrating too hard on and overcomplicating things for yourself. There is a pretty simple and elegant solution that is staring you right in the face, yet still eludes you.

The bare essentials of what your function should be doing is returning a point which represents the midpoint between two points. The two points being 'this' point (the current instance of the Point class) and an instance of another Point object that is passed into the function.

The point returned by your function will contain midpointX and midpointY values. Both of which can be extracted from the returned Point by using the getX() and getY() accessors you have defined in your Point class

You've already got the function pretty much set up (apart from the parameters to your function, which are inappropriate and unnecessary IMHO, as the returned point will take care of these values!)
Here's a very strong hint:

Point Point::midpoint(const Point &refPt)
{
    Point middle;
    middle.setX( /* I'll leave you to work out */ );
    middle.setY( /* what goes in these calls */ );
    return middle;
}
JasonHippy 739 Practically a Master Poster

Are you sure you've used the correct namespace in the declaration of the CheckAdber instance ui at line 7?
e.g.

Ui::CheckAdber ui;

From your error messages, it looks as if the Ui namespace does not exist.
And you should bear in mind that namespaces are case sensitive, so the compiler would see 'namespace Ui' as a completely different namespace to 'namespace UI'.

So you need to take a look at the file 'ui_checkadber.h' and see what namespace is being used to contain the CheckAdber class and use that instead. I suspect the namespace is probably called UI rather than Ui, so something like this will probably work:

UI::CheckAdber ui;

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

@ OP: Mark as solved?? :)

JasonHippy 739 Practically a Master Poster

@OP:
The problem you're having is where you're trying to return a char array (buf) from your function; but the prototype/declaration of the function says that your function's supposed to be returning an int!

As you want to return a C-style string / char array, you should change the signature of the function to return a char* NOT an int!!

Although, one major problem I can see there is that you'll then be returning a pointer to an array of chars that is local to the dll function. So by the time the pointer has been passed back to the caller the char array will have dropped out of scope, leaving the pointer pointing to stray memory.
But to get around this, you could declare buf to be static!
e.g.

DLL_EXPORT char* codestamp(void)
{
    time_t now;
    struct tm *ts;
    static char buf[80];
    
    now = time(0);
    ts = localtime(&now);
    
    strftime(buf, sizeof(buf), "%d%m%Y%H%M%S", ts);
	return buf;
}

Alternatively, to avoid having static data in your dll, you could pass a pointer to a char array as a parameter to your dll function and change the return type to void. e.g:

DLL_EXPORT void codestamp(char *buf)
{
    time_t now;
    struct tm *ts;
    
    now = time(0);
    ts = localtime(&now);
    
    strftime(buf, sizeof(buf), "%d%m%Y%H%M%S", ts);
}

This would mean that callers of your dll function would have to set up a buffer to pass into the function. The dll function will then populate the passed-in buffer with the timestamp.

JasonHippy 739 Practically a Master Poster

The problem is not a linking error, it's a compilation error!

If you take a look at the definition of Playsound in mmsystem.h:

WINMMAPI BOOL WINAPI PlaySoundA( IN LPCSTR pszSound, IN HMODULE hmod, IN DWORD fdwSound);
WINMMAPI BOOL WINAPI PlaySoundW( IN LPCWSTR pszSound, IN HMODULE hmod, IN DWORD fdwSound);
#ifdef UNICODE
#define PlaySound  PlaySoundW
#else
#define PlaySound  PlaySoundA
#endif // !UNICODE

If your project is set up to use Unicode, PlaySound will use PlaySoundW. Otherwise it uses PlaySoundA.
The only differences in these functions are in the parameter lists. PlaySoundW takes a const WCHAR* (aka LPCWSTR) for the file-path parameter (pszSound), whereas PlaySoundA takes a const CHAR* (aka LPCSTR) for the file-path parameter.

From the error messages you've posted, PlaySound is using PlaySoundA, NOT PlaySoundW, which indicates that your project is NOT set up to use unicode.

The reason that you are getting an error message is because in your call to PlaySound you're converting the file path to a const WCHAR* (or LPCWSTR), which is only used by PlaySoundW. But the compiler is using PlaySoundA, which is expecting a const CHAR* (or LPCSTR) for the path, not a const WCHAR*. So the compiler is complaining that the parameters you're passing in your call to PlaySound do not match the parameters required for PlaySoundA.

Fortunately there are two simple ways of fixing this problem.
Either:
1. Set up your project to use Unicode, which will cause the compiler to use PlaySoundW when …

JasonHippy 739 Practically a Master Poster

The error messages are telling you all you need to know.

At line 52, tot should be initialised before it is used:
Consider your code:

float calculateAverage(int marks[])
{
	int tot; // NOTE: tot is NOT initialised and could hold any random/arbitrary value
	float avg;
	for(int i=1;i<=5;i++)
	{
		tot=tot+marks[i]; // Q. So what value does tot get assigned on the first iteration of the loop?  
				  // A. Random uninitialised value + marks[i] - Which is why the compiler is warning you!
	}
	avg=tot/5.0f;

	return avg;
}

compare that to this:

float calculateAverage(int marks[])
{
	int tot=0; // tot is now initialised to 0
	float avg;
	for(int i=1;i<=5;i++)
	{
		tot=tot+marks[i]; // Now this will work properly
	}
	avg=tot/5.0f;

	return avg;
}

The warning message about getch is saying that the name of the function has been changed to _getch.
But we've already stated in previous posts that getch() shouldn't be used any more. So perhaps consider using cin.get or std::getline to pause your program instead!
If cin.get doesn't work properly for you, you may also want to take a look at Narue's sticky "How do I flush the input stream?" found near the top of the C++ forum:
http://www.daniweb.com/software-development/cpp/threads/90228

JasonHippy 739 Practically a Master Poster

Another option is to flip the function over and evaluate the higher grades first. This way, only one conditional evaluation is needed instead of 2 and the code becomes more efficient.

Good point!

JasonHippy 739 Practically a Master Poster

You don't want to be using system("pause") anyway. That's another big no no that I won't go into here!

At the end of main, you could use something like a call to cin.get or std::getline before the return statement.

EDIT: You might also want to consider outputting a message telling the user that the program has finished or to 'press return to continue', otherwise the user (your teacher?) will probably think that your program is hanging!

JasonHippy 739 Practically a Master Poster

I'm assuming that you're just seeing a console window pop up and then disappear. If that's the case, then that's just the way it goes, there's absolutely no problem there!

You could put some code at the end of your program to make it wait for the user to press a key. However, as your program only writes to files and doesn't output anything to the screen I don't imagine that there's any point in pausing the program at the end.

Assuming that you're using Visual studio, you could try pressing ctrl-F5 to run the program without debugging, that usually prompts you to 'press any key to continue' at the end of a program. But again, as your program currently produces no output to the screen is there any point?

JasonHippy 739 Practically a Master Poster

Apologies if this is slightly off-topic, but the initialisation of the char isn't really the biggest problem you've got. The real problem with this code lies in this block of code (which I've enclosed in CODE tags and indented for you!):

char calc_grade(float total)
{
	char letter='\0'; // this is what the others are on about, this was not initialised
	if (total >= 0)   // However, the logic in the rest of this function is severely flawed!
		letter = 'F';

	else if (total >= 60)
		letter = 'D';

	else if (total >= 70)
		letter = 'C';

	else if (total >= 80)
		letter = 'B';

	else if (total >= 90)
		letter = 'A';

	else if (total > 100)
		cout << "Grade can not exceed 100" << endl;
	else
		cout << "Grade can not be a negative number" << endl;
	return letter; // If a negative number was passed in, in your original code, it's possible that an uninitialised value could be returned here!!
}

Consider this:
Your calc_grade function is called passing the value 85.5
So the value of total will be 85.5.
Now we go into your series of if statements and the very first condition is:
If total is greater than or equal to 0, letter is set to 'F'.
As total is 85.5 and is therefore greater than 0, letter is set to F.
In other words, whenever a value greater than 0 is passed-in, your function will award that person …

JasonHippy 739 Practically a Master Poster

Damn, after I went to the trouble of not naming it, everybody else does!
heh heh! XD.
I started writing my reply and then had to take a phone call. Didn't see the interim posts!

JasonHippy 739 Practically a Master Poster

@JasonHippy:
getch is not part of <cstdio> you're thinking of getchar() and/or getc().

@Fbody:
Ooops! My bad, you're right.... Goes to show how long it's been since I've had to use any of those nasty old C functions!
Without using the file-name of the header, that was in the console I/O header in C wasn't it? DOH!

@ OP: As Fbody pointed out, old non-standard functions like clrscr and getch shouldn't really be used any more. I neglected to mention that in my previous post! Ignore my suggestion of including cstdio, but the rest of my previous post still applies!

JasonHippy 739 Practically a Master Poster

Well for starters you haven't included the header for clrscr(), which I believe is only available for older borland compilers (C++ builder and Turbo C++ etc). clrscr() is not a standard C/C++ function and is therefore non-portable. From the looks of your posted output it also looks as if you're using Visual Studio, so clrscr() will not be available anyway, so you should probably remove this line of code!

If you want to use getch() at line 43 you'll need to #include <cstdio> which includes the old C-style IO functions.

To explain the warning you're getting at line 54:

avg=tot/5.0;

This simple line of code contains three different datatypes.
- avg is declared as a float variable
- tot is an int variable
- The literal value of 5.0 is implicitly treated by the compiler as a double.

Dividing an int value by a double value yields a value which will be a double. And as you're trying to store a double value (the result of the calculation) in a float variable, you're getting a warning from the compiler.

There are two ways of fixing this.
Either:
A. Change the type of avg to double rather than float
OR:
B. Change the literal value 5.0 to 5.0f
This tells the compiler that the value 5.0 should be treated as a float NOT a double and will allow the result of the calculation to be stored in avg.

JasonHippy 739 Practically a Master Poster

From looking at the code, I think the infinite loop is happening because:
1. You call delete on an Animal, causing the flow of execution to enter the Animal class destructor.
2. Where the Animal destructor iterates through the static std::map it attempts to delete the first animal object in the map. So the flow of execution goes into the destructor for the first Animal object in the map.
3. The destructor for the 1st Animal object in the map then attempts to delete the first animal object in the static map (oops, that's itself!).
Now the destructor for the 1st Animal object in the std::map will recursively call itself until the program eventually runs out of memory and crashes.

I haven't looked at the rest of your code yet, or ran it through a debugger or anything, but I think that's what's going on!

Surely the cleanup for a static singleton object like this should really be done when your application ends, not each time an object of that class is deleted!

Otherwise, if there is a need to update the static when an Animal or Animal derived object is deleted, perhaps you need to find and remove that particular Animal instances entry from the static std::map rather than trying to remove all of them.

Anyway, hope this is of some help!
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Burning the iso is all you should need to do.
Sounds like the iso was corrupted in some way. The ubuntu download sites usually provide an md5 checksum for all downloadable files.
After downloading a file, it's usually best to create an md5 checksum. This checksum should match the checksum provided by ubuntu. If it does not match, then the file is most likely corrupted.

JasonHippy 739 Practically a Master Poster

@OP:
In answer to your question about vectors, a vector of std::strings can hold any number of valid std::string objects. Whether or not they contain whitespace is completely irrelevant. As long as a string object is valid, the vector should be able to contain it!

Obviously it seems me that you think your vector is causing your problem, somehow only storing only the first word of each string your user enters. But in actual fact, you're almost certainly using an inappropriate method/function to get your string input from the user in the first place.

How strings are retrieved from the input stream and stored will depend on which function you use to get them from the user.

From what I've seen I'm assuming you're probably using std::cin or something similar which copies everything up to the first whitespace character, or the first return character (whichever is first) into the string object.
e.g.

std::string str;
std::cout << "enter a string: ";
std::cin >> str;
std::cout << "You entered: " << str << std::endl;

Using the above code snippet, if you entered 'super mario bros', because cin only gets everything up to the first whitespace character, the string will only contain 'super'. So when you subsequently push your string into the vector, the only thing that goes into the vector is the string 'super'.

In other words, if you are using std::cin to get strings in your program, then you are getting exactly what you …

Saith commented: Very nice explanation! It does some nice critical thinking of what you could possibly assume what the OP was requesting and revealing the steps to fix the entire logical problem instead of a simple code snippet. +2 if possible. +1
jonsca commented: Agreed. Good to see you posting again Jas! +7
JasonHippy 739 Practically a Master Poster

If there's no graphic interface, you may have to manually mount your usb drive (unless your OS happens to auto-mount drives).

NOTES: Before we start, This is completely off the top of my head, I've not got a *nix box in front of me to test any of this atm, but it should work. Apologies if there are any errors though! Also you should be aware that I tend to use debian based distros, so I've included use of sudo to get root access in the following guide. You'll need to substitute sudo for su, or whatever your distro uses to get root access.

Anyway, moving onward!
To manually mount, you'll need to do the following:

1. After plugging a USB drive into your machine, you need to use the lsusb command to see what devices are connected via USB and search the output for anything that refers to your USB stick.

If you can see something which refers to your USB stick (manufacturer, capacity etc.), you'll know for certain that your system has recognised the device and you can continue on to mount it.
But if you don't see anything, there's no point attempting to mount the device, as the OS has not detected/recognised it!


2. Assuming you found your device, next you'll need to get a list of connected drives using:

dmesg | grep -i "SCSI device"

Again take a look in the output for something that refers to …

alaa sam commented: thanks alot for your help +0
JasonHippy 739 Practically a Master Poster

Empathy is another program on Ubuntu which also uses several different chat protocols.

Up in the top bar of 10.04 and 10.10, there is an image of an envelope.
If you click on the envelope, a context menu will pop up and there will be an entry in there that says 'chat' (or 'set up chat accounts' if you haven't used it before)

If you click on this it will start Empathy and you can set up any chat accounts you have. If you've already got some chat accounts set up, you can simply start Empathy, add a new account and enter the details for your google account. Once that's done, you can chat to any of your online contacts on google chat... simple!

Empathy is also integrated into the desktop. Once you've started Empathy you can set your online status (available, away, offline etc) from the top bar of the desktop too!

JasonHippy 739 Practically a Master Poster

If it's not available in the Software Centre, or via Synaptic package manager; a stable version of Chrome is available directly from google as a .deb package. You can simply download the package and install it yourself!

Here's the link:
https://encrypted.google.com/chrome?platform=linux&hl=en&lr=all

Personally I'd check the software centre or synaptic first, I think the Ubuntu version of Chrome is called Chromium, so you might want to try searching for that first. If it's not there, then use the link above and you can download and install it yourself!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

GDB is a supremely powerful tool and is extremely useful.
As L7Sqr has pointed out; as with any tool, you need to learn how to use it properly before you reap the full benefits. And as with most things, this can take a little time to achieve. But it is time well invested IMHO!

If you prefer a graphical environment rather than doing it all via the command line, there are several graphical frontends available for gdb (DDD, kdbg being two listed by L7Sqr, but there are several others)

Code::Blocks also uses gdb for debugging on Linux. Again, the IDE acts as a convenient graphical front-end. Great for general purpose debugging, but to use gdb to its full potential; you can't beat doing it via the command line IMHO!

And if RTFM is getting you nowhere, there are gdb related tutorials posted all over the web. So googling for some tutorials might be an idea:
http://tinyurl.com/5ugq3fp

Anyway, that's my two pence on the matter!
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

The script you've written will work, you just need to pass the filename without the .cpp extension.

Where you've used '$1.cpp' in your script:
If you pass 'data.cpp' as a parameter when you run the script, '$1.cpp' will expand to 'data.cpp.cpp'. Which is why it's not working for you, the shell will be unable to find a file called data.cpp.cpp.

So to solve it you could do one of two things:

1. You could call your script and just pass the filename without the extension e.g.:

./buildit.sh ./data

BTW: For the sake of argument, we'll assume your script is called 'buildit.sh'.

Now $1.cpp will expand to data.cpp and g++ will attempt to build your file and the output will be saved to err.txt.

OR

2. Remove the .cpp file extension from your script:

#!/bin/bash
g++ $1 2> err.txt

Now you can call the script from the command line and get it to build data.cpp like this:

./buildit.sh ./data.cpp

And gcc will attempt to build the file and pipe any output into a file called 'err.txt'

Obviously, the above examples assume that the script and the .cpp file are in the same directory, if they were in different directories then you'd need to use the full paths to each.
So if you had the shellscript in a directory called 'scripts' in your home directory and the .cpp file was in a directory in home called 'cpp', then you'd drop to …

JasonHippy 739 Practically a Master Poster

I can't think of anything directly flash related that could be causing the problem.
If it works in IE it should work in FF. The browser shouldn't make flash behave any differently!

Usually the only things that can affect the way that flash objects appear in different browsers is the HTML used to embed the swf in the page.
Perhaps the HTML tags you've used work in IE but not in Firefox?!

Assuming the HTML tags are the problem, are you sure your swf is even appearing on the page in Firefox??

If the tags are the problem, the best way to embed flash movies into your HTML pages in a platform/browser independent way is with a free, open source javascript called swfobject.js. (google it, you should find it!). It can be used in your HTML pages to embed swfs without having to worry about the users browser type or version.

The javascript itself is really simple to use. Basically in your HTML page you pass the path to your movie (and its parameters) to the swfobject script. At runtime it will determine the type and version of the users browser and will dynamically generate the appropriate HTML tags to correctly embed the flash movie in the users browser. Simple!

I'd recommend swfobject.js to anybody wanting to embed flash into their website!


BTW: One another thing springs to mind. When you were testing in IE and Firefox were …

JasonHippy 739 Practically a Master Poster

Well, here's a link to the Adobe documentation for the FLVPlayback component:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html

I can't test this because I haven't got any of the AS3 components (I use the flex SDK rather than the Flash IDE nowadays), but according to the documentation there is a member of the FLVPlayback component class called seekBar. So you could try setting the 'enabled' property of seekBar to false.
e.g.

myFLVComponent.seekBar.enabled=false;

Do the same for the forwardButton and the backButton members to disable the ffwd and rewind buttons.

Like I said, I can't test it, but it might work!

Otherwise if that doesn't work, the Pro editions of Flash ship with the source .fla's for all of the FLVPlayback component skins. So you could grab a copy of the .fla for the skin you're using and edit it to remove the hitstate for the seekBar (it'll probably be a long, thin, purple, pink or blue overlay over the top of the seekBar, or perhaps a small square or rectangle over the slider).
Again, you can do the same for the forwardButton and the backButton. Then all you do is re-publish the skin and use it.

To help you to find the source .fla's there's a post towards the bottom of this page that might help:
http://www.kirupa.com/forum/showthread.php?t=287148

Otherwise, simply use a skin that doesn't include the forward/back buttons or the bar, or use the 'no skin' option and perhaps create some controls of …

JasonHippy 739 Practically a Master Poster

Any chance you could clarify this a bit further? I don't really understand what you're trying to achieve here!

Do you mean as soon as the swf has loaded, you want it to take a screenshot of the entire web-page??

If so, it sounds a bit unlikely to me as the swf will not be able to see anything external to itself. So it wouldn't be possible to take a screenshot of the entire web-page directly from Flash/AS3 (at least as far as I'm aware!)

You MAY be able to connect your swf to an external server-side script (javascript/php) which could retrieve the HTML for the page and generate an image of it. But again, I'm really not sure!

If it is possible, it would probably require quite a lot of work and resources to set up. What do you intend to do with the screenshot after you've got it?

theighost commented: Clear response, good suggestion +0
JasonHippy 739 Practically a Master Poster

What do you mean by 'scrub through'?
If you mean that you want to remove the fast forward/rewind controls, or the bar which shows the current progress through the movie, you can simply use an alternative skin for your FLVPlayback component.

Assuming you're creating your instance of the FLVPlayback component on the stage from within the Flash IDE, the easiest way to do this would be to select the instance of the component on the stage and open up the component inspector window by selecting 'Window->Component Inspector' in the main menu or by pressing Alt + F7.

In the 'Parameters' tab of the component inspector window, click on the 'skin' property and then select the magnifying glass, this will bring up a dialog which will allow you to select a different skin for your component, so you could choose one of the more basic skins which has only the play/pause button and the mute button (with no progress bar, volume control or FF/RW buttons).

Alternatively, you could select 'none', so your FLVPlayback component will have no controls on it. If you set the autoplay property to true, your movie will play from start to finish as soon as it has loaded, but the user would have no way to control the playback, so you'd have to control/monitor playback via actionscript if you wanted to allow the video to be played again.

Otherwise, if you really want to you could have a go at creating your …

JasonHippy 739 Practically a Master Poster

It's because you have a member variable in your class called 'count' and you're also using a local variable called 'count' in your setCount function.
So where you're doing:

count = count;

Because there are two variables in scope, it will only use the local one.
So the local one is assigning the value of itself to itself (if you follow me?!)
So the member variable doesn't get updated.
I recommend renaming the member variable to m_count. That way you can use:

m_count = count;

But take note that if you rename the member variable, you'd need to update your getCount function to return m_count too!

EDIT - Doh! Too late!

JasonHippy 739 Practically a Master Poster

On top of the comments made by Moschops, it seems blatantly obvious that you haven't got a file called countertype.h, you've put all of the code for your class into a file called countertype.cpp.
So you need to either rename countertype.cpp to countertype.h, or separate the code so that the declaration of the class is in a header file and the definition/implementation of your class is in a .cpp file with the same name.

The 'unexpected end of file' error is because you've forgotten to include a semicolon at the end of your class declaration.
e.g.

class myclass
{
...
}; // <<<---- class declarations end with a semicolon!
Moschops commented: This is a righteous post from the hippy community :) +3
JasonHippy 739 Practically a Master Poster

I'm not sure you've posted in the correct forum, I think you want the shell scripting forum!

Anyway, I think what you're after is this:

%USERPROFILE%\Desktop

So if you wanted to navigate into the current users Desktop folder in your .bat file, then you would use:

cd %USERPROFILE%\Desktop

Likewise, if you want to pass the path to the Desktop folder as a parameter to the executable you're calling, then in your batch file you could use:

program.exe %USERPROFILE%\Desktop

Or if the program you're calling requires a switch to be specified before the path, then you'll need to do something like this:

program.exe -X %USERPROFILE%\Desktop

where -X is whatever switch you might need to specify before passing the path.

Ancient Dragon commented: So I used the correct environment variable afterall :) +35
MasterGberry commented: Perfect explanation :) +0
JasonHippy 739 Practically a Master Poster

OK, well if I understand you correctly, you only want to load the clip into secondaryMenu_mc if the clip hasn't already been loaded.
In which case you'll need to use an if statement:

if(secondaryMenu_mc!='ImageGallery_WebAndPrint_FlashMenu.swf')
	secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_FlashMenu.swf');

But comparing the movieclip against the physical filename will NOT work at all and I can't think of any movieclip properties that could help with this comparison either!

However, I can see in your handler code that you are storing the previously activated button and the currently active button. In which case, after you've updated the current and previous buttons, you can simply compare 'this' against the previously active button. If they are both the same, then the current button was clicked before, so it is reasonable to assume that the clip is already loaded (or is being loaded), therefore you don't need to do anything more and can exit the function by calling return.
e.g.

function doClick() 
{
	var prevbtn:MovieClip = activebtn;
	activebtn = this;		// update pointer to current selection   
	prevbtn.onRollOut();		// return previously selected to normal
	this.gotoAndStop(1);

	// if 'this' button is the same as 'prevbtn', the correct clip is 
	// already loaded (or perhaps still loading!)
	if(this == prevbtn)		 
		return;		// so simply return!
	else if(this == button_Ad)	// else load the appropriate clip
		secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_FlashMenu.swf');
	else if(this == button_Website) 
		secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_GIFMenu.swf');
	else if(this == button_Logo)
		secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_GIFMenu2.swf');
}

Fingers crossed, that should solve your problem!

JasonHippy 739 Practically a Master Poster

You can create your elearning content in virtually whatever format you want, be it Flash, Director, Java applets or even plain old HTML and Javascript.

I haven't used director before, but I have used Flash to create elearning packages at a previous job. However, I think with director you may need to export your files as .swf's or some other projector file format. I suspect the .dir files are source files like .fla's in Flash..but I could be wrong!

Once you've got all of your course material together, you just need to use something like Reload Editor or eXe to package your courseware up into an IMS or SCORM package.
(I used to use Reload, never tried eXe!)

Also, if memory serves with SCORM and AICC, you may also need to use some javascript alongside your courseware to allow data to be passed back and forth between the VLE and the courseware (passing user name, test scores etc).. At least we did with the courseware at my previous job...I haven't worked in the elearning sector for a few years now and I'm more than a bit rusty, so please excuse me if I'm a bit vague on the details!

Anyway, I hope this is of some help to you!
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

As far as I'm aware, for obvious security reasons there is no way to directly write any kind of file directly from flash, however it is possible to use fscommand (in AS2) or the ExternalInterface class (in AS3) to send data to an external server-side script, which in turn can process the data and save files on the server. Upon successful creation of a file, external scripts will usually pass a hyperlink back into the .swf which will enable the user to download a copy of the file they created.

I've seen some online flash apps which allow you to create images or text files which use this method, but I've not really seen any of the back-end code.
I've certainly never seen it used to export mp3's! However, that said I couldn't entirely rule it out, it may be possible! If it's possible send bitmap data from a swf and then convert/save it via an external script, then it's reasonable to assume that you could probably do the same with an mp3!

I used fscommand in AS2 several years ago to get some flash based e-learning content to communicate with a content management system (passing user data and scores in and out), but I've never tried doing it with anything like images or sounds, so I wouldn't know where to start there.

And I've not used AS3's ExternalInterface class yet either, but take a look at this link. This should get you onto the right …

JasonHippy 739 Practically a Master Poster

That's a new one on me. Can't say I've ever seen that error myself!

I'd hazard a guess and say that the file is most likely corrupted and therefore useless!

If the .fla was created in a newer version of flash than you are using you'd normally get an error about it being an incorrect or unrecognised file format when you tried to load it. Whereas if it was created in an older version of flash than you're using, flash should still be able to load it.

So file corruption is about the only thing left that I can think of!

Have you tried re-downloading it from wherever you got it from? It may have gotten corrupted when you downloaded it.

If you download the file again and get the same error when you try loading it into flash, then it is most likely the copy on the server which is corrupt.

JasonHippy 739 Practically a Master Poster

No probs! Been a while since I did any AS2.
It's also been a while since I logged in here. Don't seem to get much time to myself nowadays, so I just check in here as and when I can!

Anyway, glad to have helped!

JasonHippy 739 Practically a Master Poster

In the highlighted 'if..else if..' block of code, you need to be using the equality operator == rather than the assignment operator.
e.g.

if(this==button_Ad){
	secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_FlashMenu.swf');
	} else
	if(this==button_Website) {
	  secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_GIFMenu.swf');
	} else
	if(this==button_Logo) {
	  secondaryMenu_mc.loadMovie('ImageGallery_WebAndPrint_GIFMenu2.swf');
	} 
   }

This might work depending on how you've done things in your fla!
I'm not sure what you're trying to achieve with the lines that were like this:

secondaryMenu_mc!='ImageGallery_WebAndPrint_FlashMenu.swf';

I could be mistaken, but those lines just look completely wrong!

Otherwise, if the first method does not work, and as long as button_Ad, button_Website and button_Logo are instance names of objects, you may have to try something like this for each of the if..else conditions:

if(this._name == "button_Ad")
// irrelevant code snipped
else if (this._name == "button_Website")
// irrelevant code snipped
else if (this._name == "button_Logo")
// irrelevant code snipped

Other than that, I'm out of ideas for now!

JasonHippy 739 Practically a Master Poster

The signature of your 'inviso' function is wrong.
try this:

function inviso(e:MouseEvent):void
{
	gotoAndPlay(56);
}

Oh and for future reference. To stop smilies from appearing in your post, if you use the 'advanced editor' you have the option to 'disable smilies in text'. That will stop smilies from being rendered in your text after you post!

:) <<--- See, posted with smilies disabled!

JasonHippy 739 Practically a Master Poster

As far as I'm aware; once you start booting from a Linux live CD, whatever OS is on the HD is completely ignored. So the resident OS will not be able to stop the machine booting from the CD (The BIOS settings usually determine whether boot from CD/DVD is allowed!). Similarly, once running a live distro, the resident OS shouldn't be able to stop the HD from being reformatted either.

If your Linux live CD's are failing to boot, it is most likely a hardware related issue (or your live CD is scratched/damaged/corrupt!). But it's not necessarily the HD, it could be something else, like a component on the motherboard or some other card/component which is damaged.

What happens if you remove the HD's and then try to boot into a Linux liveCD?
If it boots OK, then the HD's are definitely damaged. Otherwise if it doesn't, then there is some other hardware related issue!

One other thought springs to mind:
256Mb of RAM doesn't sound like enough to be able to run Ubuntu in Live mode (but I could be wrong), perhaps you could try a more lightweight Linux LiveCD. Perhaps something like Slitaz (which is Ubuntu based, but far more lightweight).

Try booting a lightweight distro's live CD without the HD's connected first and then if that works, try booting with the HD's connected.

If Slitaz (or whatever lightweight distro you choose to test drive) boots OK both times (with and …

JasonHippy 739 Practically a Master Poster

If you want the page to be opened in the current window rather than in a new window you can do this:

function buttonClickHandler(e:MouseEvent):void
		{
			navigateToURL(new URLRequest("http://maxxsunglasses.com/products/new.html"), "_self");
		}

Not sure if that's what you're after.

Other than that, the code you've posted for the click handler looks OK! I really don't see how it is opening the link without being clicked though! Unless you've put the code somewhere silly!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

I suspect this could be a flashplayer security related issue.

Open up your .fla and take a look at the publish settings ('file->publish settings' in the main menu).
When the publish settings dialog appears, click on the flash tab and check the setting of the 'Local playback security' field.
If it is currently set to 'Access local files only', you should try setting it to 'Access network only'.
OK the dialog to close it, save your .fla and then re-compile/re-export your .swf and upload the .swf to your server before testing it.

Note: After making this change your .swf might not work locally from within the flash environment, but it should work when it is uploaded to a server!
Try it and let me know how you get on!

Cheers for now
Jas.

JasonHippy 739 Practically a Master Poster

[snipped]
Oops, how did I end up posting here? This is the wrong thread!
Sorry about that!

JasonHippy 739 Practically a Master Poster

If you want to know how to create/use glow effects programmatically in AS3, there is a simple example in this old thread of mine!
http://www.daniweb.com/forums/post931271.html#post931271
(Take a look, but please don't ressurect the thread by posting in it, it is very old!)

JasonHippy 739 Practically a Master Poster

For starters, that is a C source file you are editing, NOT a C++ source file (so you've posted in the wrong sub-forum!).

As this is a C project you are editing, it is reasonable to assume that any project files or makefiles for the project will have the strict C mode flag set for any C++ compilers, so the code is parsed and compiled as C rather than C++. In strict C mode (as per standard C syntax) your compiler expects all variable declarations/definitions to be at the top of a block.
So the problem is due to where you are declaring and using 'r' in the middle of a block of code. What you need to do is declare r at the top of the block (the top of the function) and then use it later on in the function!

Try this:

// XorLib 1.0.0.0
// Copyright [c] 2009-2010 Shadowscape Studios. All Rights Reserved.

#define export __declspec (dllexport)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long filesize(FILE *f)
{
	long fs;
	fseek(f,0L,SEEK_END);
	fs = ftell(f);
	fseek(f,0L,SEEK_SET);
	return fs;
}

export double crypt(char *rn, char *wn, char *sb, double ss)
{
	FILE *rf, *wf;
	unsigned char fb[BUFSIZ];
	unsigned int bp, sp = 0;
	size_t bs;
	if ((rf = fopen(rn,"rb")) == NULL) { return 0; }
	if ((wf = fopen(wn,"wb")) == NULL) { return 0; }
	while ((bs = fread(fb, 1, BUFSIZ, rf)) != 0)
	{
		for ( bp = 0; bp < bs; ++bp )
		{ …
shadowscape commented: thanks alot for all your help, i can tell you how much that means to me +1
JasonHippy 739 Practically a Master Poster

@ Ganesh:
From what I can see the code is supposed to convert multiple spaces in the input string to single spaces! Try adding some extra spaces in your input string!

Looking at the code, it appears to work for short strings with multiple spaces, but I suspect the OP is using the code to remove extra spaces from very long strings. When longer strings are input the undefined behaviour pointed out by xuangcong is kicking in, causing the problem reported by the OP.

Personally, as the input string is a std::string, I'd use the std::library to replace multiple spaces with single spaces.
Off the top of my head, here's one way of doing it:

#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>

// Replaces multiple spaces in a string with single spaces.
void RemoveExtraSpaces(std::string *inTxt)
{
	// Set up a couple of iterators
	std::string::iterator it = inTxt->begin();     // this will point to our position in the string
	std::string::iterator endPos = inTxt->end();   // this points to the end of the string

	// iterate through the string
	for( ; it!=endPos; ++it)
	{
		if(*it==' ' && *(it+1)==' ')
		{
			// The characters at the current iterator position
			// and at the next position are both spaces,
			// so remove the current character
			inTxt->erase(std::remove(it, it, ' '), it+1);

			// move the iterator back to compensate for the space character we just removed
			--it;
		}
	}
}

int main()
{
	// Create a std::string
	std::string *myTxt = new std::string("This …
JasonHippy 739 Practically a Master Poster

In C++ there's more than one way to skin a cat. That isn't the only way of solving this problem. If you aren't supposed to be using arrays, you could try using two strings.

e.g. One to temporarily store user input and another to build the final output string.

So each time through your loop you get a line of input from the user, bung a newline ("\n") on the end and then append that to your output string.
Something like this:

output += string(input + "\n");

After the loop you then display the output string which you built during the loop. And not an array in sight! I'm not going to spoonfeed you all of the code though, I'll leave it to you to work it out. I think I've said enough! heh heh...

Hope that is of some help to you!
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Or you could use a 'Date' object... Date is a globally defined intrinsic class/type in AS3 so you don't need to import anything to be able to use it.

var today:Date = new Date(); // constructor sets a new Date object to the current system date/time by default
var current_time:number = today.valueOf(); // valueOf returns the number of milliseconds since midnight on january 1st 1970 (universal time!)

The Date class has loads of different options to return the date in various formats.
I think valueOf() is most likely the one you're after. Otherwise take a look at the documentation for the Date class. I'm sure you'll find a function in there that will suit your needs!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Well, it's been a considerable while since I originally posted this and nobody has actually answered the question.

However, I can report that I had similar problems with my current persistent USB install this evening. So I had another go at recovering my personal files from the USB stick and the solution is actually mind numbingly simple....Rather like I can be sometimes it would seem!

I really think you're gonna kick yourselves when you see this...I certainly did when I thought of it.

All I needed to do was:
1. Create a folder in the /media directory
e.g.

sudo mkdir /media/jas_casperfs

2. Mount the casper-rw file on the USB stick in the newly created folder:
e.g.

sudo mount -o loop /media/USBSTICK/casper-rw /media/jas_casperfs

{simultaneously rolls-eyes, facepalms and slaps head!}

Once the casper-rw file is mounted, you have access to the entire virtual drive and all of your documents!

Why didn't I think of trying that all of those months ago?? Grr!

It just suddenly occurred to me, I knew all along that Linux can mount and read most of the major filesystems from the last god-knows how long. But for some reason it never occurred to me before that casper itself is a filesystem. I never made that connection before, but as soon as I did, I figured it must be supported, so it should be possible to mount the casper-rw file like any other filesystem...

And it bloody works....Unbelieveable!