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

Post by maverickalex » Thu Mar 19, 2009 3:18 pm

:D :D :D :D :D :D

Code: Select all

 put "--input=" & field "aptdatfld" into taptdatfld
   put"--work=" & field "workdirfld" into tworkdirfld
   if field "startidfld" is not empty then
      put"--start-id=" & "startidfld" into tstartidfld
      end if
      if field "nudgefld" is not empty then
         put "--nudge=" & "nudgefld" into tnudgefld
ETC.

works a treat. Thanks.. Again :oops:
i fear i may have descended into what i didnt want to be. :oops:

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

Post by maverickalex » Thu Mar 19, 2009 7:36 pm

I'm nearly there i promise!!!

a few questions that i can't find the answers too or just need clarification.

1. my fourth tool has a long list of items in a scrolling field.

i want to when it is clicked on, have it selected then ready for insertion in the correct place. (i think i know how to do the latter part now) for when i run the tool.

I have put this script in the scrolling list.

Code: Select all

on mouseUp
   put the hilitedLine of field "shapefilefld" into tshapefilefld
end mouseUp
does that seem right?

then i add the tshapefilefld to the tshellcommand later.

2. can i just put this in the tshellcommand

Code: Select all

put "--continue-on-errors" into tshellcommand
where i need it. it has to go in, but its not something thats going to be selectable so no need to create a field for it.

and lastly
3. The full command line i am following goes like this.

Code: Select all

e:\terragear\shape-decode --line-width 10 --continue-on-errors --max-segment 1000 e:\vmap\v0_road e:\terragear\work\road road
As you can see at the end there are two "road road"
this creates a road folder in the terragear\work folder

can this be done with a script?


Image

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

Post by SparkOut » Thu Mar 19, 2009 7:59 pm

maverickalex wrote:I have put this script in the scrolling list.

Code: Select all

on mouseUp
   put the hilitedLine of field "shapefilefld" into tshapefilefld
end mouseUp
does that seem right?
It seems right. But what you actually will get is the line number of the hilited line of field "shapefield" put into the variable. You need something actually like

Code: Select all

put line (the hilitedline of field "shapefilefld") of field "shapefilefld" into tshapefilefld
maverickalex wrote:2. can i just put this in the tshellcommand

Code: Select all

put "--continue-on-errors" into tshellcommand
where i need it. it has to go in, but its not something thats going to be selectable so no need to create a field for it.
Well, yes, you can, but it will overwrite anything that's there in the first place. If you put the "--continue-on-errors" switch into the tshellcommand string in the right place by concatenating it in the "build" part along with the rest, and using 'put space & "--continue-on-errors" after tshellcommand' or similar at the appropriate point you can insert the static literal value without any problem.
maverickalex wrote:3. The full command line i am following goes like this.

Code: Select all

e:\terragear\shape-decode --line-width 10 --continue-on-errors --max-segment 1000 e:\vmap\v0_road e:\terragear\work\road road
As you can see at the end there are two "road road"
this creates a road folder in the terragear\work folder

can this be done with a script?
Can what be done? adding the extra parameter, or creating the folder in the first place?
If you need to add the extra parameter, then yes - you might need to be concerned about the overall string and quote things with spaces in and/or quote all the parameters and have an extra set of quotes to wrap the whole thing. Your own experimentation will have to tell you that though.
If you need to have ensured that a folder exists and if not, then create it before running then you can do something like:

Code: Select all

if there is not a folder tWorkFolder then
  create folder tWorkFolder
end if
Rev should work with tWorkFolder containing Windows native backslashes (although shell commands will probably only want to see Windows backslashes, not Rev native slashes). You can also only create a folder in a folder that already exists - so you may need to check for the existence of all the folders in the path and create each one ready for the next subfolder to exist in as necessary.

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

Post by maverickalex » Thu Mar 19, 2009 9:52 pm

ok, i have the tool working fine, but not as i would like it to.

heres where it doesnt work as i'd like and i dont know if we can do a work around for it.

This particular tool finds an already downloaded file.
for example.
v0_road.shp
(each one of the .shp files relates to some form of terrain, ie roads/crops/coast etc)

but in order for the tool to work it needs to take the file extension (.shp) off.
This is why i made the scrollable list.

point the tool at the folder with the file in and then select the name of the file without the .shp from that list.

However on looking at it, that wont work because it not actually selecting the .shp file.

i can select the v0_road.shp file and then manually remove the .shp extention and the tool will run fine.

Is there a way to select the file and then have the program remove the .shp before running the tool?

