Welcome Guest | My Membership | Login

MV Your Way - PHP Edition


Article

Imagine trying to attract a new PHP developer to a job where you'll be training them to do mvBASIC work. They have to learn a new command line, a new programming language, and a new database. What if we made some of that easier by letting them bring some of their things into our home.

In the last issue, we use FUNCTION to make mvBASIC easier for us, the existing developers. We can also use the same trick to welcome our new friends inside.

PHP, like every other language, has a vast number of commands. We'll focus on some core ones for now. We'll start with date handling.

<?php
$idt=gregoriantojd(1,13,1998);
echo jddayofweek($idt,1);
?>

We could teach them to do it our way, and they should learn that eventually. That would leave them with something like:

idt = iconv('01/13/1998','D')
print oconv(oconv(idt,'DWA'),'MCT')

Instead, we could make two functions like:

FUNCTION gregorianotjd(month,day,year)
idt = iconv(month:'/':day:'/':year,'D')
return idt

FUNCTION jddayofweek(idt,mode)
begin case
case mode = 0
dow = oconv(idt,'DW')
case mode = 1
dow = oconv(oconv(idt,'DWA'),'MCT')
case mode = 2
dow = oconv(oconv(idt,'DWA'),'MCT')[1,3]
return dow

And what we did here works for other commands. Lets' re-invent file handling their way. PHP has several ways, we can start with file_get_contents and file_put_contents.

FUNCTION file_get_contents(thePath)
* thePath = /<filename>/<itemname>
theFname = oconv(thePath,'g1/1')
theIname = oconv(thePath,'g2/1')
*
theRecord = '-1':@AM:'not found'
open theFname to theHandle then
read theRecord from theHandle, theIname else null
end
return theRecord

FUNCTION file_put_contents(thePath,theRecord)
* thePath = /<filename>/<itemname>
theFname = oconv(thePath,'g1/1')
theIname = oconv(thePath,'g2/1')
open theFname to theHandle then
write theRecord on theHandle, theIname
end
return

Keeping going like that and they can code in our mvBASIC using their syntax. What we've done here can be extended to a large percentage of their commands. Yes, they will still need to use PRINT instead of ECHO but our mvBASIC will look better to their eyes. I do not advocate making this a long-term strategy, but putting a little of the familiar in our world makes it more inviting to others.

 

# # #          # # #          # # #

 

Related Articles

  • From the Inside July/August 2018

    Company: International Spectrum

    It is that time of year again. I'm starting my planning for the 2019 Spectrum Conference. If you haven't yet seen the information for the 2019 Spectrum, it will be April 8th-11th at The Wigwam in Arizona.

  • Business Tech - Talking the Talk

    Company: HDWP

    Writing for Spectrum has taught me a great deal about effective communication. Whether you are hunting for a job or already set with employment, your command of words is likely to be your most crucial non-technical skill.

  • Using OWIN Security with MultiValue Data - Part 4: Two-Factor Login

    Company: International Spectrum

    Two-Factor Authentication is starting to become a requirement in many industries. While you can implement a from-scratch workflow yourself, it can be a little cumbersome. The OWIN framework provided in ASP.NET does much of the work for you. This article explains how to implement Two-Factor Authentication in Multivalue using OWIN identity information we have implemented in previous articles.

  • Session Management with PHP

    Company: Precision Solutions

    As you begin to develop webbased MultiValue applications using a browser as the preferred user interface, one of the first changes in your thinking process has to be how your application communicates with the user. Unlike a traditional dedicated connection between user and server, web-based applications must deal with an ongoing series of non-persistent connections. How does your application know what you and the user were talking about a minute or two ago? Using the built-in capabilities of PHP, this article explores some of the issues of such session management.


Return to top