Author Topic: User Selected Images 2  (Read 21705 times)

androbourne

  • Newbie
  • *
  • Posts: 13
User Selected Images 2
« on: July 16, 2011, 08:11:22 AM »
Hello,

The application I'm creating requires a ratio button to allow the user to select a user image to place on canvas. I have the buttons working and images are loading onto the canvas just fine (Thanks to Malkom for the email support working out some of the small glitches)

Here are my following questions.

1. Once a user selects the image they wish to import how do I go about allowing it to save to the canvas it was imported to by the user so it will reload on a new start up?

I read what I could about image banks but I don't fully understand how or where the image banks are saved or how they are used.

2. I'd also like to allow the user to select a file or .exe location to the selected canvas, thus allowing the user to select the canvas to open the application. Once done this should also save for future use.

I read what I could from here http://www.tigabyte.com/smf/index.php?topic=72.0 but I wasn't 100% what was related to this topic and what as more then what I needed.

Thank you for your time in advance!

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: User Selected Images 2
« Reply #1 on: July 16, 2011, 03:30:40 PM »
Hi Andro

Nice to see you managed to make it to the forums after the problems of my switching forum software.


1. Once a user selects the image they wish to import how do I go about allowing it to save to the canvas it was imported to by the user so it will reload on a new start up?

I read what I could about image banks but I don't fully understand how or where the image banks are saved or how they are used.

Usually when a HyperNext stack or exe quits it saves the state of canvases so you don't have to do anything. It also saves the state of fields and variables but not arrays.

The QuitSave(0) command causes it to quit without saving while QuitSave(1) forces it to save before quitting. The simple Quit command always saves before quitting.

If you want to save a canvas yourself there are a few CanvasSave commands and also matching CanvasLoad commands. They are explained here:-

http://www.tigabyte.com/smf/index.php?topic=72.0


Image banks have commands for loading images and also transferring them to and from canvases.
They are explained in the above link and also here:-


http://www.tigabyte.com/smf/index.php?topic=22.0




2. I'd also like to allow the user to select a file or .exe location to the selected canvas, thus allowing the user to select the canvas to open the application. Once done this should also save for future use.

I read what I could from here http://www.tigabyte.com/smf/index.php?topic=72.0 but I wasn't 100% what was related to this topic and what as more then what I needed.

Basically you need a filepath(folderitem) to the exe to be launched. The FileAsk command presents a dialog box allowing the user to select a file and it returns details about that file. Once you have a file's details then it can be passed to the FolderItemLaunch command.

Here is a post about launching other programs:-

http://www.tigabyte.com/smf/index.php?topic=119.msg396#msg396



Malkom

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #2 on: July 16, 2011, 08:35:12 PM »
On the first question, when I compiled then ran my application, changed the canvas image and hit exit then reloaded the application it did not reload the image I selected... I also added the quitsave(1) command to exit and tried it that way still nothing, I'm I doing something wrong?

I also have a place holder for the images but I tried removing the place holder as well with no luck.


on the second question.

I tried using FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens) on a button. I want to use as a canvas to save the location of the file in, when I try to run the application it gives me a "file missing index" error.

I also tried to run this from the canvas directly and nothing. am I using this code incorrectly?

If a file path name is required for fileask command is there something I can use to obtain the filename from the users computer? I'd like to make it so the user can simply just select a button, dialog box pops up and asks for .exe location, once selected saves the .exe location into the canvas and next time the user selects the canvas it will launch the .exe
(which now I think of it I'd also need to add a way of fileask to know which canvas to put that .exe location in since I have 24 canvases on 1 card)

Im guessing the best way for this could be to create a button for fileask and have the canvas contain folderitemlaunch command? so I guess the main question here is how do I get fileask to obtain the filename from the user and place that file name into folderitemlaunch on the canvas?
« Last Edit: July 16, 2011, 08:40:29 PM by androbourne »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: User Selected Images 2
« Reply #3 on: July 18, 2011, 11:36:01 AM »
On the first question, when I compiled then ran my application, changed the canvas image and hit exit then reloaded the application it did not reload the image I selected... I also added the quitsave(1) command to exit and tried it that way still nothing, I'm I doing something wrong?

I also have a place holder for the images but I tried removing the place holder as well with no luck.

I'm not sure what is happening here as its failing for me to.

However, this manual works though and assumes canvas 3 is being used:-

Code: [Select]
@ Save canvas 3 to local JPEG file
@ quality = 100 %
CanvasJPEGSave(3,'Test.jpg',100)


Code: [Select]
@ Load canvas 3 from a local JPEG file
@ scale param = 1, so canvas is filled
CanvasLoad(3,'Test.jpg',1)


There is also a CanvasJPEGSaveAbs and associated CanvasLoadAbs for when you need to save/load the image from anywhere on the computer - uses absolute(full) file path.

Code: [Select]
@ Save canvas 3 to JPEG file
@ quality = 100 %
Local fname
Put 'c:\images\Test.jpg' into fname
CanvasJPEGSaveAbs(3,fname,100)


Code: [Select]
@ Load canvas 3 from a JPEG file
@ scale param = 1, so canvas is filled
Local fname
Put 'c:\images\Test.jpg' into fname
CanvasLoad(3,fname,1)








on the second question.

I tried using FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens) on a button. I want to use as a canvas to save the location of the file in, when I try to run the application it gives me a "file missing index" error.

