Cache issue on the server
When it first happened to me, I searched for a while before finding the reason why my upload of a specific graphic was not reflected in the browser. I had the need to update an image and once I overwrote the actual copy on the server, IIS was still showing the old version. The scenario that happened was the following:
This is when I decided to build a small procedure that I can use in such circumstances. I benefited of that at several occasions so far. Some may say that they will never need it. This is how I thought at first. But, when you manipulate images like that from various sources, you will face that situation occasionnally.
The trick consists of updating the time stamp of the most recent versions of the image before uploading it to the server. So, whenever I have that need, I only do something like this:
SET PROCEDURE TO Utility.prg FileTime('d:\iis\images\MyImage.gif',DATETIME())
Graphic quality
This section doesn't need Visual FoxPro but I thought I would mention it as many developers are facing that situation on a regular basis. There are still a lot of developers who don't know how to deal with some of the graphic quality issues where I will discuss some of them here.
The two most common graphic formats are GIF and JPG. Many will use GIF when in need to obtain a transparent background or for small images. But, when you have a need to go with real pictures or related, a JPG format will be used.
IMHO, an image should only be saved in a JPG format once. Usually, you will start from your original artwork and save the final version in JPG. By that, you will reach maximum quality. However, what many don't realize is that if you take a JPG file, apply some editing on it and resave into a JPG, you will loose quality. That is normal as when saving a JPG over a JPG, you will never reach maximum quality.
For example, we receive a lot of pictures for the Universal Thread. Members are sending their pictures in JPG format. But, some of them need editing as some may not necessarily follow our technical guidelines as is. The dimension might not be 90*117, the one pixel black border might not be present and required editing may apply. If the image has been sent in JPG format, once we save it again, we will loose quality. However, in this situation, we don't have any choice. The only format that we have is a JPG format and we have to deal with it. In order to get as close as possible to maximum quality, most graphical software will allow you to save the JPG up to 95% quality. Of course, you will end up with a bigger file but the goal here is to get the picture with maximum quality as we can. So, this is something you might want to consider if you have to do those manipulations.
Note also that some graphical software will save a JPG file with about double size as another software would do. Some high-end software will save in layer, etc. So, they add extra information in the file which increases the size of the file. Unless I would have to do the same job as a graphic artist, I will never use those specialized software as I consider them overkill for such a job. For me, I always found LView Pro the best in that area as it allows me to convert from one format to another, to benefit of all the required tools, and to save only the required information. For those who would like to consider LView Pro, you may access their Web site at http://www.lview.com.
One form, two types of window
Anyone ever ask you to do an HTML form that would launch its transaction either in the same window or in a new window? As long as you can detect that at the form level, this is not a big deal. Assuming the case, for example with a checkbox that the user can check to tell that he wants to launch the transaction in a new window, you would be able to negotiate with that with some simple JavaScript code to change the target of the form. But, what if this detection mechanism can only be done at the table level?
This is where you will start thinking about how to achieve that. Lets assume the user has a setting in his profile which contains that information. Up until that point, everything is fine. The challenge consists of implementing an approach to return the form result either in the same window or in a new window. Assuming the setting of that user is to return the form result in the same window, you just proceed as is. But, when you have to target that in a new window, you have to do some extra manipulations.
The opening of a new browser window can only be determined from the caller window. In this case, this would be the form definition. But, as we don't know at this point if we have to launch it in a new window or not, we will go with the default, which consists of launching it in the same window. Then, when the setting of the user tells to launch it in a new window, we will simply return a small HTML page which contains some JavaScript code to call the new window:
<SCRIPT> window.open("MyPage.html","_blank","scrollbars=yes,width=1000,height=750,resizable=yes,toolbar=yes") </SCRIPT>
So, at this point, the following scenario goes like this:
<SCRIPT> window.open("MyPage.html","_blank","scrollbars=yes,width=1000,height=750,resizable=yes,toolbar=yes") window.history.back() </SCRIPT>
Gathering value from one page to another
One common issue that we regular face is about gathering a value from one page to another. For example, a lot of stores use that approach. Either to hold the items in the basket, to hold the member ID or to hold any other related information, such a need would then apply. Some common approaches are regularly used:
One consists of using Cookies to store that information. While this is nice as you won't have to gather the required data from several pages and only extract it when needed, using Cookies bring some additional concerns. First of all, many users are either manually turning on the notification of cookie settings in their browser or they make use of specific software that will do that for them. In both cases, this means that whenever you set a cookie, they will receive a notification. This is getting annoying if you make use of that at several places in your application. I prefer to make use of Cookies only at the start-up of the application such as from a login to authenticate to the site.
Another one consists of gathering your data from one page to another by the use of hidden variables. This could be a preferred approach if you only have to move from one or two pages. But, this will get annoying if you have to gather the data for several pages.
Even if we talk here about only some specific pieces of information that you need to gather, some may still want to store it at the backend. If you wish to create temporary tables or related and do this at this level, that can also be a good approach to take. You would only have to maintain those temporary tables when required and extract the data from them when you are ready to extract the related data. I prefer to only make use of backend tables when I have a need to store the information permanently. For example, I would use a backend table to store the in basket of a user. By that, if he doesn't complete his purchase immediately, he can then log in later on and complete his transaction.
JavaScript alert() function without creating a new HTML page
You probably faced this situation a lot of times so far and you probably found your way in to achieve what I am about to explain. In some cases, you would like to do some specific database manipulations but don't have any specific need to return an HTML page. For example, you might have a list of members and each record contains a hyperlink to send an invoice. In that case, the best is to have the user to remain in the list so he will be able to continue to work with that list. So, here you have a situation that you need to process something on the backend and probably only want to return a message telling the user that the invoice has been sent.
This is quite easy to accomplish if you are within a frameset environment, thus a hidden frameset can be used to do the backend manipulation and return the alert() message. But, when you only have one single page in your environment, this is something you can't do. One approach you could use far is to have the hyperlink to launch the transaction in a new window, defined out of screen, and return the message. Then, just close that window.
So, the HTML code when the user clicks on one of the record link could be:
<A HREF=javascript:SendInvoice(1)>Send invoice
function SendInvoice(tnNumero) { window.open("/wconnect/wc.dll?SendInvoice~"+tnNumero,"_blank","width=1,height=1,top=2000") }
<SCRIPT> alert("The invoice has been sent.") window.close() </SCRIPT>