Convert array/list to string using a separator in C++ (MFC)



Following is the code to convert array to string using a specific separator. Language used is C++ using MFC (Microsoft Foundation Classes).

This function can trim each term in the array and also ignore blank (empty) string.

You can easily modify it for list or any other similar collection class.

void ArrayToString(CAtlArray<CString> & arrValue, CString & strValue, CString strSeparator
					, BOOL bTrim/*=TRUE*/, BOOL bIgnoreEmptyString/*=TRUE*/)
{
	int i;
	strValue.Empty();
	CString strItem;
 
	//append all strings with ; as separator
	for(i=0;i<int(arrValue.GetCount());i++)
	{
		strItem = arrValue[i];
 
		if (bTrim)
		{
			strItem.Trim();
		}
 
		if (bIgnoreEmptyString)
		{
			if (strItem.IsEmpty())
			{
				continue;
			}
		}
 
		strValue += strItem;
 
 
		if (i < (int(arrValue.GetCount())-1))
		{
			strValue += strSeparator;
		}
 
	}
 
}


Setting reminders saves a lot of money and makes life smoother



Today, I am going to highlight on a very simple fact. In today’s age of technology and smart phone, I strongly suggest that you use right apps to make your life smoother. An app that would help you to write quick notes and set reminders can really keep you stress free “if” you learn to use it timely and consistently.

I am using Notezilla – sticky notes and reminders app. Not because I wrote that myself, but because it has turned out to be a really cool utility app. Because it syncs between iPhone/Android devices and your Windows PCs. So, all your notes and reminders are always with you. This is essential since you need to be reminded any time and any where.

Here is how a notes and reminders app can help you save money and tedious effort.

  1. Set reminders to monthly phone bills. If you miss this, you may end up paying penalty.
  2. Set reminders to pay credit card bills. Now, the non-payment charges for this can be really high.
  3. Remind yourself to pay insurance premiums every year.
  4. We often miss out on taking regular data backups. Set reminders to take necessary backups. Or automate it using Copywhiz.
  5. If you have extra money in your bank account, set reminder to invest it at the right place. Investing money at the right time can earn you more interest.
  6. Jot down all the important numbers for quick reference to save time: Example: Tax id, bank account number, passport number, social security number, insurance policy numbers, GST number and the list goes on.
  7. If you are maintaining equipments such as inverter/UPS batteries, you can set a reminder so that you can extend their life.
  8. Set reminders to call the service men for your car, air conditioner (AC), room heater and various other day-to-day machinery.
  9. If want to stop renewal of a subscription at a particular time, you can set a reminder so that you don’t get charged accidentally. Avoid unnecessary hassle.
  10. If you have any deadline to buy or sell an investment, it is best to set a reminder.
  11. Often, the government of your country would have deadlines to pay taxes, file income tax returns, pay advanced tax etc. Save yourself from penalty by noting them down in an app and setting reminders.
  12. And the list goes on. You can think of other creative ways of setting reminders for both trivial and important life tasks.

Share your ideas of using a notes & reminder app effectively to make life better and more productive. Add your comments below.

Thanks. You may want to check out my product Notezilla – sticky notes and reminders apps for Windows and phones.

Thanks.



Looking for Sqlite Net PCL for your Xamarin project?



The phone app for Notezilla is created using Xamarin Forms. I like the way Xamarin Forms has grown. It works pretty well.

If you are looking for SQlite .Net PCL library, you might find multiple. But I will tell you which one is good.

For last few years I had used Sqlite.Net PCL and Sqlite-Net Extensions in my app. While I was debugging performance issue in the iOS version of my app, I found that the performance lag was due to a single linq query. It used to take 7 seconds. Xamarin Forms list view which listed our records was performing too slow. This was the case only in iOS. Not in Android.

So I looked for an alternative. And finally found the original Sqlite-Net-PCL project that is being maintained till date. I implemented Sqlite-Net-PCL and found that the same linq query executed in less than 1 second. This was a great deal for me.

In short, use Sqlite-Net-PCL. Do not use Sqlite.Net PCL because it is slow and it is not being maintained.

Sqlite-Net Extensions is dependent on Sqlite.Net PCL. Fortunately, we weren’t using Sqlite-Net Extensions. So we could easily remove it from our project.

Thanks.



XLabs Xamarin Forms Labs – Label does not un-strikethrough in Android



