Recent Posts

Pages: 1 ... 6 7 [8] 9 10
71
Getting Started / Re: Standalone Location & Movie Help
« Last post by Malkom on October 22, 2020, 06:20:04 PM »
I tried compiling my program. It goes through alright. Now I'm having issues finding where it puts the file.
When HN builds an app(executable) or stack, it places the built app/stack in the project's folder.
For instance if your project is called My Movie Player, then the built app/stack should be in the My Movie Player folder.

Note, when releasing your app or stack, the original project file is not required but remember to make a copy of it somewhere.
Only the app/stack plus any dependencies such as datafiles, images, vidoe setc are required.


As for movies, when I run my program and try to start the movie, it doesn't start. What am I doing wrong?
There is a bug in a movie player's control panel that prevents some movies such as MP4 from playing.

See number 5 in this post:-
http://www.tigabyte.com/smf/index.php?topic=326.0

However, it is possible to control a movie, play or pause it by using the relevant movie command.
 
In the scripts below, the movie player control on the card has ID 1.

The movie to be played was dragged and dropped intoto the project's movie library via the Movie Library menu option  under the menu Windows.
 

Use one button  to play the movie with the command MoviePlayNormalSpeed:-
Code: [Select]
MoviePlayNormalSpeed(1)


Use another button  to pause the movie with the command MoviePause:-
Code: [Select]
MoviePause(1)


As a movie player's controller is bugged, it can be hidden using the command MovieSetController.
Its usual to place this or similar commands in the card's open event:-
Code: [Select]
MovieSetController(1,0)



Attached below is a simple movie player that has a small movie in the project folder.

http://www.tigabyte.com/bits/Movie_Player.zip



More MP4 movies can be found here:-
https://file-examples.com/index.php/sample-video-files/sample-mp4-files/

72
Getting Started / Standalone Location & Movie Help
« Last post by Dystopia on October 22, 2020, 06:57:06 AM »
I tried compiling my program. It goes through alright. Now I'm having issues finding where it puts the file.

As for movies, when I run my program and try to start the movie, it doesn't start. What am I doing wrong?
73
Files / Re: Save & Load Data from file
« Last post by Malkom on October 03, 2020, 10:38:39 AM »
Hello, I want to ask a question.
Does HyperNext support save/load data from the XML/JSON/Plain text file? Like, save a value of a variable(s), load value of a variable from a file, etc.
Because I want to save my program data and settings there.

HN doesn't have support for XML/JSON but can easily write files to text or binary files.

By default when an HN program/stack closes it automatically saves all of its local and global variables, including content of fields etc.
Then the next time the HN program/stack is run those variables etc are automatically reloaded.
This makes it much easier for beginner programmers.
74
Getting Started / Re: Function system
« Last post by Malkom on October 03, 2020, 08:11:02 AM »
Yes it is possible to create your own user-defined functions but they are clumsy to call compared to a HN defined function.

In most programming languages the user-defined and language defined function usages are very similar.

Here is how to do it in HN:-

(1) Create a procedure for instance MyAddFN with any required parameters
     You can create your procedure in a the MainCode section where it will be global.
     Procedures can also be created in cards, buttons etc, where they will be local.

Code: [Select]
@ MyAddFN(n1,n2) - simply adds 2 numbers together
Global myResultAddFN

Put n1 into myResultAddFN

Add n2 to myResultAddFN

(2) In your button place the call to your procedure MyAddFN

Code: [Select]
Global myResultAddFN

Call MyAddFN(2,3)

Put myResultAddFN into field 1
@ 5 should appear in field 1

I try to keep the global variable names similar to the user-defined functions(procedure) because its easier to keep track of them in large programs. However, you can name your global variables anything, as long as they don't conflict with a HN keyword or other variable.


Creating a Procedure

Procedures are created in the Script Editor using the New, Edit, Del buttons in the lower left of the editor window.
Procedures are listed in the listbox directly above these 3 buttons.
Just make sure that you have selected the correct control, card or MainCode before creating your procedure.

 

This post might help in creating procedures, also know as handlers:-
http://www.tigabyte.com/smf/index.php?topic=118.msg399#msg399
75
Getting Started / Function system
« Last post by LinesOfCodes on October 02, 2020, 11:33:37 AM »
Hello, I want to know How can I create a 'function' (user-defined procedure) and create a 'plug-in' (plug-in procedure)?
76
Files / Save & Load Data from file
« Last post by LinesOfCodes on October 02, 2020, 10:58:59 AM »
Hello, I want to ask a question.
Does HyperNext support save/load data from the XML/JSON/Plain text file? Like, save a value of a variable(s), load value of a variable from a file, etc.
Because I want to save my program data and settings there.
77
Getting Started / Re: How to show an Image
« Last post by Malkom on October 01, 2020, 06:42:51 PM »
Hello, I want to know how to show an Image in my program.
But I don't know I should use Sprite or Canvas and I didn't know what script I have to use?
I already looked in Script reference but I'm still don't know what script I have to use to show an Image.
Please help me!
Personally I would use the Canvas over the Sprite because in most situations the canvas is more flexible and has more events.
Sprites worked best in HN 3.x but in HN 4.x there were some issues, especially with sprite movement on OS X.
By the way, HN5, will have fully working canvases before its sprite engine is finished.


CanvasImages

To load an image into a canvas from the project folder just use the CanvasLoad(canvas,filename,scaleflag) as below.

