Results 1 to 4 of 4

Thread: converting question from c++ to powerbasic

  1. #1
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    52
    Posts
    944
    Rep Power
    111

    converting question from c++ to powerbasic

    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
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  2. #2
    Member matthew's Avatar
    Join Date
    Mar 2007
    Location
    England
    Age
    47
    Posts
    489
    Rep Power
    66
    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.

  3. #3
    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
    Last edited by largo_winch; 06-06-2012 at 17:28.

  4. #4
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    52
    Posts
    944
    Rep Power
    111
    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
    you can't always get what you want, but if you try sometimes you might find, you get what you need

Similar Threads

  1. PowerBasic 64bits
    By ErosOlmi in forum Power Basic
    Replies: 10
    Last Post: 18-12-2023, 16:04
  2. Help converting this math formula into code, please.
    By kryton9 in forum Math: all about
    Replies: 21
    Last Post: 06-12-2010, 04:00
  3. powerbasic question
    By TomLebowski in forum 3rd party tools
    Replies: 1
    Last Post: 01-06-2010, 15:38
  4. qt about powerbasic :)
    By Lionheart008 in forum Power Basic
    Replies: 5
    Last Post: 29-09-2009, 01:18
  5. What PowerBasic can do
    By ErosOlmi in forum Power Basic
    Replies: 7
    Last Post: 01-05-2009, 04:58

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •