Creating a installer

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Creating a installer

Post by bogs » Sun Mar 17, 2019 11:06 am

mikey186 wrote:
Sun Mar 17, 2019 6:29 am
So now, how do I make the code ONLY work on one card when a user clicks on "next" as, again, the button is tied to all other cards
Your cards are either named or numbered, so you can use either 'if/then' or 'case/switch' to run code specific to any card in the stack. For example -

Code: Select all

if the number of this card is "1" then do card 1 stuff
if the number of this card is "2" then do card 2 stuff
if the number of this card is "3" then do card 3 stuff
// or case switch....
case thisCard 
case 1 
	do card stuff
	break
case 2
	do card stuff
	break
////////

Image

mikey186
Posts: 14
Joined: Wed Feb 27, 2019 9:18 am

Re: Creating a installer

Post by mikey186 » Sun Mar 17, 2019 5:55 pm

bogs wrote:
Sun Mar 17, 2019 11:06 am
mikey186 wrote:
Sun Mar 17, 2019 6:29 am
So now, how do I make the code ONLY work on one card when a user clicks on "next" as, again, the button is tied to all other cards
Your cards are either named or numbered, so you can use either 'if/then' or 'case/switch' to run code specific to any card in the stack.
And so the numbers represents the stack numbers? If so, is it possible to change into the stack name so that it'll still run the code?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Creating a installer

Post by bogs » Sun Mar 17, 2019 9:17 pm

mikey186 wrote:
Sun Mar 17, 2019 5:55 pm
And so the numbers represents the stack numbers? If so, is it possible to change into the stack name so that it'll still run the code?
I'm assuming your installer is one 'stack', and you have (approximately) 6 cards in that stack, one for each step. Every card can have a "name" like "Welcome" , "License" etc, but whether you named them or not, they will all have a number, card 1 to card 6 (for this example).

To make all the code in one button that is on every card (like you grouped the buttons I'm guessing), you can refer to the cards either by their name or, if you didn't name them, by the number of the card.

So, 2 posts up, you put the code for a button, and asked how to make it work on one card, lets say your code applies to the 3rd card of your stack, then this would be an if / then routine for doing what your asking...

Code: Select all

on mouseUp
	if the number of this card is "1" then 
		// do your card 1 code here... 
	else if the number of this card is "2" then
	  	// do your card 2 stuff here...
	else if the number of this card is "3" then 
		put "[GUMROAD PRODUCT CODE]" into tProductCode
		put field "SerialKeyField" into tMessage
		get libURLFormData("product_permalink", tProductCode,"license_key", tMessage)
		post it to url "[BUNGIE DID THIS URL LINK]"

		if URLresponse contains "true" then
			go next card
		else
			answer "INVALID!"
		end if
	else if the number of this card is "4" then
	      // your card 4 code here...
	// continue on for however many cards you have...
	end if
end mouseUp
...and this would be the case/switch equivalent...

Code: Select all

on mouseUp
put the number of this card into tmpNum

switch tmpNum
	case "1" 
		// do your card 1 code here... 
	break
	case "2"
		// do your card 2 stuff here...
	break
	case "3"  
		put "[GUMROAD PRODUCT CODE]" into tProductCode
		put field "SerialKeyField" into tMessage
		get libURLFormData("product_permalink", tProductCode,"license_key", tMessage)
		post it to url "[BUNGIE DID THIS URL LINK]"

		if URLresponse contains "true" then
			go next card
		else
			answer "INVALID!"
		end if
	case "4" 
	// your card 4 code here...
	break
	// continue on for however many cards you have...
end switch   
end mouseUp
end switch
Hopefully that makes it clearer for you :)
Image

mikey186
Posts: 14
Joined: Wed Feb 27, 2019 9:18 am

Re: Creating a installer

Post by mikey186 » Mon Mar 18, 2019 2:38 am

WORKS! Thank you! Now the next screen, I want to open the file and search for the text INSIDE the file and see if it contains the particular string. If it does, it moves on with the installation. IF not, it should give a beep. I tried experimenting again with the LiveCode guide and wiki and got a error that says "button "bOBJopen": compilation error at line 7 (if: missing 'then') near "OBJFilePath", char 10" Note that OBJFilePath i believe is the variable.

here's the code:

Code: Select all

on mouseUp
   answer file "Open source OBJ File" with type "OBJ File|obj|OBJ"
   if it <> "" then
      put it into OBJFilePath
      open file OBJFilePath for read
      if file OBJFilePath contains "test" then
         beep 
   else
      beep
   end if
end mouseUp

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Creating a installer

Post by bogs » Mon Mar 18, 2019 5:03 am

I just realized I forgot the 'break' after the end if in the example case/switch above, it *should* have been...

Code: Select all

on mouseUp
put the number of this card into tmpNum

switch tmpNum
	case "1" 
		// do your card 1 code here... 
	break
	case "2"
		// do your card 2 stuff here...
	break
	case "3"  
		put "[GUMROAD PRODUCT CODE]" into tProductCode
		put field "SerialKeyField" into tMessage
		get libURLFormData("product_permalink", tProductCode,"license_key", tMessage)
		post it to url "[BUNGIE DID THIS URL LINK]"

		if URLresponse contains "true" then
			go next card
		else
			answer "INVALID!"
		end if
	break // forgot this break!
	case "4" 
	// your card 4 code here...
	break
	// continue on for however many cards you have...
end switch   
end mouseUp
end switch
As to the code your asking about, it says it is missing a 'then' statement, I see it is missing at least one 'end if', but no 'then' appears to be missing. Hmmm.