secondly.
if there is not a folder tWorkFolder then
create folder tWorkFolder
end if
what i meant was, when the tool extracts the information from the .shp file i need the application to create another folder within the file destination folder.

ie. again the same example extracting v0_road to e:\terragear\work
the program should create a folder within terragear\work called v0_road and extract the data into that.

does that make sense?

this is my script so far

Code: Select all

on mouseUp 
   local tShellCommand 
   if field "linewidthfld" is not empty then
   put "--line-width" & space & field "linewidthfld" into tlinewidthfld
      end if
   if field "pointwidthfld" is not empty then
      put "--point-width" & field "pointwidthfld" into tpointwidthfld
   end if
   if field "maxsegfld" is not empty then
      put "--max-segment" & space & field "maxsegfld" into tmaxsegfld
      end if
      if field "startrecfld" is not empty then
         put "--start-record" & field "startrecfld" into tstartrecfld
         end if
   if field "areafld" is not empty then
      put "areafld" into tareafld
   end if
   if field "shapefilefolderfld" is not empty then
      put field "shapefilefolderfld" into tshapefilefolderfld
   end if
   if field"workfolderfld" is not empty then
      put field "workfolderfld" into tworkfolderfld
   end if
  
   

--put space & quote & quote into tShellCommand 
--the above line puts an empty pair of quotes to be the 
--first parameter passed to the shell command which is 
--necessary to act as the dummy console window "title" 
--if setHideConsoleWindows is true 
--so you will need to uncomment the line when you do that. 

put space & "shape-decode" & space after tShellCommand 
put space & tlinewidthfld & space after tShellCommand 
put space & tpointwidthfld & space after tshellcommand
put "--continue-on-errors" after tshellcommand
put  space & tmaxsegfld after tShellCommand 
put space & tstartrecfld after tshellcommand
put space & tshapefilefolderfld after tshellcommand
put space & tworkfolderfld after tshellcommand
put space & tareafld after tshellcommand 
answer "About to:" && quote & "start" & tShellCommand & quote 
get shell ("start" & tShellCommand) 
end mouseUp

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

Post by SparkOut » Thu Mar 19, 2009 11:19 pm

maverickalex wrote:but in order for the tool to work it needs to take the file extension (.shp) off.
This is why i made the scrollable list.

point the tool at the folder with the file in and then select the name of the file without the .shp from that list.

However on looking at it, that wont work because it not actually selecting the .shp file.

i can select the v0_road.shp file and then manually remove the .shp extention and the tool will run fine.

Is there a way to select the file and then have the program remove the .shp before running the tool?
You can do this easily enough either by having the filenames including the extension in the scrolling list field, and then 'replace ".shp" with empty in tshapefilefolder' before execution, or by adding the extension thus:
if field "shapefilefolderfld" is not empty then
put field "shapefilefolderfld" & ".shp" into tshapefilefolderfld
end if

or something along those lines if I've not got the paths and selections right.
maverickalex wrote:secondly.
if there is not a folder tWorkFolder then
create folder tWorkFolder
end if
what i meant was, when the tool extracts the information from the .shp file i need the application to create another folder within the file destination folder.

ie. again the same example extracting v0_road to e:\terragear\work
the program should create a folder within terragear\work called v0_road and extract the data into that.
so if the parameter v0_road comes from tRoad wherever you have sourced that info, and the destination folder has been selected from the gui and put into tworkfolderfld, then you could put these together with something of the ilk:

Code: Select all

put tworkfolderfld & "" & tRoad into tDestinationFolder
if there is not a folder tDestinationFolder then
  create folder tDestinationFolder
else
  --if the folder already exists, then maybe
  --you need to error trap or ask for confirmation
  --before overwriting?
end if

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

Post by maverickalex » Fri Mar 20, 2009 1:06 pm

I have the tool running ok now other than the folder creating issue.

But i'm gonna solve that by just getting the end user to create the folder that is needed.
They need to create a proper folder tree anyway or it gets v complicated.

I noticed howver that if i manually create a folder which is incorrectly spelt in relation to the specific item being decoded.
ie.
decoding v0_road and i try and download it to v0_roads it will create the folder v0_road and download the info into there as i would like it to.
heres my script so far.

Code: Select all