If you are trying to use un-strike-through (remove strike through) a text in extended label of XLabs Xamarin-Forms-Labs , you may not see it working. This is a bug.

To fix it, I have added to else part in both in ExtendedLabelRenderer.cs of Android platform. This fixes it.

  if (view.IsUnderline)
        {
            control.PaintFlags = control.PaintFlags | PaintFlags.UnderlineText;
        }else
        {
            control.PaintFlags &= ~PaintFlags.UnderlineText;
 
        }
 
        if (view.IsStrikeThrough)
        {
            control.PaintFlags = control.PaintFlags | PaintFlags.StrikeThruText;
        }else
        {
            control.PaintFlags &= ~PaintFlags.StrikeThruText;
        }

Thanks.



XLabs Xamarin Forms Labs – Label does not show strikethrough on multi-line in iOS



If you are trying to use strike through property of XLabs Xamarin-Forms-Labs , you may not see the strike through work on labels having multiline (wrapped text). This is a bug.

To fix it, add the following line after setting this.Control.AttributedText = new NSMutableAttributedString in the file ExtendedLabelRendered.cs

 ((NSMutableAttributedString)this.Control.AttributedText).AddAttribute (
                UIStringAttributeKey.BaselineOffset, new NSNumber(0) , new NSRange (0, view.Text.Length));

Thanks.



Why Google Chromecast is better than Set Top Box (TataSky etc)



Six months back I moved from TataSky to Google Chromecast! What an amazing relief! I find several advantages of using TV via the Internet over normal Set Top Box like TataSky, DishNet, Airtel Digital TV, Videocon DTH etc.

For several years I was looking for some technology that will allow me to restrict TV by time slots. This is mainly for my kids, so that they don’t watch TV anytime they wish to and however long. I consider TV a slow poison. It takes away precious time, physical and mental health.

Here are the advantages of casting.

  1. The complete control is via the phone. Only if the kids get the phone, they get to watch TV.
  2. It is free! No monthly subscriptions! You are just using your existing broadband Internet bandwidth.
  3. More channel options. More apps providing hundreds of channels (Jio TV, Hotstar, YuppTV etc)
  4. Less commercial advertisements.
  5. Short commercial advertisements. A 30 minute TV program actually finishes in 20 minutes. We we save a lot of time and frustration due to length ads.
  6. Watch TV programs before their scheduled time. Since the same program is available at different time zones, you can watch a serial well before their Indian time table. Watch early, sleep early!
  7. There are more advantages…..I am unable to recollect. Will add them soon :)


StackOverflow like alternative Q & A system



In order to build a Question & Answer system like StackOverflow, for my website Conceptworld, I was looking for various alternatives.

The reasons behind building a Q&A website for our products were:

  1. SEO (Search Engine Optimization)
  2. Minimizing Support
  3. Provide customers with quick answers to frequent questions

Since year 2000 when we founded Conceptworld, we have received several thousand support queries. I wanted to put the best, frequently asked support queries into this Q&A website.

I found a long list on this stack exchange page but I wanted something that can be setup easily on my Windows based server (IIS). I am using shared hosting from Lunarpages.

Finally I found a fantastic Q&A system called Question2Answer. It is a PHP based free and open source platform which works so well. I have successfully set it up on our Conceptworld support page.

Question2Answer is as easy as setting up wordpress on any server. It has a huge community around it. Plus there are several plugins available to tweak the product to your needs.

If you are looking for a free Q2A platform that will work on Windows IIS based server, then I strongly recommend Question2Answer.

If you found this post useful, please like it by clicking on one of the social media buttons (facebook, twitter, google+) on top/left of this post.



Splitting CString to array in MFC



The following function converts string to array in MFC & ATL. By default it trims each string in the array and also ignores empty strings. It uses CString MFC class and CAtlArray ATL class.

