Friday, May 31, 2024

Another Day, Another Ball Game (and Another Pair of Pants!)

 

Another Day, Another Ball Game (and Another Pair of Pants!)

Hey everyone,

Just checking in as I juggle web development, softball tournaments, and keeping my kids in clothes!

Today on the development front, I'm neck-deep in refactoring my webforms project into .NET Core MVC. Let me tell you, wrangling the DB2 .NET provider has been a real challenge. But hey, that's the life of a developer, right? We love a good puzzle (or maybe that's just me).

On the family front, it's all about softball this weekend! Both my girls are playing in a tournament down in Oklahoma City. We're packing up and heading out early tomorrow morning. Of course, just before we left, I realized my youngest daughter had completely outgrown her softball pants. So, that meant another trip to the sporting goods store. Let's just say, having two travel ball players keeps this dad on his toes (and broke!).

In between games, I also managed to squeeze in some work on my son's auto repair shop website. I snagged him a new local citation and freshened up some of the content. Hopefully, it'll help him attract some new customers!

Speaking of customers, gotta make sure I charge the camera tonight so I can capture all the amazing plays (and meltdowns - hey, it's sports!). Wish us luck on the road trip and at the tournament!

Until next time,

Wednesday, May 15, 2024

Local Gems: Unveiling Hidden Businesses in Your Neighborhood

 Hey everyone!

It's been a while since my last post. Between cheering on my daughters at their softball games and helping my son launch his auto repair business, things have been a whirlwind! But with a little more breathing room, I wanted to jump back in and talk about something important: supporting our local businesses.

Have you ever wondered about the impact your local businesses have on your community? Beyond the convenience they provide, local shops contribute to the unique character and economic well-being of your city. Today, we'll delve into the world of local business directories and explore how they can help you discover hidden gems!

Many online platforms exist to connect customers with local businesses. These directories allow shop owners to create detailed listings showcasing their services, contact information, and sometimes even customer reviews.

Let's take a quick example. Imagine you're searching for a reliable auto repair shop in Broken Arrow. A local directory might lead you to a listing with a shop that specializes in Hyundai repairs and boasts consistently positive reviews praising their quick and efficient service.

Local listings can be a goldmine for information. Detailed descriptions, clear contact details, and even customer experiences can all play a big role in building trust with potential customers. By utilizing these directories, you can ensure you're finding the perfect local business to suit your needs.

Local directories can be a game-changer when it comes to comparing businesses within your zip code. Imagine searching for a local businesses and being presented with a list of options in your neighborhood, all with detailed information like services offered, customer reviews, and even pricing. With a local directory, you can easily compare these factors side-by-side to find the perfect business that fits your needs and budget, all without spending hours sifting through individual websites or making calls.

On that note, I'm also working with my son to implement a good customer relationship management system (CRM) for his auto repair shop. A CRM helps businesses track customer interactions, appointments, and preferences, allowing them to communicate more effectively and build stronger relationships.

So, next time you're on the hunt for a great car repair shop in Broken Arrow, consider exploring some local business directories! Read reviews, compare listings, and discover the fantastic businesses that make your city special. In future posts, we'll explore different local business categories, so stay tuned to learn more about the amazing shops right in your backyard!

Sunday, May 5, 2024

Ditch the Indicators! Positioning the Cursor in RPGLE Dynamically

 

For decades, RPG programmers have relied on the tried-and-true combination of DSPATR(PC) and indicators to manage cursor placement on display files. While this method gets the job done, it can also introduce a host of challenges that hinder code maintainability and introduce potential errors. This blog post dives into a modern alternative – dynamic cursor positioning without indicators – that offers a cleaner and more efficient approach.

The Pervasiveness (and Peril) of Indicators

If you've spent any time working with RPGLE display files, you're likely familiar with the concept of indicators. These special fields within the display file allow you to control the cursor's location. While indicators seem straightforward at first, their widespread use can lead to several problems:

  • Code Complexity: Managing numerous indicators throughout your code can quickly lead to spaghetti logic. Keeping track of which indicator points to which field can become a maintenance nightmare.
  • Maintainability Woes: As programs evolve, indicator-based cursor control can make modifications cumbersome. Adding new fields or rearranging the display can require a ripple effect of indicator updates throughout the code.
  • Error Prone: Incorrect indicator values can lead to unintended cursor placement, causing user confusion and data entry errors. Debugging such issues can be a time-consuming task.

A Modern Alternative: Enter CSRLOC

There's a better way! The RPG language provides a built-in functionality called CSRLOC that allows you to dynamically control the cursor position at runtime. This keyword resides within the display file itself and stores information about the cursor's location, specifically the row and column number. By leveraging CSRLOC, we can eliminate the need for separate indicator fields altogether.

The Power of CSRLOC in Action

Instead of pre-defining cursor positions with indicators, we can utilize the CSRLOC data dynamically. Here's how it works:

Add CSRLOC to the display file.  If you have multiple screens, you will need to add it to every format where you need to position to a field.

A       R SCR1
A       CSRLOC(Z1LINE Z1COLUMN)
A       Z1LINE   3S 0H
A       Z1COLUMN  3S 0H
  • Unleashing QCMDEXC: The QCMDEXC RPG built-in function allows us to execute iSeries commands dynamically. In this case, we'll use it to execute the DSPFFD command, which retrieves information about the display file structure at runtime. This retrieved data includes the crucial CSRLOC values.
    // Get list of fields in display file
    // for cursor positioning
    cmdstr = 'DSPFFD FILE(SLVNDM01) ' +
    'OUTPUT(*OUTFILE) OUTFILE(QTEMP/VNDMFLDS)';
    
    qcmdexc(%trim(cmdstr): %len(%trim(cmdstr)));

  • Building a Reusable Subprocedure: To avoid code duplication, we can create a subprocedure that takes the record format name and the target field name as input parameters. This subprocedure will:
    • Use QCMDEXC to execute DSPFFD and retrieve the CSRLOC data.
    • Parse the retrieved data to identify the row and column position of the target field based on its name within the record format.
    • Utilize this information to dynamically calculate the desired cursor location.
      dcl-proc setCursor;
        dcl-pi *N;
          @RecFormat VARCHAR(10) value;
          @FieldName VARCHAR(10) value;
        end-pi;
      
        dcl-s $$recFmt varchar(10);
        dcl-s $$fldNam varchar(10);
      
        $$recFmt = %upper( %trim(@RecFormat) );
        $$fldNam = %upper( %trim(@FieldName) );
      
      
        // Set the cursor based the field
        exec sql select whdrow, whdcol
        into :z1line, :z1column
        from vndmflds
        where trim(whname) = :$$recFmt and trim(whfldi) = :$$fldNam;
      
        return;
      end-proc;

By calling this subprocedure whenever you need to position the cursor on a specific field, you can eliminate the need for pre-defined indicators. The subprocedure takes care of calculating the correct row and column based on the current display file structure.

// turn off position indicators 60 thru 79
$recformat = 'SCR1';
%subarr(*in:60:20) = *off;

*in90 = *on;  //assume prog
1b      if vmname = *BLANKS;

         snd-msg 'Vendor name required';
         setCursor($recformat:'vmname');
LV       leavesr;
1e      endif;

Benefits and Considerations

This dynamic approach to cursor positioning offers several advantages:

  • Reduced Code Complexity: Saying goodbye to indicators means cleaner and less cluttered code.
  • Improved Maintainability: Changes to the display file layout no longer require extensive indicator updates, making your code more adaptable.
  • Potential for Flexibility: Dynamic cursor positioning opens doors for more flexible cursor control logic within your program.

There are a couple of considerations to keep in mind:

  • Display File Modification: This approach requires adding the CSRLOC keyword to your display file.
  • Slight Processing Overhead: The use of QCMDEXC for retrieving CSRLOC data introduces a small overhead compared to using indicators. However, in most cases, the benefits of cleaner code outweigh this minor performance consideration.

Conclusion: A Brighter RPGLE Future

By embracing dynamic cursor positioning and ditching the indicator approach, you can write cleaner, more maintainable, and potentially more flexible RPGLE code. This technique is particularly valuable for programs that interact with complex display files or require frequent layout changes. Consider exploring this approach and see how it can transform your RPGLE development experience!

Have You Ditched Indicators Yet? Share Your Experiences!

Have you experimented with dynamic cursor positioning in your RPGLE programs? Share your experiences and insights in the comments below. Let's discuss the potential of this approach and explore its broader applications in the RPG world!

For more RPGLE tips and tricks, check out some of my other posts:

Replacing ERRMSGID with SND-MSG


Another Day, Another Ball Game (and Another Pair of Pants!)

  Another Day, Another Ball Game (and Another Pair of Pants!) Hey everyone, Just checking in as I juggle web development, softball tourname...