Weirder to me though, is that something here is beginning to smell rotten. Your talking about creating an installer. Why on earth would an installer be asking the end user to pick a file? If you are installing something, then any file(s) used should be in the location of the installer, or downloaded to a location you will know during the process of the install.

I can't think of any reason the user should be required to open any file through a file dialog during an installation of a program.
Image

mikey186
Posts: 14
Joined: Wed Feb 27, 2019 9:18 am

Re: Creating a installer

Post by mikey186 » Mon Mar 18, 2019 5:14 am

bogs wrote:
Mon Mar 18, 2019 5:03 am
Weirder to me though, is that something here is beginning to smell rotten. Your talking about creating an installer. Why on earth would an installer be asking the end user to pick a file? If you are installing something, then any file(s) used should be in the location of the installer, or downloaded to a location you will know during the process of the install.

I can't think of any reason the user should be required to open any file through a file dialog during an installation of a program.
Put it this way, especially, say.....if it's a expansion for another program (or sometimes) a game, then a user would require to search for a specific file somewhere in the bin or anywhere else for a matching version or a matching text, and if passed, then it will keep going. It's kinda hard to explain, but hope this helps. Some installers (especially InstallBuilder) has that compare file feature as well.

As for the code, I did add 'end if' to the middle 'IF' statement, and it's still giving me the error. I'm sure I put then in the correct position?

Code: Select all

open file OBJFilePath for read 
if file OBJFilePath contains "test" then 
beep 
else
answer "NOPE"
end if

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Creating a installer

Post by bogs » Mon Mar 18, 2019 6:10 am

mikey186 wrote:
Mon Mar 18, 2019 5:14 am
Put it this way, especially, say.....if it's a expansion for another program (or sometimes) a game, then a user would require to search for a specific file somewhere in the bin or anywhere else for a matching version or a matching text, and if passed, then it will keep going. It's kinda hard to explain, but hope this helps. Some installers (especially InstallBuilder) has that compare file feature as well.
I understand comparing files as part of an updater, which would apply to expansion packs as well. The part I don't see an explanation for is requiring the end user to navigate through a file dialog to a specific file that is part of an installed program.

Anyone publishing programs (and updates to programs they have published) should well know the places to look for said program, and the directory structure it would use, thereby eliminating the need for an end user to find a file for them.

In Windows, you'd be looking for the install location in the registry. In 'nix, there are only a few places you'd actually install something, and they would be trivial to search. Mac, as Klaus pointed out earlier, is even more limited in where you might have a program located.

If your applying an update/expansion to a product you haven't created, or don't know well enough to know the above, that sounds a little dubious to me.
mikey186 wrote:
Mon Mar 18, 2019 5:14 am
As for the code, I did add 'end if' to the middle 'IF' statement, and it's still giving me the error. I'm sure I put then in the correct position?
Adding the missing 'end if' doesn't fix the problem of the missing "then" complaint, I was just noting it was missing.

As far as the statement goes, to me it looks like

Code: Select all

if file OBJFilePath contains "test"
is what the debugger would actually be complaining about. It is telling you 'then' is missing when it obviously is not, so the statement before then is suspect.
Image

mikey186
Posts: 14
Joined: Wed Feb 27, 2019 9:18 am

Re: Creating a installer

Post by mikey186 » Mon Mar 18, 2019 8:25 am

Thanks for the tip! So that works, and so last but not least...installing the files. Unfortunately, I don't think there's a way to actually store the amount of files (over 10+ of it) in a LiveCode standalone application. Instead it relies on downloading from a URL. So I added a button to download the file, but I want to pop up a answer file window asking where should the file (a ZIP file in this case) to be saved to. Once decided, and clicks OK, then the file will begin downloading with a progress bar and brings back an answer window showing "Download completed".

There is a LiveCode guide on "How to show the progress of a download". It does almost exactly what I want to do, except it's missing a way to prompt a user where to save it, and let it download to the user's desired directory, and it'll pop up a message saying "Download completed".

here's the code so far (mostly from the guide with a tweak)

Code: Select all

on mouseUp
   	-- put the address of the file we want to download into a variable
	put "[URL FILE TO DOWNLOAD]" into tDownloadLink  -- 2.3 MB
	
	-- set up a message to show the status of the download as it progresses
	libURLSetStatusCallback "showProgress", the long name of me
	
	-- make sure the progress bar is hidden, as this property is used to initialize it
	show scrollbar "ProgressBar"
	
	-- start the download process, telling LiveCode to call the "downloadComplete" handler when finished
	answer ("You answered "  & it)
end mouseUp

command showProgress pURL, pStatus
	-- this is the status callback message which gets called regularly during the download
	-- pStatus will show some initialization messages, then
	-- loading,bytesReceived,bytesTotal
	
	-- using a graphical progress bar instead
	-- the first time this is called, find the total number of bytes that are to be downloaded
	-- use this info to set the span of the progress bar
	
	-- wait until the download info is being received
	if the number of items in pStatus = 3 then
		if the visible of scrollbar "ProgressBar" = false then
			put the last item of pStatus into tTotalBytes
			set the startValue of scrollbar "ProgressBar" to 0
			set the endValue of scrollbar "ProgressBar" to tTotalBytes
			show scrollbar "ProgressBar"
		end if
		
		set the thumbPosition of scrollbar "ProgressBar" to item 2 of pStatus
	end if
end showProgress

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Creating a installer

Post by MaxV » Mon Apr 22, 2019 10:30 pm

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”