Cyprich.com

Occasionally Relevant Insights from a Software Builder

By

C#: Bonjour Monde!

This is the Canadian version of the “Hello World! program that every programmer learned in the first 5 minutes of their schooling. Compile this as a console project to test if your compiler is working.

ConsoleApplication1
{
  class Program
  {
    static void Main (string [] args)
 
   {
      Console.WriteLine (“Bonjour Monde!”);
 
     Console.ReadKey ();
 
   }
  }
}

By

How to Copy Contents of HTML Textbox to Another

I recently made changes to a web form that populated a PDF through an XFDF file. In the new code, instead of outputting to an XFDF, the page outputs to an HTML file. Everything worked great, except the HTML page lacked one feature the PDF did. If you have 2 fields with the same name on a PDF, when you update one field, the other field automatically gets the same content. This naming trick won’t work in HTML.

The sample code below will copy the contents of a textbox to another textbox without using JavaScript. The updates occur during each key press. I’ve include examples in standard HTML and ASP.NET. The red text is the code you use to copy one textbox to another.

HTML:

<form name="aForm" action="" method="" />
  <input type="text" name="TextBox1" onkeyup="document.aForm.TextBox2.value = this.value" />
  <input type="text" name="TextBox2" />
 </form>

ASP.NET:

<asp:TextBox ID="TextBox1" runat="server" onkeyup="document.aForm.TextBox2.value = this.value"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

By

How to Replace QLingo with JavaScript in a uStore Dynamic Document

Programmed elements in a dynamic document for XMPie uStore can be built using JavaScript instead of QLingo. Follow the steps below:

  1. Don’t use JavaScript in InDesign with the ADOR objects. All of the programming will take place in uPlan.

  2. In uPlan, create the variables and campaign dials for the ADOR objects that will be used as variables in functions.

  3. Create the function in JavaScript.

    function ShowPersonalCorporation (star1, star2, star3)
    {
     if (star1 || star2 || star3)
       return "*Personal Real Estate Corporation";
    }

  4. Call the function in the ADOR object.

    ShowPersonalCorporation (@{_Star1}, @{_Star2}, @{_Star3})


Testing for Null Values


In QLingo, you would test for a null value by using the IsNullOrEmpty function, which would return a value based on its result (true: display real estate info; false: display nothing):


if (!IsNullOrEmpty (@{_Star1}))

{

 “*Personal Real Estate Corporation”

}

else

{

 “”

}


The JavaScript equivalent is:


function ShowPersonalCorporation (star)

{

 if (star)

   return “*Personal Real Estate Corporation”;

}

By

A Quick (Not Approved by Xerox) Way To Setup SSL On All uStores

When you have hundreds of stores in uStore, making updates on all of them takes a very long time. This doesn’t matter if your paid by the hour, but if your in a hurry and need everything updated quickly, the manual method is not the best solution. For your information, this method is described below. The procedure can take a few minutes to complete. Multiply that by hundreds of stores and you’ll see the problem.

Manual Method

In the uStore admin site,

  1. Take store offline.
  2. Open Store Setting -> Set Up Store
  3. In the Advanced tab, select the Security Option
  4. Press Save & Place Online

The change can easily be made by modifying a table in the uStore database. This method isn’t recommended by Xerox and I wouldn’t recommend it either to novice database administrators. For experienced users, make a backup of the database before you make any changes. MSSQL doesn’t ask “Are you sure you want to make this change?” when you run SQL queries.

SQL Method

In the uStore database, you will need to modify the Store table. Each store here has an SslOption field which defaults to 0 value (see table below):

SslOption Field
0 Not Secured
1 Secure All
2 Secure Critical Points

Select which SSL option that you want and run the following SQL command:

     UPDATE Store SET SslOption=@SslOption WHERE StatusID=1

Example:
     UPDATE Store SET SslOption=2 WHERE StatusID=1

This updates all active stores to SSL option: Secure Critical Points

After the SQL query is run, you need to force a cache refresh. The page for this is on your your uStore at (use the IP of your server):

     http://127.0.0.1/uStoreAdmin/Support.aspx

In Cache update, press the Refresh Localization Cache button, Refresh ACL Cache button, and Refresh General Cache button. Not sure if all of these are needed, but I’ve done this and the stores were fine afterwards. If you don’t do a manual cache refresh, this will eventually occur in uStore, but if someone opens a store in the admin site and makes a modification, you may lose the changes your SQL query made.

And that’s it. Again, if your not an experience database administrator, don’t attempt this.

By

How to Lock a Windows 10 Screen from a Console Command

I normally lock my computer when I step away from it to prevent other users from getting access to it which would give them full access to my web sites, databases, and other sensitive files. I do this as opposed to logging out of the computer. Locking the screen keeps you logged in but it requires you to enter your login password to open the desktop.

While working on a computer, you can press the Windows + L keys to lock the screen. If your logged in by VNC, closing your connection does not automatically lock your computer and it will remain in an unlocked state so that anyone can start using it. A simple way to lock your computer from a command prompt is to run:

rundll32.exe user32.dll,LockWorkStation

Opening a command prompt to do this is too much work, so create a batch file (Lock Workstation.bat), place that line in it, and keep the file on the Desktop for easy access. Then when you complete your remote session, lock the screen before you close the connection.