I also tried to run this from the canvas directly and nothing. am I using this code incorrectly?

If a file path name is required for fileask command is there something I can use to obtain the filename from the users computer? I'd like to make it so the user can simply just select a button, dialog box pops up and asks for .exe location, once selected saves the .exe location into the canvas and next time the user selects the canvas it will launch the .exe
(which now I think of it I'd also need to add a way of fileask to know which canvas to put that .exe location in since I have 24 canvases on 1 card)

Im guessing the best way for this could be to create a button for fileask and have the canvas contain folderitemlaunch command? so I guess the main question here is how do I get fileask to obtain the filename from the user and place that file name into folderitemlaunch on the canvas?

This code places the full file path into field 1 and launches the selected application in the background:-

Code: [Select]
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens

FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Put line 9 of fdetails into field 1

FolderItemLaunch(fhandle,1)


Below are the specs for the info returned in the param fdetails (we used line 9 above). These can be used to determine if the file exists, is a folder etc:-


The details of a file or folder is returned as a list of attributes separated by carriage returns.

   1    -  Name of file or folder.
   2    -  1 if it exists, 0 otherwise.
   3    -  1 if it is a folder, 0 if a file.
   4    -  1 if an alias.
   5    -  1 if visible.
   6    -  1 if locked.
   7    -  1 if writeable.
   8    -  1 if readable.
   9    -  the absolute path.
   10  -  the number of items in the folder.
   11  -  The Mac Type code.
   12  -  The Mac Creator code.
   13  -  the creation short date.
   14  -  the creation short time.
   15  -  the modification short date.
   16  -  the modification short time.
   17  -  the display name.
   18  -  1 if the extension is visible.
   19  -  the length of the data fork.
   20  -  the length of the resource fork.
   21  -  the Macintosh Directory ID - an integer.
   22  -  the Macintosh VRefNum - an integer.
   23  -  Actual name including extension.
   24  -  filename extension.
   25  -  type (user created ).
   26  -  Parent directory absolute pathname.
 

I hope this helps
Malkom

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #4 on: July 19, 2011, 08:43:14 PM »
In regards to the first question about images.

I did it manually and it did work only problem I have is the only way it will load the image is if I click on the canvas, is there a way will auto load without me having to click on the canvas?

Or if not code that would auto click the canvas for me on startup?



In regards to question 2

Once i have the .exe location in field 1 how can I put that info into this command?

Local fname,fhandle,fdetails,ftypes, fpaths,fnames,fextens

  @ set the filename of the program to launch
  Put 'TO PUT .EXE LOCATION HERE' into fname

  @ Get the file handle
  FolderItemGetAbs(fname,fhandle,fdetails,ftypes, fpaths,fnames,fextens)

  @ Launch the application in the foreground
  FolderItemLaunch fhandle,1

any ideas?

Also my field 1 would be located on a hidden card, what command could I use to put this on a hidden card? card number is 4

Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens

FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Put line 9 of fdetails into field 1

FolderItemLaunch(fhandle,1)


Im guessing it's something like

"Put line 9 of fdetails into FieldFN(1, 4)"   ???
« Last Edit: July 19, 2011, 09:04:48 PM by androbourne »

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #5 on: July 19, 2011, 09:08:47 PM »
Actually in regards to question 1 I figured it out I was placing the code into canvas instead of page code.

All I need is help with question 2 and Im set. Thank you.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: User Selected Images 2
« Reply #6 on: July 20, 2011, 04:45:30 PM »
Actually in regards to question 1 I figured it out I was placing the code into canvas instead of page code.

All I need is help with question 2 and Im set. Thank you.

Thats great you figured Q1 out  :)

