Recent Posts

Pages: 1 2 3 4 5 6 7 8 9 10
1
General Discussion / Re: I realize this may be be a dumb question. . .
« Last post by John Strasser on July 19, 2017, 01:40:25 AM »
Thanks Jose. I'll try again when I get home. It might be an issue on my office computer
2
General Discussion / Re: I realize this may be be a dumb question. . .
« Last post by José Roca on July 19, 2017, 01:24:12 AM »
The forums are there: https://forum.powerbasic.com/

Maybe you're using a differen address. It was changed to use https instead of http.
3
General Discussion / I realize this may be be a dumb question. . .
« Last post by John Strasser on July 19, 2017, 01:02:29 AM »
Hi Folks,

as the subject says. . .

Whilst my programming hours have been few and far between lately my interest in PB hasn't waned. I see the website is still there, and the store.

But I can't get to the forums (surprise  ???). Are they still around?

Thanks for the help,

JS
4
General Discussion / Re: What would be best C++ IDE and compiler
« Last post by Paul Breen on July 14, 2017, 09:03:55 PM »
C++ Builder by Embarcadero is free now for the starter edition, used to be about $240. With this you get the famous VCL library made famous by delphi. For desktop apps this frequently cited as the best library for windows. The new compiler is llvm based, not the old borland compiler anymore. Starter is limited to 32 bits but probably not a problem for a beginner. Microsoft makes the best compiler for windows but it may not be the best for you. See the videos on youtube to help you make up your mind. I prefer the RAD Studio IDE myself, in Delphi mode. If you are a student, get the RAD Studio professional, it is a steal even if you do have to pay about $130 for it. Sure, visual studio is free, but it is free for everybody, so why do people who make their living writing programs pay for other tools? As an extra benefit, your soul will not burn on the lake of fire for all eternity as punishment for joining the dark side. Try them both and see which one you like better.
5
Discussion / Re: String::Remove(const TCHAR* pStr)
« Last post by Frederick J. Harris on June 30, 2017, 09:19:50 PM »
I think I just did a fairly extensive job of testing for memory leaks and I'm not finding any.  Actually, the version where the return from the Remove is being assigned to itself yields the least amount of code overhead.  Here's the results of a sample run...

Code: [Select]
// Main.cpp
// cl Main.cpp Strings.cpp /O1 /Os /GR- /GS- TCLib.lib kernel32.lib user32.lib
// 4,608 Bytes VC15 (VStudio 2008); x64; UNICODE
#ifndef UNICODE
   #define   UNICODE
#endif
#ifndef _UNICODE
   #define   _UNICODE
#endif
#include <windows.h>
#include "stdio.h"
#include "Strings.h"

int main()
{
 String s1(L"one  , two,     three,  four     ");  // 840
 
 s1=s1.Remove(L" ");                               // 952
 s1.Print(true);
 getchar();

 return 0;
}

/*
Entering String::String(const TCHAR* pStr) Constructor!
  this->lpBuffer = 1739840
Leaving String::String(const TCHAR* pStr) Constructor!

Entering String String::Remove(const TCHAR* pStr)
  this->lpBuffer   = 1739840
  Entering String::String(const size_t iSize, bool blnFillNulls)
    this->lpBuffer = 1739952
  Leaving String::String(const size_t iSize, bool blnFillNulls)
Leaving String String::Remove(const TCHAR* pStr)

Entering String& String::operator=(const String& strAnother)
  strAnother.lpBuffer = 1739952
  this->lpBuffer      = 1739840
  this->lpBuffer      = 1739840
Leaving String& String::operator=(const String& strAnother)

Entering String Destructor!
  this->lpBuffer = 1739952
  this->lpBuffer = one,two,three,four
Leaving String Destructor!

one,two,three,four

Entering String Destructor!
  this->lpBuffer = 1739840
  this->lpBuffer = one,two,three,four
Leaving String Destructor!

840  deleted
952  deleted
*/
6
Discussion / Re: String::Remove(const TCHAR* pStr)
« Last post by James C. Fuller on June 30, 2017, 06:20:42 PM »
Fred,
  bc9 has both function and statement string procedures for a couple of it's calls.

