Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, April 27, 2016

Fortran 77 (F77) - How to Convert Integer to String and Concatenate

Recently was working with a 91-year old researcher on their Fortran 77 code written over the last 50-years. It needed debugging and some new coding so it lead to learning an ancient language lovingly called F77. It is an eye-opening experience to realize you are working on something with that much history and contributing to a legacy.

Anyhow, personal reflections aside, here is how you convert an integer into a string in fortran 77 and then concatenate it to another string. Useful for suffixing a filename for example.

Conversion

The basic idea behind converting a variable of any type to a string in Fortran 77 is to write that variable into a Character array variable of some length using the Write function. So in our case we will be writing an Integer into a Character array.

Note: The size of the character array should match the number of digits else you will have a lot of white space. Of course you can do that if you want.

Let's define two such variables and assign them values.

Tuesday, July 10, 2012

What is "this" in Java?


So in learning Java I found the "this" keyword to be a bit of an odd item to work with. It is pretty obvious now but initially it was confusing and some google-fu helped clear things up. The one thing that was a bit subtle was the construct:

InnerClass innerClassObject = this.new innerClassConstructor();

So here is the answer. When you have an Inner Class, it can't be handled directly at all and needs to be referenced via an instanced object of its encapsulating Outer Class. In other words, you need an object created for the Outer Class before you can create an object of the Inner Class. The code would normally look as follows:

OuterClass.InnerClass innerClassObject = new outerClassConstructor().new innerClassConstructor();