on mouseUp 
   local tShellCommand 
   if field "linewidthfld" is not empty then
   put "--line-width" & space & field "linewidthfld" into tlinewidthfld
      end if
   if field "pointwidthfld" is not empty then
      put "--point-width" & field "pointwidthfld" into tpointwidthfld
   end if
   if field "maxsegfld" is not empty then
      put "--max-segment" & space & field "maxsegfld" into tmaxsegfld
      end if
      if field "startrecfld" is not empty then
         put "--start-record" & field "startrecfld" into tstartrecfld
         end if
   if field "areafld" is not empty then
      put "areafld" into tareafld
   end if
   if field "shapefilefolderfld" is not empty then
      put field "shapefilefolderfld" into tshapefilefolderfld
   end if
   if field "shapefilefld" is not empty then
      put "shapefilefld" into tshapefilefld
   end if
   put line (the hilitedline of field "shapefilefld") of field "shapefilefld" into tshapefilefld
   replace ".shp" with empty in tshapefilefld
   if field"workfolderfld" is not empty then
      put field "workfolderfld" into tworkfolderfld
   end if
  
   

--put space & quote & quote into tShellCommand 
--the above line puts an empty pair of quotes to be the 
--first parameter passed to the shell command which is 
--necessary to act as the dummy console window "title" 
--if setHideConsoleWindows is true 
--so you will need to uncomment the line when you do that. 

put space & "shape-decode" & space after tShellCommand 
put space & tlinewidthfld & space after tShellCommand 
put space & tpointwidthfld & space after tshellcommand
put "--continue-on-errors" after tshellcommand
put space & tmaxsegfld after tShellCommand 
put space & tstartrecfld after tshellcommand
put space & tshapefilefolderfld after tshellcommand
put "\" & tshapefilefld after tshellcommand
put space & tworkfolderfld after tshellcommand
put space & tareafld after tshellcommand 
answer "About to:" && quote & "start" & tShellCommand & quote 
get shell ("start" & tShellCommand) 
end mouseUp

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

Post by maverickalex » Mon Mar 23, 2009 2:46 pm

Could you suggest a script, i could use to select all the folder names from a particular folder, so that those names could be transferred into a text field. thos names are then inserted into my final command line.
or even suggest a better format of doing this.

For example i might have 15 folders each named differently say " Landmass Road Rail Forest" etc.

My idea was initially to have a script to select all the folder names and have them placed into a scrollable text field. Where i could then use a ctrl & mouse click to select all the folder needed. But i dont know if thats the best way to go about it.

Thanks very much

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

Post by Mark » Mon Mar 23, 2009 3:44 pm

Dear maverickalex,

The folders function gives you a list of folders in the current directory:

Code: Select all

put the folders
You can assemble the full path to a folder by appending one of the folders to the defaultFolder (or directory).

Code: Select all

put the directory into myDir
put the folders into myFolderList
repeat for each line myFolder in myFolderList
  put myDir & slash & myFolder into myCurrentFolder
  -- do something with myCurrentFolder here
end repeat
Best regards,

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 23, 2009 6:57 pm

This is the last tool in my required set.

Image

As you can see the top selectable field is where the tool point to the "work" directory.

The contents of that Work directory and numerous folders (which can be different each time) and looks similar to this.

Image

The end command line which i am following is this.
Image

does that script populate the myfolder list (big list field at the bottom)
with the folders from myworkdir ?

Thanks, and sorry again for the stupid questions

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

Post by SparkOut » Mon Mar 23, 2009 8:51 pm

No, Mark was answering with info about how to interrogate the folders, I don't think he could have known exactly what you wanted to do with them, hence the "--do something with myCurrentFolder here" line.

Anyway, you should need to do something along the lines of

Code: Select all

put the defaultFolder into tOldFolder
set the defaultFolder to field "workfolderfield"
put the folders into field "folderlistfield"
--set the listBehaviour, multipleHilites, 
--nonContiguousHilites and toggleHilites
--of that field to true
set the defaultFolder to tOldFolder
Then when the action is taken to build the command, you can

Code: Select all

put the hilitedLines of field "folderlistfield" into tSelectedLines
repeat for each item tLine in tSelectedLines
  put space & line tLine of field "folderlistfield" after tTheCommandLine
end repeat
at the appropriate point.

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

Post by maverickalex » Mon Mar 23, 2009 8:54 pm

Thats what i was after, i tried marks way and wasnt coming up with the right results.
I knew the hilited function would be needed. but it looks like the way you describe is the way forward.

Thanks Agian
Ill report back

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

Post by maverickalex » Mon Mar 23, 2009 9:14 pm

Code: Select all

on mouseUp
put the defaultFolder into tOldfolder 
set the defaultFolder to field "workdir" 
put the folders into field "folderlistfield" 
--set the listBehaviour, multipleHilites, 
--nonContiguousHilites and toggleHilites 
--of that field to true 
set the defaultFolder to tOldFolder
   end mouseUp
That works a treat and i get my folders in the folderlistfield.