//converts semicolon separated string to array of strings
void StringToArray(CString & strValue, CAtlArray<CString> & arrValue, TCHAR szSeparator, BOOL bTrim/*=TRUE*/, BOOL bIgnoreEmptyString/*=TRUE*/)
{
	int idx;
	CString strTemp,strRest;
 
	strRest = strValue;
 
	if (strRest.IsEmpty()) {
		arrValue.RemoveAll();
		return;
	}
	do
	{
		idx = strRest.Find(szSeparator);
 
		if (idx != -1)
		{
			//take the left part
			strTemp = strRest.Left(idx);
 
			if (bTrim)
			{
				strTemp.Trim();
			}
 
			if ( (bIgnoreEmptyString) && strTemp.IsEmpty() )
			{
				//ignore
			}else
			{
				arrValue.Add(strTemp);
			}
 
			strRest = strRest.Right(strRest.GetLength()-idx-1);
 
		}else
		{
			if (bTrim)
			{
				strRest.Trim();
			}
 
			if (!strRest.IsEmpty())
			{
				//this is the last element, so lets add it
				arrValue.Add(strRest);
			}
		}
 
	}while(idx != -1);
 
}


Tracking your software downloads using setup filename



Measuring your marketing campaign is utmost necessary to determine the success of your campaign.

In order to measure, you need to track various factors. When you are selling a downloadable software, one such factor is the website from which your software was downloaded.

There are several software download sites where you can publish your software. Such as download.com, softonic, softpedia etc. When someone purchases your software, how will you determine from which website he had downloaded your product? Very few websites have javascript based tracking methods. The disadvantage is that tracking is available only when you advertise on that particular download website.

Today I will show you one trick. The trick is to name the setup file name with a tracking code and track it till product purchase. I implemented this today for my sticky notes app – Notezilla.

Step 1:

If the setup file name is NotezillaSetup.exe, just suffix it with a code like NotezillaSetup(s101).exe

Step 2:

In the setup program that you use, parse the setup file name, pick the tracking code and save it in registry or an INI file during installation of the product.

I use Inno Setup. Here is the Inno Setup script I used to parse and save it to INI file during installation.

function GetDownloadSource(Param: String) : String;
var
setupFileName : String;
stringPos : Integer;
downloadSourceName : String;
Begin
 
  //The following code is to find the source of download file
  //from the file name itself. For example if the file name is NotezillaSetup(s100).exe 
  //then we will get s100 from the file name
  setupFileName := ExtractFileName(ExpandConstant('{srcexe}'));
  stringPos := Pos('(s', setupFileName);
  if (stringPos > 0) Then
  Begin
       //+1 ignores ( character
       downloadSourceName := Copy(setupFileName, stringPos+1, Length(setupFileName)); 
       stringPos := Pos(')', downloadSourceName);
       if (stringPos > 0) Then
       Begin
              //remove all characters after ) closing bracket so that
              //finally we get a string of within the () brakets
              Delete(downloadSourceName, stringPos, Length(downloadSourceName));
       End;
  End;
 
  Result := downloadSourceName;
 
End;

In the INI file, now you used the above function GetDownloadSource

[INI]
Filename: "{userappdata}\Conceptworld\Notezilla\Notezilla.ini"; Section: "General"; Key: "DownloadSource"; String: "{code:GetDownloadSource}";

Step 3:

In your software, you will have various locations where you take the user to your website. Like Buy Now button, Website button, Online Help.

You need to suffix the tracking code to all the urls that take the user to your website.

Example:

Old Url: http://www.conceptworld.com/Notezilla
New Url: http://www.conceptworld.com/Notezilla?downloadTrackingCode=s101

Step 4:

Now modify your website code (client or server side) to read this tracking code and save it to cookie or session variable.

Step 5:

On your order page, take the tracking code from the cookie/session variable and append to your order urls. All e-commerce websites allow you pass additional data so that you can track your order. Configure your e-commerce server provider to save this additional data and send it to you on successful order completion. Usually it is through IPN (Instant Payment Notification).

That’s it.

You can see how useful this tracking method can be. You simply have to change the setup file name and provide a different url to the download website. This way you can plan your marketing strategies. Where to spend more money on advertisement, where you stop spending more money etc.

I hope you got an idea how to go about it. If you have any questions, please post them below in comments section.



What would Buddha do? – Borrow or buy this book online



[Borrow Book]

[Buy Book]

A unique approach to Buddhism, What Would Buddha Do? shows that anyone can find guidance in Buddha’s teachings. It demonstrates how to use the advice of Buddha to become a better person at work, at home, and in society. Presented in a reader-friendly format, with each page offering a question, a Buddhist quote, and advice from the author, What Would Buddha Do? applies this question to 101 problems confronted in everyday life and reveals how Buddha’s teachings are still meaningful after 2,500 years. [Read More]