------------------------------------------------------------------------------
SubStr$ = Remove$(Main$,Match$)
Remove Match$ FROM Main$
------------------------------------------------------------------------------
SubStr$ = Replace$(Main$,Match$,Change$)
Replace Match$ WITH Change$ IN Main$
------------------------------------------------------------------------------


but all the rest do not modify the Main$ and return a new string.


James
7
Discussion / Re: String::Remove(const TCHAR* pStr)
« Last post by Frederick J. Harris on June 30, 2017, 04:00:36 PM »
I'll do some debug console output on that later today Jim just to make sure, but my guess is that it'll be OK.  If it isn't crashing anywhere then the only concern would be memory leaks, so that's what I'll be looking for.  Good idea, by the way.  I hadn't thought of that.

Originally when I first wrote my string class years ago I had it that the original object was modified, then in one of the apps where I was using the string class I ran into an issue where I kept needing the original unmodified string.  It was at that point it occurred to me I should perhaps modify the method to return a modified string, rather than altering the original string.  I suppose it could be argued either way.  Or do you think my original thought of modifying the original string is best?

That issue served as a lesson to me though in that in all my further work on the String Class I always gave a thought to whether I want to modify the original String (this) or leave it be and create/return the altered one.
8
Discussion / Re: String::Remove(const TCHAR* pStr)
« Last post by James C. Fuller on June 29, 2017, 04:50:41 PM »
Patrice,
  Pretty cool.
I have all the [w]char routines built into bc9 but I prefer Fred's string class because I can do this without the overhead of the circular buffer used for returns of character strings in bc9.
James


fstring GetHello ()
{
    fstring  fsHello(_T("Hello There!"));
    return fsHello;
}

int _tmain ()
{
    fstring  fs = {0};
    fs = GetHello();
    fs.Print( true);
}
9
Discussion / Re: String::Remove(const TCHAR* pStr)
« Last post by Patrice Terrier on June 29, 2017, 03:29:19 PM »
Here is what i am using in my code for triming without using a dedicated string class...

Code: [Select]
long find_wchar(IN WCHAR* sChar, IN WCHAR* sItem) {
    long nRet = -1;
    long K = 0, nLen = lstrlen(sChar);
    for (K = 0; K < nLen; K++) {
        if (sChar[K] == sItem[0]) { nRet = K; }
    }
    return nRet;
}

void reverse(WCHAR str[], long length) {
    int start = 0;
    int end = length -1;
    while (start < end) {
        swap(*(str + start), *(str + end));
        start++;
        end--;
    }
}

WCHAR* RTRIM(IN WCHAR* sBuf, IN WCHAR* sChar) {
    long nLength = lstrlen(sBuf);
    long nLen = lstrlen(sChar);
    if ((nLength) && (nLen)) {
        while (nLength > 0) {
            nLength -= 1;
            if (find_wchar(sChar, &sBuf[nLength]) > -1) {
                sBuf[nLength] = L'\0';
            } else {
                break;
            }
        }
    }
    return sBuf;
}

WCHAR* LTRIM(IN WCHAR* sBuf, IN WCHAR* sChar) {
    reverse(sBuf, lstrlen(sBuf));
    sBuf = RTRIM(sBuf, sChar);
    reverse(sBuf, lstrlen(sBuf));
}

WCHAR* TRIM(IN WCHAR* sBuf, IN WCHAR* sChar) {
    return LTRIM(RTRIM(sBuf, sChar), sChar);
}

10
Discussion / Re: String::Remove(const TCHAR* pStr)
« Last post by James C. Fuller on June 29, 2017, 02:25:14 PM »
Fred,
  This seems to work. Do you see any problems reusing s1?
James

Code: [Select]
typedef String fstring;
int _tmain ()
{
    fstring  s1(_T("Zero,  One, Two  , Three ,  Four, Five   , Six, Seven, Eight , Nine, Ten,"));
    s1.Print( true);
    s1 = s1.Remove(_T(" "));
    s1.Print( true);
    // Remove Trailing comma
    s1.RTrim(44);
    s1.Print( true);
}

output:

Zero,  One, Two  , Three ,  Four, Five   , Six, Seven, Eight , Nine, Ten,
Zero,One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,
Zero,One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten
Pages: 1 2 3 4 5 6 7 8 9 10