PDA

View Full Version : converting question from c++ to powerbasic



Lionheart008
06-06-2012, 09:46
hello all.

I need some help to convert this little part from c++ to powerbasic (topic: class)



I need some help to convert this little c++ part to pbwin :) I am not very familiar with c++, sorry..


namespace fbLib
{
CLASS fbFile

{
PRIVATE: ' ?
std::STRING mt_filename; ///< NAME OF the current file.

...

public: ' ?
'/// Default constructor which exists only for the sake of allowing to construct files without filenames.
fbFile();
'' function, ok :)

'/// Initializes a fbFile with a filename
EXPLICIT fbFile(CONST std::STRING strFlename);

'/// Returns the name of the current file.
std::STRING getFileName() CONST;
'/// Changes the name of the current file.
void setFileName(std::STRING strFilename);

''pbwin: Function setFileName(byval strFilename as string) as string ' ?

void readmyDirectory() throw (Exceptions::CannotOpenFile, Exceptions::InvalidFormat, std::exception);
' what is "throw" ?
...

};
}


I am not very familiar with c++ so I am asking here for help, thanks in advance, best regards, frank

matthew
06-06-2012, 15:09
I don't own PowerBASIC so I can't help with the conversion but I noticed you asked what "throw" meant.

If an error occurs in that section of code at the end, such as a file cannot be found then the THROW statement will generate an error. In another file somewhere else, there'll be an accompanying CATCH statement that will deal with the error. You can find out more about Exception Handling in C++ here (http://msdn.microsoft.com/en-us/library/6dekhbbc.aspx).

largo_winch
06-06-2012, 17:24
you can disregard terms like

a) "std:" and "namespace fbLib" are not important for thinbasic/powerbasic convertion into functions or subs.

b) "privat" is for access to inner circle (e.g. functions) and that's not the safest modus like "protected" level (a) public (outer circle=all) , b) privat, c) protected (no access) )

c) "void" = function/subs (ok)

d) "class" constructs are using class/method/inheritance in powerbasic as I know and instances. it looks like a header file you are trying to convert? ;)


addendum: c# example:



class Employee2
{
private string name = "FirstName, LastName";
private double salary = 100.0;

public string GetName()
{
return name;
}

public double Salary
{
get { return salary; }
}
}

class PrivateTest
{
static void Main()
{
Employee2 e = new Employee2();

// The data members are inaccessible (private), so
// they can't be accessed like this:
// string n = e.name;
// double s = e.salary;

// 'name' is indirectly accessed via method:
string n = e.GetName();

// 'salary' is indirectly accessed via property
double s = e.Salary;
}
}



bye, largo

Lionheart008
13-06-2012, 11:22
thank you matthew and largo for infos, I will check this example again, yes it was a header file I wanted to translate, but the example I have saved from a c++ website wasn't complete I saw. there's a lot of more to convert and I will do it step by step. regards, frank