Setting the scaleflag to 1 will cause the canvas to fit the whole image into the canvas.  Otherwise it will be displayed at pixel to pixel scale so larger images will be hidden off canvas.

Code: [Select]
Local fname

Put 'Chrysanthemum.jpg' into fname
CanvasLoad(1,fname,1)

Also there is the CanvasLoadAbs(canvas,filename,scaleflag) command that expects a full file path to the image.

There is also the CanvasLoadAsk(canvas,filename,scaleflag) command that presents a dialog box so the user can locate the image file.


For more details see the Help section Files  - Graphics.




Canvas Drop Image

Its possible to drop an image onto a canvas but the canvas must have its image drop event enabled.
It can be enabled/disabled using the CanvasSetDrop(canvas,modeflag)
Modeflag 0 disables, while 1 enables.
By default canvas image drop is disabled.

Usually the CanvasSetDrop command is placed in the Card's opening event but could equally be placed in a button's script etc.

Code: [Select]
CanvasSetDrop(1,1)



Image Banks
HyperNext has a set of image banks allowing images to be stored, retrieved and loaded/saved to and from files. The images can also be used in sprite animations and copied to/from canvases. Each bank holds one image and the number of banks allowed is dicated by the memory available.

Images within the banks can be rotated and flipped. These commands are particularly useful for preparing output for the printer and for canvases.

Files used by image banks can be either local or absolute.  Usually it is best to use local files.

There are also two sets of commands for saving/loading images. One is for cross-platform use and the other for standard image formats such as jpegs, picts etc.
 
78
Getting Started / How to show an Image
« Last post by LinesOfCodes on October 01, 2020, 12:34:18 PM »
Hello, I want to know how to show an Image in my program.
But I don't know I should use Sprite or Canvas and I didn't know what script I have to use?
I already looked in Script reference but I'm still don't know what script I have to use to show an Image.
Please help me!
79
Development Progress / September 2020
« Last post by Malkom on September 30, 2020, 02:46:54 PM »
Here is a brief progress report on HN5 development for the month of September 2020.

The aim is to get the Chart demo project running inside HN5 Creator IDE.

The development is being carried out on a Windows 7 x64 machine with regular testing of HN5 on Linux(Lubuntu).

The development language is Free Pascal which should ensure HN5 will be able to run on a variety of Operating Systems, both newer and older versions. The main targets being Windows, OS X and Linux.


RUNTIME ENGINE

Most of the keywords and functions needed by the Chart project are now implemented.
Those remaining are mostly concerned with the GUI such as canvas, color picker etc.


HELP SYSTEM

This now loads and correctly displays a test HAC help file.
It uses self-contained Free Pascal code to ensure that it will be both cross-platform and not need external helper apps.

 

 

80
Getting Started / Re: How can I use Listbox?
« Last post by Malkom on September 27, 2020, 10:55:24 AM »
In these examples the listbox has the ID 1, and has 3 columns and 10 rows.

Before starting with a listbox its usually best to reset it because HN can remember the final structure from when the project was previously run in Creator.

Code: [Select]
ListboxDeleteAll(1)

A listbox can also be set up in the card's opening event so making it appear instantly.
When editing a card's script or its controls:
   The opening event is the first item in the leftmost column of the listbox entitled "Card".
   Any items listed after the card's opening event are all for for controls such as buttons fields etc,

Set a listbox to have 3 columns:
Code: [Select]
ListboxSetColumns(1,3)

Alternatively you could build a 3 column listbox having 10 rows using the ListboxBuild command:
Code: [Select]
ListboxBuild(1,10,3)




  • How can I set heading text?

Code: [Select]
ListboxSetHeading(1,1,'Title 1')
ListboxSetHeading(1,2,'Title 2')
ListboxSetHeading(1,3,'Title 3')



  • How can I Insert a value into the second column?

So to set the listbox cell column 2 and row 9, to value 'hello' use:
Code: [Select]
ListboxSetCellValue(1,9,2,'hello')



  • Can I run a command If the user double clicks on a row?

Your script can check for various listbox events using the function ListboxEventFN(id):

For instance, this code checks if a cell was clicked. When a cell is clicked, it finds the cell coordinates and then calls a user-defined procedure to do something.
Code: [Select]
Local event,row,col

Put ListboxEventFN into event
If event=2 then
    Put ListboxRowClickedFN(1) into row
    Put ListboxColumnClickedFN(1) into col   
    Put ListboxCellValueFN(1,row,col) into txt
    Call DoSomething(row,col,txt)
endif

Note, a listbox's script is only called in response to an event such as when the user clicks a cell, drops a file on it, etc.

Here are the event numbers and descriptions:
         1 - Cell action either editable cell or checkbox clicked.
         2 - Cell clicked.
         3 - Drag reorded rows.
         4 - Drag row.
         5 - Drop drag.
         6 - Drop file.
         7 - Double click.
         8 - Header pressed
         9 - Cell key down.
         10 - Cell got focus.
         11 - Cell text change.
         12 - Cell lost focus.
         13 - Sort column.




  • How to add more columns

The ListboxSetColumns(id,ncols) changes the number of columns, for instance to 5, in this code:
Code: [Select]
ListboxSetColumns(1,5)

Note, if you want to add a row use the ListboxAddRow(id,value) command.
It adds value into the first cell of the new row.
Code: [Select]
ListboxAddRow(1,'cell value')
Pages: 1 ... 6 7 [8] 9 10