Perl programming in UEStudio

Perl programming in UEStudio

2
NewbieNewbie
2

    Aug 27, 2007#1

    Anyone out there doing any Perl programming with UES or UE? I am trying to decide whether UES offers significantly more capability than UE to make it worth upgrading to UES.

    344
    MasterMaster
    344

      Aug 27, 2007#2

      I do a bit via FTP on Unix side. I use UE only as a (good) editor. There is a syntax highlighting wordfile on this website you can use.
      I do not need more than editing, I got a debugger on Unix side.

      rds Bego
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      119
      Power UserPower User
      119

        Aug 27, 2007#3

        I do a fair amount of Perl programming. I don't think that UES offers much over UE for Perl, though. I suppose that CVS/SVN integration might be nice. I'm sure that UES's debugger and class viewer don't work with Perl.

        UE's user tools allow you to do a lot of integration if you're willing to put in the effort needed to figure things out. e.g. here are my user tools:

        * Perl Lint
        * Run Perl script
        * Debug Perl script
        * Perltidy file
        * Perlcritic

        I also have a script to run perltidy on a selection and tools to check files in and out of version control. (I use Clearcase.)

        1

          Nov 08, 2007#4

          mjcarman, would you mind sharing your user tool for debugging a perl script from within UEStudio ?

          I just upgraded from UE 12 to UEStudio (I *really* like the time counting in the project manager and figured - what the heck - I haven't gone wrong with anything from IDM yet, so the little bit extra to go from UE to UES would be worth it)

          Much appreciated!

          119
          Power UserPower User
          119

            Nov 09, 2007#5

            I don't run UEStudio. I use the builtin Perl debugger, I just launch it from UE.

            Name: Perl Lint
            Command Line: perl -Mstrict -Mdiagnostics -cw "%f"
            Working Directory: %P
            (*) Output to List Box
            [ ] Show DOS Box
            [x] Capture Output

            Name: Run Perl Script
            Command Line: perl "%f"
            Working Directory: %P
            (*) Replace Existing
            [x] Show DOS Box
            [x] Capture Output

            Name: Debug Perl Script
            Command Line: perl -d "%f"
            Working Directory: %P
            (*) Output to List Box
            [x] Show DOS Box
            [ ] Capture Output

            Alternately, you can use perl -d:ptkdb "%f" if you have the Perl/Tk debugger installed. (http://ptkdb.sourceforge.net/)

            Name: perlcritic
            Command Line: perlcritic -verbose 2 "%n%e"
            Working Directory: %P
            (*) Output to List Box
            [ ] Show DOS Box
            [x] Capture Output

            Name: perltidy file
            Command Line: perltidy "%f"
            Working Directory: %P
            (*) Output to List Box
            [ ] Show DOS Box
            [x] Capture Output

            1

              Aug 13, 2010#6

              Hi,

              First I want to thank you for the Run Perl script. I use it to run perl in UltraEdit 16.10.

              Name: Run Perl Script
              Command Line: perl "%f"
              Working Directory: %P
              (*) Replace Existing
              [x] Show DOS Box
              [x] Capture Output

              However, when I run script that calls a CMD window as seen in my sample script it doesn't show print statement although it shows cmd window and waits to write a string and a number but it ignores print statment.

              #!/usr/bin/perl -w
              use strict;

              print "Enter string: ";
              my $string = <STDIN>;
              print "Enter number: ";
              chomp(my $number = <STDIN>);

              my $result =$string x $number;
              print "Result is \n$result";

              Any way to force UltraEdit to show print text?
              Enter number: (waiting for input here)

              6,686585
              Grand MasterGrand Master
              6,686585

                Aug 21, 2010#7

                Well, you have enabled the capture output option. Therefore UltraEdit redirects everything printed to the devices stdout and stderr into internal stream buffers and so nothing is written into the console window. When you want to see everything in the console window you have to uncheck the capture output option.

                For example when you would compile the following C source and then run the created EXE from within UltraEdit with capturing output you would only see in the console window (DOS box) what you enter and in captured output only the prompt text.

                Code: Select all

                #include <stdio.h>      // for printf() and getchar()
                
                void main(void)
                {
                 const char sPrompt[] = "Enter something: ";
                 int iChar;
                
                 printf(sPrompt);       // Print string to device stdout.
                 do
                 {
                  iChar = getchar();    // Get character from stdin with echo to stdout.
                 }
                 while(iChar != '\n');  // Break loop when RETURN pressed.
                }
                The solution would be that the console application writes to stdout as well as directly to console window as shown below:

                Code: Select all

                #include <stdio.h>  // for printf() and putchar()
                #include <conio.h>  // for cprintf(), getch() and putch()
                
                void main(void)
                {
                 const char sPrompt[] = "Enter something: ";
                 int iChar;
                
                 cprintf(sPrompt);  // Print string directly to console window.
                 printf(sPrompt);   // Print string to captured device stdout.
                 do
                 {
                  iChar = getch();  // Get character directly from keyboard and not from stdin without echo.
                  putch(iChar);     // Write character directly to console window not using stdout.
                  putchar(iChar);   // Print character to captured device stdout.
                 }
                 while(iChar != '\r');  // Break loop when RETURN pressed.
                }
                But such a console application is not portable because it uses DOS functions for direct access to video and keyboard. I doubt that the Perl interpreter supports printing directly to video console.
                Best regards from an UC/UE/UES for Windows user from Austria

                6
                NewbieNewbie
                6

                  How can I work with Perl in UE?

                  Feb 19, 2012#8

                  Which windows I need to open in UE to work with Perl?
                  How can I execute it and see directly result of my script?
                  The only thing I have found that have something with Perl is that I need to set View -> View As -> Perl.

                  Thanks!

                  6,686585
                  Grand MasterGrand Master
                  6,686585

                    Re: How can I work with Perl in UE?

                    Feb 19, 2012#9

                    spuzh wrote:Which windows I need to open in UE to work with Perl?
                    No one.
                    spuzh wrote:How can I execute it and see directly result of my script?
                    By configuring a user tool which runs the perl interpreter with the file name of active file as parameter. Open Advanced - Tool Configuration and setup the tool for running Perl interpreter with name of active file. Two examples on how to configure such a tool are given above. I don't have installed Perl interpreter and of course don't see into which directory you have installed the Perl interpreter. So I can't give you a definite answer how to configure the tool. In general you would need to enter respectively select after pressing button Insert.

                    On the tab Command:

                    Menu item name: Run Perl Script (or whatever you like as name)
                    Command line: "Full path to Perl program files directory\perl.exe" "%f"
                    Working directory: %p
                    Toolbar bitmap/icon (file path): Full name of a *.bmp or *.ico containing a 16x16 or 24x24 icon

                    You can leave the field for the file name of the bitmap/icon file empty if you don't have a suitable bitmap or icon file.

                    On the tab Options:

                    Program Type: DOS program
                    Save active file: checked
                    Save all files first: not checked

                    On the tab Output:

                    Command Output: Output to list box
                    Show DOS box: not checked (checked if script requires user input during execution)
                    Capture output: checked (not checked if script requires user input during execution)
                    Replace selected text with: No replace


                    Close the configuration dialog with button OK. You see now in menu Advanced the just configured user tool ready for execution by clicking on the menu item. You see also the hotkey assigned to the user tool. The hotkey can be modified at Advanced - Configuration - Key Mapping. The command name for first user tool is AdvancedUserTool1.

                    You can also right click on any toolbar, left click on Customize Toolbar and add User Tool 1 with the toolbar customization dialog to any toolbar for execution by clicking on the symbol of the tool. The symbol is loaded from the specified bitmap or icon file if you have configured one.

                    Now when you execute the user tool, UltraEdit saves the active file and starts Perl.exe with the full name of the active file as parameter. The working directory for Perl is set to the directory of the script file. The output of the Perl script is captured to the output window automatically displayed if capturing is enabled because no user input during script execution.