For Q2:-
As you already have the full path to the exe in the field then you just need to create a file handle from that path for the FolderItemLaunch command. The FolderItemGet command can create a file handle from a valid path.


Code: [Select]
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens

@ place path into a var
Put field 1 into fname

@ fetch file handle
FolderItemGet(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

@ Launch the application in the foreground
FolderItemLaunch fhandle,1


I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #7 on: July 20, 2011, 08:23:15 PM »
I'll try this out, and what about obtaining that data from another card? is the fieldfn(1, 4) a vaild command for obtaining data from field 1 in card 4?

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: User Selected Images 2
« Reply #8 on: July 21, 2011, 05:47:27 AM »
I'll try this out, and what about obtaining that data from another card? is the fieldfn(1, 4) a vaild command for obtaining data from field 1 in card 4?

Use the following:-
Code: [Select]
Put FieldCardFN(4,1) into x
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #9 on: July 21, 2011, 08:50:42 AM »
Put FieldCardFN(4,1) into x

In this command I understand x is for index, I don't see where I can obtain the value for index...

I may have questioned the request wrong.

On card 3 field 1 I'd like to place into field 1 of card 4

Shouldn't the command be something like

Put Field 1 into FieldCardFn(4, 1) ???? that command doesnt work so I assume Im doing something wrong here : /

Also once it places the data into field 1 of card 4 and I quit it should save the text in that field for reuse correct?
« Last Edit: July 21, 2011, 09:11:50 AM by androbourne »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: User Selected Images 2
« Reply #10 on: July 21, 2011, 10:27:03 AM »
Put FieldCardFN(4,1) into x

In this command I understand x is for index, I don't see where I can obtain the value for index...

I may have questioned the request wrong.

On card 3 field 1 I'd like to place into field 1 of card 4

Shouldn't the command be something like

Put Field 1 into FieldCardFn(4, 1) ???? that command doesnt work so I assume Im doing something wrong here : /

Also once it places the data into field 1 of card 4 and I quit it should save the text in that field for reuse correct?

In the above x is just a variable to hold the data. We cold have used almost any name for it.

So if you are on card 3 and want to take the text from field 1 on card 3 and place it in field 1 on card 4 then the following should work:-

Code: [Select]
@ assumes on Card 3
Local data

Put field 1 into data

FieldCardSet(4,1,data)



This is a description of the function FieldCardFN:-

Returns the text from a field  residing on a card currently out of focus. At the current time it can only fetch all of the text.

     FieldCardFN(cardnum,field index)

     Put FieldCardFN(21,7) into x




This is a description of the command FieldCardSet:-

Sets the text of a field that resides on a card currently out of focus.  At the current time it completely replaces the text already in the field.

      FieldCardSet cardid,index,value



 


I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #11 on: July 24, 2011, 06:04:12 AM »
Ok thank you I'll check and out and get back to you!

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #12 on: July 28, 2011, 12:50:36 AM »
Ok here is the update.

On the home card (card 2) I have a ratio button that links to an import page where I have the follow commands on 2 different buttons.

Browse Button Contains:

Quote
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens

FileAsk(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Put line 9 of fdetails into field 1

and Import Button Contains:

Quote
@ assumes on Card 3
Local data

Put field 1 into data

FieldCardSet(4,1,data)

This puts the browsed location into field 1 of hidden card (card 4)

This works perfectly.

What I need now is the following:

On card 2 (home card) I'd like the user to be able to select the canvas and it open a .exe location.

For the canvas I have this command.

Quote
Local fname,fhandle,fdetails,ftypes, fpaths,fnames,fextens

  @ set the filename of the program to launch
  Put 'FNAME' into fname

  @ Get the file handle
  FolderItemGetAbs(fname,fhandle,fdetails,ftypes, fpaths,fnames,fextens)

  @ Launch the application in the foreground
  FolderItemLaunch fhandle,1

In this section:

Quote
Put 'FNAME' into fname
I would like it to get data from field 1 of card 4 and be placed into this line.

Is that possible?
« Last Edit: July 28, 2011, 03:11:49 AM by androbourne »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: User Selected Images 2
« Reply #13 on: July 28, 2011, 06:25:47 PM »

In this section:

Quote
Put 'FNAME' into fname
I would like it to get data from field 1 of card 4 and be placed into this line.

Is that possible?

Yes, with the FieldCardFN function:-

Code: [Select]
Put FieldCardFN(4,1) into fname

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

androbourne

  • Newbie
  • *
  • Posts: 13
Re: User Selected Images 2
« Reply #14 on: August 08, 2011, 08:51:04 PM »
Everything seems to be working perfectly, thank you for all your help!