i have the executable files, now how to create the GUI

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

i have the executable files, now how to create the GUI

Post by maverickalex » Mon Mar 16, 2009 12:15 am

Hi everyone,

Firstly this is my first post and before i start i would just like to state that i am not just coming into the forum to demand scripts etc etc etc.

I am here to learn from those more knowledgable and experinced in programming languages.

I will be reading books and tutorials in order to gain the required information.
I WILL NOT be a pain in the ASS "scouts honour"

Ok so here goes.


This may seem somewhat random and a complete Newbie question.

As part of a free open source flight simulator we have tools under linux that can help create the terrain of the world.

Someone has gone to the trouble of converting the linux commands to run under windows.

However to get them to run we still need to run the command lines in the dos box.

It would be a whole lot simpler if there was a GUI that helped this for those people who have never touched command lines in their life.
Generally speaking the average Windoze user would have nightmares if faced with having to insert "code" into a window.

all the executables have been done, it just lacks for GUI.

examples of the present commands are as follows.

one such executable is called HGTCHOP.exe

Code: Select all

set PATH=e:\flightgear\terragear;%PATH% 
hgtchop 3 e:\flightgear\terragear\N07W071.hgt.zip e:\flightgear\work
where e\flighgear\terragear is the path to the executable
hgtchop is the exe
3 is a resolution
N070W071.hgt.zip is the file to unzip
and
e:flightgear\work is the folder to unzip the contents too.

we then get this lovely lot pinging away

Code: Select all

min = -252900,25650  max = -252450,26100 
start_x = 900  span_x = 150 
start_y = 150  span_y = 150 
array_file = e:\flightgear\work/w080n00/w071n07/1792078.arr.gz 
-71:7, 7:1 
width = 0.125 height = 0.125 
min = -252450,25650  max = -252000,26100 
start_x = 1050  span_x = 150 
start_y = 150  span_y = 150 
array_file = e:\flightgear\work/w080n00/w071n07/1792079.arr.gz 
-71:0, 7:2 
width = 0.125 height = 0.125 
min = -255600,26100  max = -255150,26550 
start_x = 0  span_x = 150 
start_y = 300  span_y = 150
to give us some nice uncompressed files of data out the other end.

The HGTchop .exe is one of a number(20) of tools that are usable and i would need to create a GUI that could select one of them, and on selecting that particular one show any parameters or different options associated with.

ie. the hgtchop has the option to choose different resolutions by putting 1 or 3.

and another would say have the option of different line widths etc.

What documentation would be the best to read up on in relation to those examples i have provided.

Any help or pointers would be really appreciated. Like i say, i dont want people to "do it for me" theres nothing quite like that satisfaction of when the penny drops.

Any advice or pointers would be much appreciated

Sorry this first post is long.

Thanks Alex

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Mon Mar 16, 2009 1:12 am

Alex-

Welcome to the revolution.

It sounds like you'll mostly be using the shell command. You pass it the commandline as an argument, i.e.,

get shell("hgtchop 3 e:\flightgear\terragear\N07W071.hgt.zip e:\flightgear\work")

(note that these can be variables as well...)

put 3 into tResolution
put "e:\flightgear\" into tDirectory
put tDirectory & "terragear\N07W071.hgt.zip" into tZipFile
put tDirectory & "work" into tWorkFile
get shell("hgtchop" && tResolution && tZipFile && tWorkFile)

and you'll probably also want to check out the hideconsolewindows property, as in

set the hideconsolewindows to true

Have fun.

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

Post by maverickalex » Mon Mar 16, 2009 7:43 pm

Thanks very much for that advice.

This is what i am looking to go for, simple but effective.

Image
Image

The first scrollable window obviously loads the drives on your pc and lets you find a particular folder.

Which from reading another thread the script would go along the lines of this.

Code: Select all

intDriveType = <<intDriveType>> 
strComputer = "." 
result = "" 
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colDisks = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk") 
For Each objDisk in colDisks 
  Select Case objDisk.DriveType 
  Case intDriveType 
    result = result & objDisk.DeviceID & vblf 
  End Select 
Next 
Set colDisks = nothing 
Set objWMIService = nothing
although i believe that just lets you choose a drive type.

So at the end of the 2nd stack, we would have a command equal to

Code: Select all

set PATH=e:\flightgear\terragear;%PATH% 
hgtchop 3 e:\flightgear\terragear\N07W071.hgt.zip e:\flightgear\work
At least thats the idea.

I'm quite enjoying the reading at the moment, lots over my head, but some sinking in at least. :shock:

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Mar 16, 2009 10:15 pm

