C10: Hand Coded Form example

I wrote this program as a learning exercise, to learn how queues work, how to read and write INI files and plain text files (using stringtheory)

I also learnt how to edit the values in a list and update the queue. Many thanks to all the people who generously helped me by answering newbie questions, especially @MarkGoldberg for his code review and debuger code

The complete project is here: https://github.com/DonnEdwards/Fixer

I would greatly appreciate any comments, criticisms, suggestions or bug reports. The debug viewer I used was https://github.com/CobaltFusion/DebugViewPP

Hi Donn,

A couple of little comments.

  1. I think most people would declare a variable and then use it in the window declaration, so that you wouldn’t have statements like = ?No{PROP:Value}.

  2. You treat your filenames sometimes as CSTRINGS and sometimes as STRINGS. Personally I would stick with CSTRINGS.

Jon

1 Like

I’m not sure how to do this. Can you give me a simple example?

Thanks for the note about filenames and strings. I’ll take a closer look. Much appreciated.

You declare variables and then use the as USE attribute in your control definitions.
`
SearchString cstring(41)
ReplaceString cstring(41)
No long ! I’d probably use a different variable name :slight_smile:

                    ENTRY(@s40),AT(17,115,99,10), USE(SearchString),MSG('Use this to edit the search string')
                    ENTRY(@s40),AT(119,115,98,10),USE(ReplaceString),MSG('Use this to edit the replace string')
                    ENTRY(@N4),AT(221,115,36,10), USE(No),MSG('Use this to edit a particular entry')

`

Then in your code you can use the variables to get the values from the control.

`
If No = 42

!Do something

end
`
If you want to manipulate the control then use the ? syntax.

?SearchString{Prop:Color,1} = color:blue

1 Like

 PROGRAM
 MAP
 END
mynumber  SHORT
Window    WINDOW('Caption'),AT(,,236,221),GRAY,FONT( 'SegoeUI',9)
           BUTTON('&OK'),AT(19,62,41,14),USE(?OkButton),DEFAULT
           BUTTON('&Cancel'),AT(69,62,42,14),USE(?CancelButton)
           STRING( 'Myfavourite number:'),AT(2,15),USE(?dispstr)
           ENTRY(@n4),AT(79,15),USE(mynumber)
         END
 CODE
 open(window)
      
 ACCEPT
   case accepted()
          
   of ?mynumber
              
     message( 'yourfavourite # is ' &mynumber)

   of ?OkButton
              
     close(window)
          
   end
 end
1 Like

Hi Donn -

Couple of things.

You have the beginning of some nice functions. It would be good to test for errors and respond to them.
e.g. in ProcessAllFiles, you call GetAllFiles. What if there’s a problem with GetAllFiles? You wouldn’t want to proceed if there was.
I’d have an error test after COPY(), ST.LoadFile, and ST.SaveFile as well.
I didn’t read all of the code, but those are things I noticed.

Also, my personal preference would be to copy the files to a separate folder for processing and leave the source folder intact.

There’s a function called fnsplit() as defined in libsrc\CLIB.CLW That might be useful to you.

1 Like

Thanks for all the suggestions so far. I am working through them.

I tried replacing ?No with intPairNo but when I want to update the value on the form I still need to use

?intPairNo{PROP:Use} = intPairNo

Any idea why this would be necessary? See updated Github code

Hi Donn,

If you update the intPairNo variable, and you want that change to appear on the screen, you use Display(?intPairNo).

Jon

image002.jpg

1 Like

Thanks for the suggestions. I have updated the code and made some other improvements to version 1.0.5

I’ll take look st fnsplit() shortly