There is an extra folder appears with ".."
i'm thinking of using the filterfolder function but i keep getting an error

Code: Select all

on mouseUp
   # Filters the strings "." and ".." from a list
   function filterDots pList
  local tList
  put pList into tList
  filter tList without "."
  filter tList without ".."
  return tList
end filterDots
# Returns a filtered list of folders in the current directory
function filteredFolders
  return filterDots(the folders)
end filteredFolders
put the defaultFolder into tOldfolder 
set the defaultFolder to field "workdir" 
put the folders into field "folderlistfield" 
--set the listBehaviour, multipleHilites, 
--nonContiguousHilites and toggleHilites 
--of that field to true 
set the defaultFolder to tOldFolder
   end mouseUp
i know its a basic error

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

Post by SparkOut » Mon Mar 23, 2009 9:44 pm

Ah, but you never learn unless you try!

In this case there's no pressing reason to use a function:

Code: Select all

on mouseUp 
  put the defaultFolder into tOldfolder 
  set the defaultFolder to field "workdir" 
  put the folders into tList
  filter tList without "."
  filter tList without ".."
  put tList into field "folderlistfield" 
  --set the listBehaviour, multipleHilites, 
  --nonContiguousHilites and toggleHilites 
  --of that field to true 
  set the defaultFolder to tOldFolder 
end mouseUp
A function is a separate block of code that takes some input, processes it, and returns a value to the section of code that called the function. In this case you would (hypothetically) use a function to strip the dots by something like:

Code: Select all

on mouseUp 
  put the defaultFolder into tOldfolder 
  set the defaultFolder to field "workdir" 
  put the folders into tList
  put fnStripDots(tList) into field "folderlistfield" 
  --the function is called here, but the code that actually
  --comprises the function is separate from the mouseUp handler
  set the defaultFolder to tOldFolder 
end mouseUp

function fnStripDots pList
  --this function could be placed anywhere
  --in the message path that is traversed
  --from the code that calls it
  --so it could be in the same card, or
  --in the stack script, etc. and would 
  --also be usable by any other routines that
  --needed a strip dots function
  filter pList without "."
  filter pList without ".."
  return pList
end fnStripDots
Here the mouseUp handler gets the folder list and posts it away to the strip dots sausage machine, which sends back a new list without dots, so the mouseUp handler can put that returned data into the field.

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

Post by maverickalex » Mon Mar 23, 2009 9:51 pm

i wasn't too far off then. Thanks again SparkOut. I have learnt so much in a short time thanks to your patience and encouragement.
Im quite excited, only the final command line button to do and thats it. :D

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

Post by maverickalex » Mon Mar 23, 2009 10:50 pm

i have a problem somewhere in the script for the final command line.

I cant seem to find it.

Heres the final script

Code: Select all

on mouseUp 
   local tShellCommand 
   if field "workdir" is not empty then
   put field "workdir" into tworkdir
      end if
   if field "outputfld" is not empty then
      put field "outputfld" into toutputfld
   end if
   if field "lonfld" is not empty then
      put field "lonfld" into tlonfld
      end if
      if field "latfld" is not empty then
         put field "latfld" into tlatfld
         end if
   if field "xdistfld" is not empty then
      put "xdistfld" into txdistfld
   end if
   if field "ydistfld" is not empty then
      put field "ydistfld" into tydistfld
   end if
   If field "folderlistfield" is not empty then
      put field "folderlistfield" into tfolderlistfield
      end if
   
  
   

--put space & quote & quote into tShellCommand 
--the above line puts an empty pair of quotes to be the 
--first parameter passed to the shell command which is 
--necessary to act as the dummy console window "title" 
--if setHideConsoleWindows is true 
--so you will need to uncomment the line when you do that. 

put space & "fgfs-construct" & space after tShellCommand 
put space & "--work-dir=" & tworkdir after tShellCommand 
put space & "--output-dir=" & toutputfld after tshellcommand
put space & "--lon=" & tlonfld after tshellcommand
put space & "--lat=" &  tlatfld after tShellCommand 
put space & "--xdist=" & txdistfld after tshellcommand
put space & "--ydist=" & tydistfld after tshellcommand
put the hilitedLines of field "folderlistfield" into tSelectedLines 
repeat for each item tLine in tSelectedLines 
put space & line tLine of field "folderlistfield" after tshellcommand
end repeat
answer "About to:" && quote & "start" & tShellCommand & quote 
get shell ("start" & tShellCommand) 
end mouseUp
it doesn't seem to want to show the xdist value
or the list of folders after.

Image
as soon as the tool runs it crashes. Which is not too clever :shock:

Can you see my mistake?

Post Reply