Hi Alex and welcome,

You'll find that nobody is selfish with their code round here - when you have a positive learning attitude like yours there's no need to feel embarrassed about asking for help. I think I know the thread you've seen where <ahem> it may come across otherwise :oops:

Anyway, that snippet is, as you noticed, for using the Windows Management Interface scripting tools to interrogate the types of drives you have on the machine. To get a path to a file or folder, there is a much simpler native way (cross platform too) in the "answer file" and "answer folder" commands.

Code: Select all

  answer folder "Please select the path to your toolset"
   put it into tPath
   if tPath is not empty then
      put tPath into tWinPath
      replace "/" with "\" in tWinPath
   end if
   put tWinPath into field "fldToolsetPath"
will give you a path to the toolset folder in your first field. The slashes have been converted to the windows notation, although mostly native Rev file and folder paths work on Windows either way, when it comes to using shell commands, they should be converted to Windows style.

You can then temporarily "set the defaultFolder to tPath" (using standard Rev slashes) and "get the files" which will list the files in the default folder for you to choose which tool to run. You could of course just use the "answer file" version to browse directly to the tool to run without worrying about collecting the files in the defaultFolder.

HTH

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

Post by maverickalex » Mon Mar 16, 2009 10:52 pm

That's great, thank you. I must admit i did feel a little embarrased especially after reading "that" thread. I didn't want to come across in that way, and i can totally understand the replies given..
I enjoy learning new things so anything achieved from new is such a buzz. even just getting the machine to "beep" put a big smile on my face, so there will be cartwheels at the end :D

It's great to know that there are persons such as yourself willing to share a wealth of knowledge and have an abundance of patience where others may not.

thanks again

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Mar 16, 2009 11:27 pm

Hi Alex,

Instead of making two fields, you might make an application with a menubar.

File Edit Tools

And Tools could have the following menu items:

hgtchop
terrafit
terra
foftoolset
more...

and you might give some of these menu items a submenu, if there are several possibilties. I can imagine that hgtchop has two submenus, one for each resolution for instance.

If these tools are able to create more common formats, such as png, jpeg, mov etc, you might be able to display the output in your stack.

In the File menu, you might have a Save menu item that saves the hgt file and an Export menu item to save the zip file.

Just a few ideas. Let us know when you have questions about implementing these ideas (if you like).

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

Post by maverickalex » Mon Mar 16, 2009 11:30 pm

Even with that little bit of help, i have realised that i dont even need the first part of the GUI "answer folder"

I simply need "answer file"
which takes you straight to the exectuable i require and puts the path straight in.

I'll be Bill gates best pal in no time. :)

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

Post by maverickalex » Mon Mar 16, 2009 11:55 pm

Thanks Mark,

I didnt realise you had posted prior to my last post.

I think as i have mentioned i only need the path initially to the .exe file.

***edit*** Although having read your post more thoroughly that seems a much simpler way of doing things and gives even better choice at a later development stage.*****

The more advanced side of it is the variables and the outputs.

My problem at the moment is that i dont actaully know what all the tools do yet. Some may be obsolete by now,(i'm on with double checking)

I know there is at least 7 tools which are vital for the conversion process, each one having different variables. and needing to be in the right order.

for example, i have simply called up the terrafit.exe with no command line arguements.

here is its output
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Code: Select all

C:\Documents and Settings\alex>e:\flightgear\terragear\terrafit.exe
Min points = 50
Max points = 1000
Max error  = 40
Insufficient arguments
Usage: e:\flightgear\terragear\terrafit.exe [options] <file | path to walk>
         -h | --help
         -m | --minnodes 50
         -x | --maxnodes 1000
         -e | --maxerror 40
         -v | --version

Algorithm will produce at least <minnodes> fitted nodes, but no
more than <maxnodes>.  Within that range, the algorithm will stop
if the maximum elevation error for any remaining point
drops below <maxerror> meters.

Increasing the maxnodes value and/or decreasing maxerror
will produce a better surface approximation.

The input file must be a .arr.gz file such as that produced
by demchop or hgtchop utils.

**** NOTE ****:
If a directory is input all .arr.gz files in directory will be
processed recursively.

The output file(s) is/are called .fit.gz and is simply a list of
from the resulting fitted surface nodes.  The user of the
.fit.gz file will need to retriangulate the surface.
and onother tool asks for these variables

Code: Select all

C:\Documents and Settings\alex>e:\flightgear\terragear\shape-decode.exe
Usage: e:\flightgear\terragear\shape-decode.exe [--line-width width] [--point-wi
dth width] [--area-column col] [--code-col col] [--line-width-column col ]  [--c
ontinue-on-errors] [--max-segment max_segment_length] [--start-record num] <shap
e_file> <work_dir> [ area_string ]
Options:
--line-width width
        Width in meters for the lines
--point-width width
        Size in meters of the squares generated from points
--max-segment max_segment_length
        Maximum segment length in meters
--area-column col
        Get areatype for objects from column number col
        in associated dbf-file (only if <area_string> is not given)
--code-column col
        Get codetype for objects from column number col
        in associated dbf-file
        (currently code is only used in debug printouts)
--continue-on-errors
        Continue even if the file seems fishy

--start-record record-number
        Start processing at the specified record number (first record num=0)
--end-record record-number
        End processing at (immediately after) the specified record number (first
 record num=0)

<shape_file>
        Name of the shape-file to process, without .shp extension
<work_dir>
        Directory to put the polygon files in
<area_string>
        (Optional) Area type for all objects in file
        Overrides --area-column option if present

it helpfully gives "usage" information so i can see what needs to go where at least


I have modified my initial stack now so just press go and find the tool required. (big leap) :D

Image

I'm thinking of either:
a:- just putting the variable options in a menu box with a text field for the variable.

then selecting the output folder in the same way as finding the tool initially.
or
b:-creating another stack for the variables, the slimmer the application the better i would think.

Does that make sense?

heres what i think you mean Mark with a tools menu.
Image

would those tools in the menu need the "get shell" script ?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Tue Mar 17, 2009 5:18 am

Looks nice. Now I'd throw a menuPick handler in the tools button of the menu thusly:

Code: Select all

on menuPick pChoice
  switch pChoice
    case "Demchop"
      -- do the Demchop thing
      break
    case "deminfo"
      -- do the deminfo thing
      break
-- etc
    default
  end switch
end menuPick
...and it's a matter of personal preferences, but I like to keep things fairly short if possible, so I would make "Demchop" a separate handler rather than deal with it in the switch statement:

Code: Select all

    case "Demchop"
      doDemchop
      break

on doDemchop
-- do stuff here
-- here's where you compile you list of arguments
-- and issue a shell call
end doDemchop
[/code]

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 17, 2009 9:28 am

Looks good to me, Alex.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

Post by maverickalex » Tue Mar 17, 2009 4:28 pm

ok the tools menu has the script you set above. ie

Image
case "Demchop"
doDemchop
break

on doDemchop
-- do stuff here
-- here's where you compile you list of arguments
-- and issue a shell call
end doDemchop
is that used instead of whats in the image? or create a handler for each of the tools in the selection.

I maybe just got ahead of myself :oops:

I know it's not ideal but i am reading up on the parts of code you are suggesting to see how it fits in. That way i am learnign whilst also moving forward with your help.

BTW i'm sorry for all the images, i ust find it easier to explain things that way, at least you can see what or where i'm up to.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 17, 2009 4:40 pm

Dear Alex,

You can now replace a line

Code: Select all

do the demchop thing
with a command

Code: Select all

doDemchopThing
and put another handler elsewhere in your stack or even in the same button "Tools" (but the latter is not recommended):

Code: Select all

on doDemChopThing
  -- do the demchop thing
end deDemChopThing
Now you can replace

Code: Select all

--do the demchop thing
with your own code, which should probably include a shell function.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

maverickalex
Posts: 108
Joined: Sun Mar 15, 2009 11:51 pm

Post by maverickalex » Tue Mar 17, 2009 6:05 pm

i think i need to read a bit more, I am getting confused. :oops:

i'm struggling with the variables.

if i created a field labelled "variables"
and a field labelled finalchoice

then did this code

Code: Select all

put variable() into toolsetchoice
put toolsetchoice() into finalchoice
would that work.
Well i know it doesnt becuase i tried it.
I tried running before i could walk it seems lol

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 17, 2009 6:18 pm

Hi Alex,

What exactly are you trying to do? What do you want the functions variable and toolsetchoice to do? I'm not sure that variable is a good choice for a function name. I'd use a different name.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Tue Mar 17, 2009 6:22 pm

Not quite sure what you're trying to do there, but if you're trying to put something into a field you have to say that explicitly:

Code: Select all

put variable() into field "toolsetchoice"
put toolsetchoice() into field "finalchoice"
...and I'd agree about "variable" being a bad choice for a function name. Just to stay out of trouble.

Post Reply