wip: save what I have before doing major simplifications

data Dir :: *2 where
  Hor :: name ~> Dir -- these are nodes
  Ver :: name ~> Dir -- should be tree of names!

data Tree :: Dir ~> *1 where
  Pri :: Tag ~> Tree (Hor Tag)
  Unit :: Tree (Ver name)
  --Ni :: Tree (Hor name)
  --Fork :: Tree (d name) ~> Tree (Hor name) ~> Tree (Hor name)
  -- pasting
  Empty :: Tree (Hor (Wrap name))
  Paste :: Tree (Hor name) ~> Tree (Hor (Wrap name)) ~> Tree (Hor (Wrap name))
 --deriving syntax (tr) List(Ni, Fork) Unit(Unit) Item(Pri)
 deriving syntax (tr) List(Empty, Paste) Unit(Unit) Item(Pri)

data Tree' :: Tree d ~> * where
  Labeled :: Label tag -> Tree' (tag)tr
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr
 deriving syntax (ar) List(Done, Fork) Unit(In) Item(Labeled)

kind Wrap a = W a

data Stack :: Tree (d n) ~> Tree (e n) ~> * where
  Cell :: Stack ()tr ()tr
  NicheDone :: Stack ()tr []tr
  --Niche :: Stack tr out -> Stack tr [out]tr
  Also :: Tree' at -> Stack tr out' -> Stack tr out -> Stack tr [out'; out]tr
 deriving syntax(z) Record(NicheDone, Also)

--t1 = {(`hey)ar=Cell}z

data Dir :: *2 where
  Hor :: name ~> Dir -- these are nodes
  Ver :: name ~> Dir -- should be tree of names!

data Tree :: Dir ~> *1 where
  Pri :: Tag ~> Tree (Hor Tag)
  Unit :: Tree (Ver name)
  Ni :: Tree (Hor name)
  Fork :: Tree (d Tag) ~> Tree (Hor name) ~> Tree (Hor name)
 deriving syntax (tr) List(Ni, Fork) Unit(Unit) Item(Pri)

data Tree' :: Tree d ~> * where
  Labeled :: Label tag -> Tree' (tag)tr
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr
 deriving syntax (ar) List(Done, Fork) Unit(In) Item(Labeled)

kind Wrap a = W a

data Stack :: Tree (d Tag) ~> Tree (e Tag) ~> * where
  Cell :: Stack ()tr ()tr
  NicheDone :: Stack ()tr []tr
  Niche :: Stack tr out -> Stack tr [out]tr
  Also :: Tree' at -> Stack tr out' -> Stack tr out -> Stack tr [out'; out]tr
 deriving syntax(z) Record(NicheDone, Also)

t1 = {(`hey)ar=Cell}z


make it pass

make it pass

data Foo :: * where
  Nu :: Foo
  Co :: Foo -> Int -> Foo
 deriving syntax (f) LeftList(Nu, Co)

data Bar = Bnu | Bar Bar Int deriving LeftList(b)

data Baz  :: * where
  Nub :: Baz
  Cob :: Baz -> Int -> Baz
 deriving LeftList(z)

len :: Foo -> Int
len []f = 0
len [rest; _]f = 1 + len rest

t0 = len [[]f; 1, 2, 3]f

t1 = len [lazy [1, 2]f; 3, 4]f

[t2; 4, 5]b = [1,2,3,4,5]b

[[1,2,3]z; 4]z = [[1]z; 2, 3, 4]z

[t3; t4]z = [[1]z; 2]z

t5 [[1,2,3]z; 4]z = 42

##test "these do not match up"
 t6 = t5 [[1]z; 2, 3]z

data Foo :: * where
  Nu :: Foo
  Co :: Foo -> Int -> Foo
 deriving syntax (f) LeftList(Nu, Co)

data Bar = Bnu | Bar Bar Int deriving LeftList(b)

data Baz  :: * where
  Nub :: Baz
  Cob :: Baz -> Int -> Baz
 deriving LeftList(z)

len :: Foo -> Int
len []f = 0
len [rest; _]f = 1 + len rest

t0 = len [[]f; 1, 2, 3]f

t1 = len [lazy [1, 2]f; 3, 4]f

[t2; 4, 5]b = [1,2,3,4,5]b

[[1,2,3]z; 4]z = [[1]z; 2, 3, 4]z

[t3; t4]z = [[1]z; 2]z

##test "these do not match up"
 [[1,2,3]z; 4]z = [[1]z; 2, 3]z


Build a XMemberDefinition List, based on a XDbResult

// XDbResultHelpers.prg
// Created by    : fabri
// Creation Date : 7/3/2020 8:45:05 PM
// Created for   :
// WorkStation   : FABPORTABLE

USING System
USING System.Collections.Generic
USING System.Text
USING LanguageService.CodeAnalysis.XSharp
USING System.Linq

BEGIN NAMESPACE XSharpModel

	/// <summary>
	/// The XDbResultHelpers class.
	/// </summary>
	CLASS XDbResultHelpers

		///
		STATIC METHOD BuildTypesInFile( origin AS XFile, found AS IList<XDbResult>) AS IList<XTypeDefinition>
			VAR result := List<XTypeDefinition>{}
			LOCAL idProject := -1 AS INT64
			//
			TRY
					FOREACH VAR element IN found
						// Skip types found in another project
						IF idProject != -1 .AND. element:IdProject != idProject
							LOOP
						ENDIF
						idProject   := element:IdProject
						VAR name    := element:TypeName
						VAR idType  := element:IdType
						VAR fileName := element:FileName
						IF fileName == NULL
							fileName := origin:FullPath
						ENDIF
						VAR file       := XFile{ fileName, origin:Project}
						file:Virtual   := TRUE
						file:Id        := element:IdFile
						VAR range    := TextRange{element:StartLine, element:StartColumn, element:EndLine, element:EndColumn}
						VAR interval := TextInterval{element:Start, element:Stop}
						VAR xtype := XTypeDefinition{name, element:Kind,element:Attributes, range, interval, file}
						xtype:Namespace := element:Namespace
						xtype:Id  := element:IdType
						result:Add(xtype)
				NEXT
			CATCH e AS Exception
				XSolution.WriteOutputMessage("GetTypesInFile: "+ e:Message)
			END TRY
		RETURN result

		STATIC METHOD BuildFullTypesInFile( origin AS XFile, found AS IList<XDbResult>) AS IList<XTypeDefinition>
			VAR result := List<XTypeDefinition>{}
			LOCAL idProject := -1 AS INT64
			//
			TRY
					FOREACH VAR element IN found
						// Skip types found in another project
						IF idProject != -1 .AND. element:IdProject != idProject
							LOOP
						ENDIF
						idProject   := element:IdProject
						//
						VAR name    := element:TypeName
						VAR idType  := element:IdType
						VAR fileName := element:FileName
						IF fileName == NULL
							fileName := origin:FullPath
						ENDIF
						VAR file       := XFile{ fileName, origin:Project}
						file:Virtual   := TRUE
						// If we don't set Interactive, the EntityList will be emptied after the Parse() operation
						file:Interactive := TRUE
						file:Id        := element:IdFile
						VAR members := XDatabase.GetMembers(idType)
						// now create a temporary source for the parser
						VAR source     := GetTypeSource(element, members)
						VAR walker := SourceWalker{file}
						walker:Parse(source, FALSE)
						IF walker:EntityList:Count > 0
							VAR xElement      := walker:EntityList:First()
							IF xElement IS XTypeDefinition VAR xtype
								xtype:Range       := TextRange{element:StartLine, element:StartColumn, element:EndLine, element:EndColumn}
								xtype:Interval    := TextInterval{element:Start, element:Stop}
								xtype:XmlComments := element:XmlComments
								xtype:ClassType   := (XSharpDialect) element:ClassType
								xtype:Namespace := element:Namespace
								xtype:Id  := element:IdType
								VAR xmembers := xtype:XMembers
								IF xmembers:Count == members:Count
									LOCAL i AS INT
									FOR i := 0 TO members:Count-1
										VAR xmember := (XMemberDefinition) xmembers[i]
										VAR melement := members[i]
										xmember:Range       := TextRange{melement:StartLine, melement:StartColumn, melement:EndLine, melement:EndColumn}
										xmember:Interval    := TextInterval{melement:Start, melement:Stop}
										IF xmember:Name == melement:MemberName
											xmember:XmlComments := melement:XmlComments
										ENDIF
									NEXT
								ENDIF
								result:Add(xtype)
							ENDIF
						ENDIF
				NEXT
			CATCH e AS Exception
				XSolution.WriteOutputMessage("GetTypesInFile: "+ e:Message)
			END TRY
			//
			RETURN result

		// Comes from XProject, would be worth to merge source ???
		PRIVATE STATIC METHOD GetTypeSource(element AS XDbResult, members AS IList<XDbResult>) AS STRING
			VAR sb := StringBuilder{}
			sb:AppendLine(element:SourceCode)
			FOREACH VAR xmember IN members
				sb:AppendLine(xmember:SourceCode)
				SWITCH xmember:Kind
					CASE Kind.Property
						VAR source := xmember:SourceCode:ToLower():Replace('\t',' ')
						IF source:Contains(" get") .OR. ;
								source:Contains(" set") .OR. ;
								source:Contains(" auto")
								// single line
							NOP
						ELSE
							sb:AppendLine("END PROPERTY")
						ENDIF
					CASE Kind.Event
						VAR source := xmember:SourceCode:ToLower():Replace('\t',' ')
						IF source:Contains(" add") .OR. ;
								source:Contains(" remove")
								// single line
							NOP
						ELSE
							sb:AppendLine("END EVENT")
						ENDIF
				END SWITCH
			NEXT
			SWITCH element:Kind
				CASE Kind.Class
					IF element:ClassType == (INT) XSharpDialect.XPP
						sb:AppendLine("ENDCLASS")
					ELSEIF element:ClassType == (INT) XSharpDialect.FoxPro
						sb:AppendLine("ENDDEFINE")
					ELSE
						sb:AppendLine("END CLASS")
					ENDIF
				CASE Kind.Structure
					sb:AppendLine("END STRUCTURE")
				CASE Kind.Interface
					sb:AppendLine("END INTERFACE")
			END SWITCH
			RETURN sb:ToString()
		END CLASS
END NAMESPACE // global::XSharpCodeModel.Model

// XDbResultHelpers.prg
// Created by    : fabri
// Creation Date : 7/3/2020 8:45:05 PM
// Created for   :
// WorkStation   : FABPORTABLE

USING System
USING System.Collections.Generic
USING System.Text
USING LanguageService.CodeAnalysis.XSharp
USING System.Linq

BEGIN NAMESPACE XSharpModel

	/// <summary>
	/// The XDbResultHelpers class.
	/// </summary>
	CLASS XDbResultHelpers

		///
		STATIC METHOD BuildTypesInFile( origin AS XFile, found AS IList<XDbResult>) AS IList<XTypeDefinition>
			VAR result := List<XTypeDefinition>{}
			LOCAL idProject := -1 AS INT64
			//
			TRY
					FOREACH VAR element IN found
						// Skip types found in another project
						IF idProject != -1 .AND. element:IdProject != idProject
							LOOP
						ENDIF
						idProject   := element:IdProject
						VAR name    := element:TypeName
						VAR idType  := element:IdType
						VAR fileName := element:FileName
						IF fileName == NULL
							fileName := origin:FullPath
						ENDIF
						VAR file       := XFile{ fileName, origin:Project}
						file:Virtual   := TRUE
						file:Id        := element:IdFile
						VAR range    := TextRange{element:StartLine, element:StartColumn, element:EndLine, element:EndColumn}
						VAR interval := TextInterval{element:Start, element:Stop}
						VAR xtype := XTypeDefinition{name, element:Kind,element:Attributes, range, interval, file}
						xtype:Namespace := element:Namespace
						xtype:Id  := element:IdType
						result:Add(xtype)
				NEXT
			CATCH e AS Exception
				XSolution.WriteOutputMessage("GetTypesInFile: "+ e:Message)
			END TRY
		RETURN result

		STATIC METHOD BuildFullTypesInFile( origin AS XFile, found AS IList<XDbResult>) AS IList<XTypeDefinition>
			VAR result := List<XTypeDefinition>{}
			LOCAL idProject := -1 AS INT64
			//
			TRY
					FOREACH VAR element IN found
						// Skip types found in another project
						IF idProject != -1 .AND. element:IdProject != idProject
							LOOP
						ENDIF
						idProject   := element:IdProject
						//
						VAR name    := element:TypeName
						VAR idType  := element:IdType
						VAR fileName := element:FileName
						IF fileName == NULL
							fileName := origin:FullPath
						ENDIF
						VAR file       := XFile{ fileName, origin:Project}
						file:Virtual   := TRUE
						// If we don't set Interactive, the EntityList will be emptied after the Parse() operation
						file:Interactive := TRUE
						file:Id        := element:IdFile
						VAR members := XDatabase.GetMembers(idType)
						// now create a temporary source for the parser
						VAR source     := GetTypeSource(element, members)
						VAR walker := SourceWalker{file}
						walker:Parse(source, FALSE)
						IF walker:EntityList:Count > 0
							VAR xElement      := walker:EntityList:First()
							IF xElement IS XTypeDefinition VAR xtype
								xtype:Range       := TextRange{element:StartLine, element:StartColumn, element:EndLine, element:EndColumn}
								xtype:Interval    := TextInterval{element:Start, element:Stop}
								xtype:XmlComments := element:XmlComments
								xtype:ClassType   := (XSharpDialect) element:ClassType
								xtype:Namespace := element:Namespace
								xtype:Id  := element:IdType
								VAR xmembers := xtype:XMembers
								IF xmembers:Count == members:Count
									LOCAL i AS INT
									FOR i := 0 TO members:Count-1
										VAR xmember := (XMemberDefinition) xmembers[i]
										VAR melement := members[i]
										xmember:Range       := TextRange{melement:StartLine, melement:StartColumn, melement:EndLine, melement:EndColumn}
										xmember:Interval    := TextInterval{melement:Start, melement:Stop}
										IF xmember:Name == melement:MemberName
											xmember:XmlComments := melement:XmlComments
										ENDIF
									NEXT
								ENDIF
								result:Add(xtype)
							ENDIF
						ENDIF
				NEXT
			CATCH e AS Exception
				XSolution.WriteOutputMessage("GetTypesInFile: "+ e:Message)
			END TRY
			//
		RETURN result

		STATIC METHOD BuildFullFuncsInFile( origin AS XFile, found AS IList<XDbResult>) AS IList<XMemberDefinition>
			VAR result := List<XMemberDefinition>{}
			LOCAL idProject := -1 AS INT64
			//
			TRY
					// now create a temporary source for the parser
					VAR source     := GetTypeSource( NULL, found)
					VAR element := found:First()
					VAR fileName := element:FileName
					IF fileName == NULL
						fileName := "dummy.prg"
					ENDIF
					VAR file       := XFile{ fileName, origin:Project}
					file:Virtual   := TRUE
					// If we don't set Interactive, the EntityList will be emptied after the Parse() operation
					file:Interactive := TRUE
					file:Id        := element:IdFile
					VAR walker := SourceWalker{file}
					walker:Parse(source, FALSE)
					IF walker:EntityList:Count > 0 .AND. ( walker:EntityList:Count == found:Count )
						LOCAL i AS INT
						FOR i := 0 TO found:Count-1
						    VAR entity := walker:EntityList[i]
							IF entity IS XMemberDefinition VAR xMember
								VAR melement := found[i]
								xMember:Range       := TextRange{melement:StartLine, melement:StartColumn, melement:EndLine, melement:EndColumn}
								xMember:Interval    := TextInterval{melement:Start, melement:Stop}
								result:Add( xMember )
							ENDIF
						NEXT
				ENDIF
			CATCH e AS Exception
				XSolution.WriteOutputMessage("BuildFullFuncsInFile: "+ e:Message)
			END TRY
		RETURN result

		// Comes from XProject, would be worth to merge source ???
		PRIVATE STATIC METHOD GetTypeSource(element AS XDbResult, members AS IList<XDbResult>) AS STRING
			VAR sb := StringBuilder{}
			IF element != NULL
				sb:AppendLine(element:SourceCode)
			ENDIF
			FOREACH VAR xmember IN members
				sb:AppendLine(xmember:SourceCode)
				SWITCH xmember:Kind
					CASE Kind.Property
						VAR source := xmember:SourceCode:ToLower():Replace('\t',' ')
						IF source:Contains(" get") .OR. ;
								source:Contains(" set") .OR. ;
								source:Contains(" auto")
								// single line
							NOP
						ELSE
							sb:AppendLine("END PROPERTY")
						ENDIF
					CASE Kind.Event
						VAR source := xmember:SourceCode:ToLower():Replace('\t',' ')
						IF source:Contains(" add") .OR. ;
								source:Contains(" remove")
								// single line
							NOP
						ELSE
							sb:AppendLine("END EVENT")
						ENDIF
				END SWITCH
			NEXT
			IF element != NULL
				SWITCH element:Kind
					CASE Kind.Class
						IF element:ClassType == (INT) XSharpDialect.XPP
							sb:AppendLine("ENDCLASS")
						ELSEIF element:ClassType == (INT) XSharpDialect.FoxPro
							sb:AppendLine("ENDDEFINE")
						ELSE
							sb:AppendLine("END CLASS")
						ENDIF
					CASE Kind.Structure
						sb:AppendLine("END STRUCTURE")
					CASE Kind.Interface
						sb:AppendLine("END INTERFACE")
				END SWITCH
			ENDIF
			RETURN sb:ToString()
		END CLASS
END NAMESPACE // global::XSharpCodeModel.Model


codegen/QtWebEngineWidgets: updated

codegen/QtWebEngineWidgets: updated

Modified:
codegen/QtWebEngineWidgets/QWebEnginePage.prg

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$project=Qt5xHb
$module=QtWebEngineWidgets

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=QObject

$addMethods

$addSignals

$endClass

$destructor

#pragma BEGINDUMP

$includes=5,4,0

#include <QtWidgets/QAction>
#include <QtWidgets/QMenu>

$prototype=explicit QWebEnginePage(QObject *parent = 0)
$constructor=5,4,0|new|QObject *=0

$deleteMethod=5,4,0

$prototype=QWebEngineHistory *history() const
$method=5,4,0|QWebEngineHistory *|history|

$prototype=QWidget *view() const
$method=5,4,0|QWidget *|view|

$prototype=void setView(QWidget *view)
$method=5,4,0|void|setView|QWidget *

$prototype=bool hasSelection() const
$method=5,4,0|bool|hasSelection|

$prototype=QString selectedText() const
$method=5,4,0|QString|selectedText|

$prototype=QAction *action(WebAction action) const
$method=5,4,0|QAction *|action|QWebEnginePage::WebAction

$prototype=virtual void triggerAction(WebAction action, bool checked = false)
$virtualMethod=5,4,0|void|triggerAction|QWebEnginePage::WebAction,bool=false

$prototype=virtual bool event(QEvent*)
$virtualMethod=5,4,0|bool|event|QEvent *

$prototype=void findText(const QString &subString, FindFlags options = 0, const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())
%% TODO: implementar
%% $method=5,4,0|void|findText|const QString &,QWebEnginePage::FindFlags=0,const QWebEngineCallback<bool> &=QWebEngineCallback<bool>()

$prototype=QMenu *createStandardContextMenu()
$method=5,4,0|QMenu *|createStandardContextMenu|

$prototype=void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy)
$method=5,4,0|void|setFeaturePermission|const QUrl &,QWebEnginePage::Feature,QWebEnginePage::PermissionPolicy

$prototype=void load(const QUrl &url)
$method=5,4,0|void|load|const QUrl &

$prototype=void setHtml(const QString &html, const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setHtml|const QString &,const QUrl &=QUrl()

$prototype=void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setContent|const QByteArray &,const QString &=QString(),const QUrl &=QUrl()

$prototype=void toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toHtml|const QWebEngineCallback<const QString &> &

$prototype=void toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toPlainText|const QWebEngineCallback<const QString &> &

$prototype=QString title() const
$method=5,4,0|QString|title|

$prototype=QUrl url() const
$method=5,4,0|QUrl|url|

$prototype=void setUrl(const QUrl &url)
$method=5,4,0|void|setUrl|const QUrl &

$prototype=QUrl requestedUrl() const
$method=5,4,0|QUrl|requestedUrl|

$prototype=QUrl iconUrl() const
$method=5,4,0|QUrl|iconUrl|

$prototype=qreal zoomFactor() const
$method=5,4,0|qreal|zoomFactor|

$prototype=void setZoomFactor(qreal factor)
$method=5,4,0|void|setZoomFactor|qreal

$prototype=void runJavaScript(const QString& scriptSource)
$internalMethod=5,4,0|void|runJavaScript,runJavaScript1|const QString &

$prototype=void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
%% TODO: implementar
%% $internalMethod=5,4,0|void|runJavaScript,runJavaScript2|const QString &,const QWebEngineCallback<const QVariant &> &

/*
[1]void runJavaScript(const QString& scriptSource)
[2]void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
*/

HB_FUNC( QWEBENGINEPAGE_RUNJAVASCRIPT )
{
  if( ISNUMPAR(1) && ISCHAR(1) )
  {
    QWebEnginePage_runJavaScript1();
  }
%%  else if( ISNUMPAR(2) && ISCHAR(1) && ISARRAY(2) )
%%  {
%%    QWebEnginePage_runJavaScript2();
%%  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}
$addMethod=runJavaScript

$prototype=QWebEngineSettings *settings() const
$method=5,4,0|QWebEngineSettings *|settings|

$beginSignals
$signal=5,4,0|loadStarted()
$signal=5,4,0|loadProgress(int)
$signal=5,4,0|loadFinished(bool)
$signal=5,4,0|linkHovered(QString)
$signal=5,4,0|selectionChanged()
$signal=5,4,0|geometryChangeRequested(QRect)
$signal=5,4,0|windowCloseRequested()
$signal=5,4,0|featurePermissionRequested(QUrl,QWebEnginePage::Feature)
$signal=5,4,0|featurePermissionRequestCanceled(QUrl,QWebEnginePage::Feature)
$signal=5,4,0|authenticationRequired(QUrl,QAuthenticator*)
$signal=5,4,0|proxyAuthenticationRequired(QUrl,QAuthenticator*,QString)
$signal=5,4,0|titleChanged(QString)
$signal=5,4,0|urlChanged(QUrl)
$signal=5,4,0|iconUrlChanged(QUrl)
$endSignals

#pragma ENDDUMP

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$project=Qt5xHb
$module=QtWebEngineWidgets

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=QObject

$addMethods

$addSignals

$endClass

$destructor

#pragma BEGINDUMP

$includes=5,4,0

#include <QtWidgets/QAction>
#include <QtWidgets/QMenu>

$prototype=explicit QWebEnginePage(QObject *parent = 0)
$constructor=5,4,0|new|QObject *=0

$deleteMethod=5,4,0

$prototype=QWebEngineHistory *history() const
$method=5,4,0|QWebEngineHistory *|history|

$prototype=QWidget *view() const
$method=5,4,0|QWidget *|view|

$prototype=void setView(QWidget *view)
$method=5,4,0|void|setView|QWidget *

$prototype=bool hasSelection() const
$method=5,4,0|bool|hasSelection|

$prototype=QString selectedText() const
$method=5,4,0|QString|selectedText|

$prototype=QAction *action(WebAction action) const
$method=5,4,0|QAction *|action|QWebEnginePage::WebAction

$prototype=virtual void triggerAction(WebAction action, bool checked = false)
$virtualMethod=5,4,0|void|triggerAction|QWebEnginePage::WebAction,bool=false

$prototype=virtual bool event(QEvent*)
$virtualMethod=5,4,0|bool|event|QEvent *

$prototype=void findText(const QString &subString, FindFlags options = 0, const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())
%% TODO: implementar
%% $method=5,4,0|void|findText|const QString &,QWebEnginePage::FindFlags=0,const QWebEngineCallback<bool> &=QWebEngineCallback<bool>()

$prototype=QMenu *createStandardContextMenu()
$method=5,4,0|QMenu *|createStandardContextMenu|

$prototype=void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy)
$method=5,4,0|void|setFeaturePermission|const QUrl &,QWebEnginePage::Feature,QWebEnginePage::PermissionPolicy

$prototype=void load(const QUrl &url)
$method=5,4,0|void|load|const QUrl &

$prototype=void setHtml(const QString &html, const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setHtml|const QString &,const QUrl &=QUrl()

$prototype=void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setContent|const QByteArray &,const QString &=QString(),const QUrl &=QUrl()

$prototype=void toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toHtml|const QWebEngineCallback<const QString &> &

$prototype=void toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toPlainText|const QWebEngineCallback<const QString &> &

$prototype=QString title() const
$method=5,4,0|QString|title|

$prototype=QUrl url() const
$method=5,4,0|QUrl|url|

$prototype=void setUrl(const QUrl &url)
$method=5,4,0|void|setUrl|const QUrl &

$prototype=QUrl requestedUrl() const
$method=5,4,0|QUrl|requestedUrl|

$prototype=QUrl iconUrl() const
$method=5,4,0|QUrl|iconUrl|

$prototype=qreal zoomFactor() const
$method=5,4,0|qreal|zoomFactor|

$prototype=void setZoomFactor(qreal factor)
$method=5,4,0|void|setZoomFactor|qreal

$prototype=void runJavaScript(const QString& scriptSource)
$internalMethod=5,4,0|void|runJavaScript,runJavaScript1|const QString &

$prototype=void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
%% TODO: implementar
%% $internalMethod=5,4,0|void|runJavaScript,runJavaScript2|const QString &,const QWebEngineCallback<const QVariant &> &

//[1]void runJavaScript(const QString& scriptSource)
//[2]void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)

HB_FUNC( QWEBENGINEPAGE_RUNJAVASCRIPT )
{
  if( ISNUMPAR(1) && ISCHAR(1) )
  {
    QWebEnginePage_runJavaScript1();
  }
%%  else if( ISNUMPAR(2) && ISCHAR(1) && ISARRAY(2) )
%%  {
%%    QWebEnginePage_runJavaScript2();
%%  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}
$addMethod=runJavaScript

$prototype=QWebEngineSettings *settings() const
$method=5,4,0|QWebEngineSettings *|settings|

$beginSignals
$signal=5,4,0|loadStarted()
$signal=5,4,0|loadProgress(int)
$signal=5,4,0|loadFinished(bool)
$signal=5,4,0|linkHovered(QString)
$signal=5,4,0|selectionChanged()
$signal=5,4,0|geometryChangeRequested(QRect)
$signal=5,4,0|windowCloseRequested()
$signal=5,4,0|featurePermissionRequested(QUrl,QWebEnginePage::Feature)
$signal=5,4,0|featurePermissionRequestCanceled(QUrl,QWebEnginePage::Feature)
$signal=5,4,0|authenticationRequired(QUrl,QAuthenticator*)
$signal=5,4,0|proxyAuthenticationRequired(QUrl,QAuthenticator*,QString)
$signal=5,4,0|titleChanged(QString)
$signal=5,4,0|urlChanged(QUrl)
$signal=5,4,0|iconUrlChanged(QUrl)
$endSignals

#pragma ENDDUMP


[VFP] property Message was deleted when AssertDialog was made designable


more comments

more comments

-- Modeling Opetopes
-- here is Eric's editor: http://sma.epfl.ch/~finster/opetope/opetope.html
--
-- Note: Kock et al. use a similar scheme, where
--          - dots    <-->   lines
--          - spheres <-->   dots
--          - lines disappear
--          -                spheres appear

-- Note: In Eric's new work (at IAS) there are no
--       dots any more, instead he uses 'outout cards', so
--          - (output) cards   <-->  lines
--          - space between stacked cards <--> output cards
--          - lines disappear
--          -                (regular) cards appear

import "../tests/NatList.prg"

-- list kind
--kind List = Ni | Co

-- define the Tree kind, a rose tree
-- note: Ni may only appear in Fork second position (TODO: use GADT!)

kind Tree = Unit | Ni | Fork Tree Tree deriving syntax (tr) List(Ni, Fork) Unit(Unit)

-- make it singleton

data Tree' :: Tree ~> * where
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr

-- define a proposition for subtrees
-- to be checked: TakeHead must ensure that all the node is consumed

prop Subtree :: Tree ~> Tree ~> * where
  BothUnit :: Subtree ()tr ()tr
  BothNil :: Subtree []tr []tr
  TakeHead :: Subtree head head' -> Subtree tail tail' -> Subtree [head; tail]tr [head'; tail']tr
  SkipHead :: Subtree tail tail' -> Subtree [head; tail]tr [head'; tail']tr

-- now we can stack cards (these are zooms in Kock et al. parlance)

data Stack :: Tree ~> Tree ~> * where
  Empty :: Corolla tr => Tree' tr -> Stack tr ()tr
  SubDone :: Stack ()tr []tr
  Subdivision :: Stack ()tr sub -> Stack tr rest -> Stack tr [sub; rest]tr
  Encompass :: Subtree consumed tr => Stack consumed prod -> Stack tr prod
  -- the following three grab a node
  NodeDone :: Stack []tr []tr
  Pick :: {- EntireNode => -} Stack head prodhead -> Stack tail prodtail -> Stack [head, tail]tr [prodhead, prodtail]tr
  Exclude :: {- EntireNode => -} Stack tail prod -> Stack [head, tail]tr prod

-- remains to define corollas

prop Corolla :: Tree ~> * where
  None' :: Corolla []tr
  One' :: Corolla tail -> Corolla [()tr; tail]tr

--  o   --->  |
--  |         |

lolliCell :: Stack []tr ()tr
lolliCell = Empty Done

--  |         |
--  o   --->  |
--  |         |

dolliCell :: Stack [()tr]tr ()tr
dolliCell = Empty $ Fork In Done

--    |           o   |
-- | [o] |  --->   \ /
-- | [|] |          o
--    |             |

--cyclops :: Stack [()tr]tr [[]tr, ()tr]tr
--cyclops = Subdivision SubDone (Exclude NodeDone)

--- OLD IMPLEMENTATION FOLLOWS

-- Node Types

kind NodeType = Regular | Universal

-- Node Labels (parametrized by dimension?)

data NodeLabel = Named (Label n)
               | Comp NodeLabel NodeLabel

-- Node: named faces as inputs and an output (face)

-- Consuming some twig

data Eat :: Twig ~> * where
  NoDot :: Eat None  -- do not extend till next sprouting point
  Sub :: Eat (Sprout l)

-- A connected deck of cards

data Deck :: Twig ~> Twig ~> * where
  Air :: Deck t None
  Card :: Eat t -> Deck subt out -> Deck t (Sprout [out]w)

-- A forest: trees in each dimension up to n
--   o when it ends in a corolla then it is a cell (n-dimensional)
--

--data Forest

-- Idea: each tree must have two type parameters
--       o left: set of nodes from dim (n - 1) is our (tree of) lines
--       o right: my set of nodes is the tree I push to dim n + 1

-- HAH! we have a thrist!

-- trees live at the type level

-- have these forms
--      O  |
--   o  |  o
--      o

--         |
-- List of o starts at O

data List :: *1 where
  No :: List
  Ext :: List ~> Twig ~> List
 deriving LeftList(w)

data Twig :: *1 where
  None :: Twig
  Sprout :: List ~> Twig

-- an Opetope is a LeftThrist of Decks

-- Dimension Zero is always:

dim0 = Card NoDot Air

dim1 = Card Sub Air

upto1 = [dim0, dim1]lt

-- Modeling Opetopes
-- here is Eric's editor: http://sma.epfl.ch/~finster/opetope/opetope.html
--
-- Note: Kock et al. use a similar scheme, where
--          - dots    <-->   lines
--          - spheres <-->   dots
--          - lines disappear
--          -                spheres appear

-- Note: In Eric's new work (at IAS) there are no
--       dots any more, instead he uses 'outout cards', so
--          - (output) cards   <-->  lines
--          - space between stacked cards <--> output cards
--          - lines disappear
--          -                (regular) cards appear

import "../tests/NatList.prg"

-- list kind
--kind List = Ni | Co

-- define the Tree kind, a rose tree
-- note: Ni may only appear in Fork second position (TODO: use GADT!)

kind Tree = Unit | Ni | Fork Tree Tree deriving syntax (tr) List(Ni, Fork) Unit(Unit)

-- make it singleton

data Tree' :: Tree ~> * where
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr

-- define a proposition for subtrees

prop Subtree :: Tree ~> Tree ~> * where
  BothUnit :: Subtree ()tr ()tr
  BothNil :: Subtree []tr []tr
  TakeHead :: Subtree head head' -> Subtree tail tail' -> Subtree [head; tail]tr [head'; tail']tr
  SkipHead :: Subtree tail tail' -> Subtree [head; tail]tr [head'; tail']tr

-- now we can stack cards

data Stack :: Tree ~> Tree ~> * where
  Empty :: Corolla tr => Tree' tr -> Stack tr ()tr
  SubDone :: Stack ()tr []tr
  Subdivision :: Stack ()tr sub -> Stack tr rest -> Stack tr [sub; rest]tr
  Encompass :: Subtree consumed tr => Stack consumed prod -> Stack tr prod
  -- the following three grab a node
  NodeDone :: Stack []tr []tr
  Pick :: {- EntireNode => -} Stack head prodhead -> Stack tail prodtail -> Stack [head, tail]tr [prodhead, prodtail]tr
  Exclude :: {- EntireNode => -} Stack tail prod -> Stack [head, tail]tr prod

-- remains to define corollas

prop Corolla :: Tree ~> * where
  None' :: Corolla []tr
  One' :: Corolla tail -> Corolla [()tr; tail]tr

--  o   --->  |
--  |         |

lolliCell :: Stack []tr ()tr
lolliCell = Empty Done

--  |         |
--  o   --->  |
--  |         |

dolliCell :: Stack [()tr]tr ()tr
dolliCell = Empty $ Fork In Done

--    |           o   |
-- | [o] |  --->   \ /
-- | [|] |          o
--    |             |

--cyclops :: Stack [()tr]tr [[]tr, ()tr]tr
--cyclops = Subdivision SubDone (Exclude NodeDone)

--- OLD IMPLEMENTATION FOLLOWS

-- Node Types

kind NodeType = Regular | Universal

-- Node Labels (parametrized by dimension?)

data NodeLabel = Named (Label n)
               | Comp NodeLabel NodeLabel

-- Node: named faces as inputs and an output (face)

-- Consuming some twig

data Eat :: Twig ~> * where
  NoDot :: Eat None  -- do not extend till next sprouting point
  Sub :: Eat (Sprout l)

-- A connected deck of cards

data Deck :: Twig ~> Twig ~> * where
  Air :: Deck t None
  Card :: Eat t -> Deck subt out -> Deck t (Sprout [out]w)

-- A forest: trees in each dimension up to n
--   o when it ends in a corolla then it is a cell (n-dimensional)
--

--data Forest

-- Idea: each tree must have two type parameters
--       o left: set of nodes from dim (n - 1) is our (tree of) lines
--       o right: my set of nodes is the tree I push to dim n + 1

-- HAH! we have a thrist!

-- trees live at the type level

-- have these forms
--      O  |
--   o  |  o
--      o

--         |
-- List of o starts at O

data List :: *1 where
  No :: List
  Ext :: List ~> Twig ~> List
 deriving LeftList(w)

data Twig :: *1 where
  None :: Twig
  Sprout :: List ~> Twig

-- an Opetope is a LeftThrist of Decks

-- Dimension Zero is always:

dim0 = Card NoDot Air

dim1 = Card Sub Air

upto1 = [dim0, dim1]lt


Small optimizations

Small optimizations

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

/// <summary>
/// </summary>
/// <param name="f"></param>
/// <returns>
/// </returns>
FUNCTION Float2Long(f AS USUAL) AS LONG
    LOCAL flValue AS FLOAT
    flValue := (FLOAT) f
    RETURN (LONG) flValue

    /// <summary>
    /// Return the absolute value of a numeric expression, regardless of its sign.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Abs(n AS USUAL) AS USUAL
    LOCAL uRet AS USUAL
    IF n:IsInt64
        uRet := Math.Abs( (INT64) n )
    ELSEIF n:IsDecimal
        uRet := Math.Abs( (Decimal) n)
    ELSEIF n:isInteger
        uRet := Math.Abs( (INT) n )
    ELSEIF n:IsFLoat
        uRet := AbsFloat( n )
    ELSE
        THROW  Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
    ENDIF
    RETURN uRet

    /// <summary>
    /// Calculate the arc cotangent of a number.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION ACot(n AS USUAL) AS FLOAT
    RETURN 2 * Math.ATan(1) + Math.ATan( (REAL8) n)

    /// <summary>
    /// Calculate the arc tangent of a number.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION ATan(n AS USUAL) AS FLOAT
    RETURN Math.ATan((REAL8)n)

    /// <summary>
    /// Round a number up to the next highest integer.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Ceil(n AS USUAL) AS USUAL
    LOCAL result AS USUAL
    IF n:IsInteger
        result := n
    ELSEIF n:IsDecimal
        LOCAL d AS decimal
        d := (decimal) n
        d := Math.Ceiling(d)
        IF d <= int32.MaxValue .AND. d >= int32.MinValue
            result := COnvert.ToInt32(d)
        ELSEIF d <= int64.MaxValue .AND. d >= int64.MinValue
            result := COnvert.ToInt64(d)
        ELSE
            result := d
        ENDIF

    ELSEIF n:IsFloat
        LOCAL r8 AS REAL8
        r8 := (FLOAT) n
        r8 := Math.Ceiling(r8)
        IF r8 <= int32.MaxValue .AND. r8 >= int32.MinValue
            result := COnvert.ToInt32(r8)
        ELSEIF r8 <= int64.MaxValue .AND. r8 >= int64.MinValue
            result := COnvert.ToInt64(r8)
        ELSE
            result := r8
        ENDIF
    ELSE
        THROW  Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
    ENDIF
    RETURN result

    /// <summary>
    /// Calculate the cosine of a number.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Cos(n AS USUAL) AS FLOAT
    RETURN Math.Cos((REAL8)n)

    /// <summary>
    /// Calculate the cotangent of a value.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Cot(n AS USUAL) AS FLOAT
    RETURN 2 * Math.ATan( 1 ) + Math.ATan( (REAL8)n)

    /// <summary>
    /// Calculate the numeric value of a natural logarithm.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION EXP(n AS USUAL) AS FLOAT
    RETURN Math.Exp((REAL8)n)

    /// <summary>
    /// Round a number down to the next lowest integer.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Floor(n AS USUAL) AS USUAL
    LOCAL result AS USUAL
    IF n:IsInteger
        result := n
    ELSEIF n:IsDecimal
        LOCAL d AS decimal
        d := (decimal) n
        d := Math.Floor(d)
        IF d <= int32.MaxValue .AND. d >= int32.MinValue
            result := COnvert.ToInt32(d)
        ELSEIF d <= int64.MaxValue .AND. d >= int64.MinValue
            result := COnvert.ToInt64(d)
        ELSE
            result := d
        ENDIF

    ELSEIF n:IsFloat
        LOCAL r8 AS REAL8
        r8 := (FLOAT) n
        r8 := Math.Floor(r8)
        IF r8 <= int32.MaxValue .AND. r8 >= int32.MinValue
            result := COnvert.ToInt32(r8)
        ELSEIF r8 <= int64.MaxValue .AND. r8 >= int64.MinValue
            result := COnvert.ToInt64(r8)
        ELSE
            result := r8
        ENDIF
    ELSE
        THROW  Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
    ENDIF
    RETURN result

    /// <summary>
    /// Truncate or
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Integer(n AS USUAL) AS USUAL
    LOCAL result AS USUAL
    IF n:IsInteger
        result := n
    ELSEIF n:IsFloat .OR. n:IsDecimal
        IF n > 0.0
            result := Floor(n)
        ELSE
            result := Ceil(n)
        ENDIF
    ELSE
        THROW Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
    ENDIF
    RETURN result

    /// <summary>
    /// Calculate the natural logarithm of a numeric value.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION LOG(n AS USUAL) AS FLOAT
    RETURN Math.Log((REAL8)n)

    /// <summary>
    /// Calculate the common logarithm of a numeric value.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Log10(n AS USUAL) AS FLOAT
    RETURN Math.Log10((REAL8)n)

    /// <summary>
    /// Raise the first argument to the numeric power specified by the second argument.
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <returns>
    /// </returns>
FUNCTION POW(x AS USUAL,y AS USUAL) AS FLOAT
    RETURN Math.Pow((REAL8)x, (REAL8)y)

INTERNAL GLOBAL _randomGenerator AS Random
/// <summary>
/// Return a random number between 0 and 1.
/// </summary>
/// <param name="nSeed"></param>
/// <returns>
/// </returns>
FUNCTION Rand(nSeed AS USUAL) AS FLOAT
    IF !nSeed:IsNumeric .OR. nSeed <= 0
        nSeed := (INT) DateTime.Now:Ticks
    ENDIF
    _randomGenerator := Random{ nSeed }
    RETURN _randomGenerator:NextDouble()

FUNCTION Rand() AS FLOAT
    IF _randomGenerator == NULL
        _randomGenerator := Random{ 100001 }
    ENDIF
    RETURN _randomGenerator:NextDouble()

    /// <summary>
    /// Round a number to a specified number of digits.
    /// </summary>
    /// <param name="n"></param>
    /// <param name="iDec"></param>
    /// <returns>
    /// </returns>

    #define MAX_DECIMALS 15
FUNCTION Round(n AS USUAL,iDec AS INT) AS USUAL
    LOCAL ret    AS USUAL
    LOCAL IsLong   AS LOGIC
    LOCAL IsInt64  AS LOGIC
    LOCAL r8     AS REAL8

    IF ! n:IsNumeric
        THROW Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument is not numeric")
    ENDIF

    // For Integers we could round the numbers
    // Round(12345, -1) -> 12350
    IsInt64 := n:IsInt64
    IsLong  := n:IsLong
    r8  := n

    IF iDec > 0
        // Round after decimal point
        IF iDec > MAX_DECIMALS
            iDec := MAX_DECIMALS
        ENDIF

        r8 := Math.Round( r8, iDec, MidpointRounding.AwayFromZero )
    ELSE
        // Round before decimal point
        iDec := -iDec

        IF iDec > MAX_DECIMALS
            iDec := MAX_DECIMALS
        ENDIF

        r8 := r8 / ( 10 ^ iDec )
        r8 := Math.Round( r8, 0, MidpointRounding.AwayFromZero )
        r8 := r8 * ( 10 ^ iDec )

        IF r8 < 0
            isLong	:= r8 >= Int32.MinValue
            isInt64 := r8 >= Int64.MinValue
        ELSE
            isLong  := r8 <= Int32.MaxValue
            isInt64 := r8 <= Int64.MaxValue
        ENDIF
        iDec := 0
    ENDIF

    IF isLong .OR. IsInt64
        iDec := 0
    ENDIF

    IF iDec == 0
        IF IsLong
            ret := (INT) r8
        ELSEIF IsInt64
            ret := (INT64) r8
        ELSE
            ret := FLOAT{r8, 0}
        ENDIF
    ELSE
        ret := FLOAT{r8, iDec}
    ENDIF

    RETURN ret

    /// <summary>
    /// Calculate the sine of a number.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Sin(n AS USUAL) AS FLOAT
    RETURN Math.Sin((REAL8)n)

    /// <summary>
    /// Return the square root of a positive number.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION SQRT(n AS USUAL) AS FLOAT
    RETURN Math.SQrt((REAL8)n)

    /// <summary>
    /// Calculate the tangent of a number.
    /// </summary>
    /// <param name="n"></param>
    /// <returns>
    /// </returns>
FUNCTION Tan(n AS USUAL) AS FLOAT
    RETURN Math.Tan((REAL8)n)

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

/// <summary>
/// </summary>
/// <param name="f"></param>
/// <returns>
/// </returns>
FUNCTION Float2Long(f AS USUAL) AS LONG
	LOCAL flValue AS FLOAT
	flValue := (FLOAT) f
	RETURN (LONG) flValue

	/// <summary>
	/// Return the absolute value of a numeric expression, regardless of its sign.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Abs(n AS USUAL) AS USUAL
	LOCAL uRet AS USUAL
	IF n:IsInt64
		uRet := Math.Abs( (INT64) n )
	ELSEIF n:IsDecimal
		uRet := Math.Abs( (Decimal) n)
	ELSEIF n:isInteger
		uRet := Math.Abs( (INT) n )
	ELSEIF n:IsFLoat
		uRet := AbsFloat( n )
	ELSE
		THROW  Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
	ENDIF
	RETURN uRet

	/// <summary>
	/// Calculate the arc cotangent of a number.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION ACot(n AS USUAL) AS FLOAT
	LOCAL f AS FLOAT
	LOCAL r8 AS REAL8
	f := n
	r8 := f
	RETURN 2 * Math.ATan(1) + Math.ATan(r8)

	/// <summary>
	/// Calculate the arc tangent of a number.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION ATan(n AS USUAL) AS FLOAT
	LOCAL f AS FLOAT
	LOCAL r8 AS REAL8
	f := n
	r8 := f
	RETURN Math.ATan(r8)

	/// <summary>
	/// Round a number up to the next highest integer.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Ceil(n AS USUAL) AS USUAL
	LOCAL result AS USUAL
	IF n:IsInteger
		result := n
	ELSEIF n:IsDecimal
		LOCAL d AS decimal
		d := (decimal) n
		d := Math.Ceiling(d)
		IF d <= int32.MaxValue .AND. d >= int32.MinValue
			result := COnvert.ToInt32(d)
		ELSEIF d <= int64.MaxValue .AND. d >= int64.MinValue
			result := COnvert.ToInt64(d)
		ELSE
			result := d
		ENDIF

	ELSEIF n:IsFloat
		LOCAL r8 AS REAL8
		r8 := (FLOAT) n
		r8 := Math.Ceiling(r8)
		IF r8 <= int32.MaxValue .AND. r8 >= int32.MinValue
			result := COnvert.ToInt32(r8)
		ELSEIF r8 <= int64.MaxValue .AND. r8 >= int64.MinValue
			result := COnvert.ToInt64(r8)
		ELSE
			result := r8
		ENDIF
	ELSE
		THROW  Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
	ENDIF
	RETURN result

	/// <summary>
	/// Calculate the cosine of a number.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Cos(n AS USUAL) AS FLOAT
	LOCAL f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN Math.Cos(r8)

	/// <summary>
	/// Calculate the cotangent of a value.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Cot(n AS USUAL) AS FLOAT
	LOCAL f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN 2 * ATan( 1 ) + Math.ATan( r8 )

	/// <summary>
	/// Calculate the numeric value of a natural logarithm.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION EXP(n AS USUAL) AS FLOAT
	LOCAL f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN Math.Exp(r8)

	/// <summary>
	/// Round a number down to the next lowest integer.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Floor(n AS USUAL) AS USUAL
	LOCAL result AS USUAL
	IF n:IsInteger
		result := n
	ELSEIF n:IsDecimal
		LOCAL d AS decimal
		d := (decimal) n
		d := Math.Floor(d)
		IF d <= int32.MaxValue .AND. d >= int32.MinValue
			result := COnvert.ToInt32(d)
		ELSEIF d <= int64.MaxValue .AND. d >= int64.MinValue
			result := COnvert.ToInt64(d)
		ELSE
			result := d
		ENDIF

	ELSEIF n:IsFloat
		LOCAL r8 AS REAL8
		r8 := (FLOAT) n
		r8 := Math.Floor(r8)
		IF r8 <= int32.MaxValue .AND. r8 >= int32.MinValue
			result := COnvert.ToInt32(r8)
		ELSEIF r8 <= int64.MaxValue .AND. r8 >= int64.MinValue
			result := COnvert.ToInt64(r8)
		ELSE
			result := r8
		ENDIF
	ELSE
		THROW  Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
	ENDIF
	RETURN result

	/// <summary>
	/// Truncate or
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Integer(n AS USUAL) AS USUAL
	LOCAL result AS USUAL
	IF n:IsInteger
		result := n
	ELSEIF n:IsFloat .OR. n:IsDecimal
		IF n > 0.0
			result := Floor(n)
		ELSE
			result := Ceil(n)
		ENDIF
	ELSE
		THROW Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument not numeric",1)
	ENDIF
	RETURN result

	/// <summary>
	/// Calculate the natural logarithm of a numeric value.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION LOG(n AS USUAL) AS FLOAT
	LOCAL f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN Math.Log(r8)

	/// <summary>
	/// Calculate the common logarithm of a numeric value.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Log10(n AS USUAL) AS FLOAT
	LOCAL f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN Math.Log10(r8)

	/// <summary>
	/// Raise the first argument to the numeric power specified by the second argument.
	/// </summary>
	/// <param name="x"></param>
	/// <param name="y"></param>
	/// <returns>
	/// </returns>
FUNCTION POW(x AS USUAL,y AS USUAL) AS FLOAT
	LOCAL r8x := (REAL8) (FLOAT) x AS REAL8
	LOCAL r8y := (REAL8) (FLOAT) y AS REAL8
	RETURN Math.Pow(x, y)

INTERNAL GLOBAL _randomGenerator AS Random
/// <summary>
/// Return a random number between 0 and 1.
/// </summary>
/// <param name="nSeed"></param>
/// <returns>
/// </returns>
FUNCTION Rand(nSeed AS USUAL) AS FLOAT
	IF !nSeed:IsNumeric .OR. nSeed <= 0
		nSeed := (INT) DateTime.Now:Ticks
	ENDIF
	_randomGenerator := Random{ nSeed }
	RETURN _randomGenerator:NextDouble()

FUNCTION Rand() AS FLOAT
	IF _randomGenerator == NULL
		_randomGenerator := Random{ 100001 }
	ENDIF
	RETURN _randomGenerator:NextDouble()

	/// <summary>
	/// Round a number to a specified number of digits.
	/// </summary>
	/// <param name="n"></param>
	/// <param name="iDec"></param>
	/// <returns>
	/// </returns>

	#define MAX_DECIMALS 15
FUNCTION Round(n AS USUAL,iDec AS INT) AS USUAL
	LOCAL ret    AS USUAL
	LOCAL IsLong   AS LOGIC
	LOCAL IsInt64  AS LOGIC
	LOCAL r8     AS REAL8

	IF ! n:IsNumeric
		THROW Error.ArgumentError( __ENTITY__, NAMEOF(n), "Argument is not numeric")
	ENDIF

	// For Integers we could round the numbers
	// Round(12345, -1) -> 12350
	IsInt64 := n:IsInt64
	IsLong  := n:IsLong
	r8  := n

	IF iDec > 0
			// Round after decimal point
			IF iDec > MAX_DECIMALS
				iDec := MAX_DECIMALS
			ENDIF

		r8 := Math.Round( r8, iDec, MidpointRounding.AwayFromZero )
	ELSE
		// Round before decimal point
		iDec := -iDec

		IF iDec > MAX_DECIMALS
			iDec := MAX_DECIMALS
		ENDIF

		r8 := r8 / ( 10 ^ iDec )
		r8 := Math.Round( r8, 0, MidpointRounding.AwayFromZero )
		r8 := r8 * ( 10 ^ iDec )

		IF r8 < 0
			isLong	:= r8 >= Int32.MinValue
			isInt64 := r8 >= Int64.MinValue
		ELSE
			isLong  := r8 <= Int32.MaxValue
			isInt64 := r8 <= Int64.MaxValue
		ENDIF
		iDec := 0
	ENDIF

	IF isLong .OR. IsInt64
		iDec := 0
	ENDIF

	IF iDec == 0
		IF IsLong
			ret := (INT) r8
		ELSEIF IsInt64
			ret := (INT64) r8
		ELSE
			ret := FLOAT{r8, 0}
		ENDIF
	ELSE
		ret := FLOAT{r8, iDec}
	ENDIF

	RETURN ret

	/// <summary>
	/// Calculate the sine of a number.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Sin(n AS USUAL) AS FLOAT
	LOCAL f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN Math.Sin(r8)

	/// <summary>
	/// Return the square root of a positive number.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION SQRT(n AS USUAL) AS FLOAT
	LOCAL  f := n AS FLOAT
	LOCAL r8 := (REAL8) f AS REAL8
	RETURN Math.SQrt(r8)

	/// <summary>
	/// Calculate the tangent of a number.
	/// </summary>
	/// <param name="n"></param>
	/// <returns>
	/// </returns>
FUNCTION Tan(n AS USUAL) AS FLOAT
LOCAL  f := n AS FLOAT
LOCAL r8 := (REAL8) f AS REAL8
RETURN Math.Tan(r8)


[Runtime] The FoxPro ALen() function is now called __FoxALen() and called from the ALen() inside XSharp.RT

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING XSharp.Internal

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
FUNCTION ALen(a AS __FoxArray, nArrayAttribute AS LONG) AS DWORD
    SWITCH nArrayAttribute
    CASE 1
        RETURN (DWORD) a:Rows
    CASE 2
        IF a:MultiDimensional
            RETURN (DWORD) a:Columns
        ELSE
            RETURN 0
        ENDIF
    CASE 0
            RETURN (DWORD) a:Count
    OTHERWISE
        THROW ArgumentOutOfRangeException { nameof(nArrayAttribute),nArrayAttribute, "'nArrayAttribute' number is out of range (expected 0, 1 or 2)"}
    END SWITCH

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION __FoxALen(a AS __FoxArray) AS DWORD
    RETURN ALen(a, 0)

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD) AS USUAL
   IF ( nRowSubscript > 0 .AND. nRowSubscript <= ArrayName:Rows )
      RETURN nRowSubscript
   ENDIF
   THROW ArgumentOutOfRangeException { nameof(nRowSubscript),nRowSubscript, "'nRowSubscript' number is out of range"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD, nColumnSubscript AS DWORD) AS USUAL
    IF ArrayName:MultiDimensional
        IF nRowSubscript == 0 .OR. nRowSubscript >  ArrayName:Rows
           THROW ArgumentOutOfRangeException { nameof(nRowSubscript), nRowSubscript, "'nRowSubscript' number is out of range" }
        ELSEIF nColumnSubscript == 0 .OR. nColumnSubscript > ArrayName:Columns
           THROW ArgumentOutOfRangeException { nameof(nColumnSubscript), nColumnSubscript, "'nColumnSubscript' number is out of range" }
        ENDIF
        nRowSubscript --
        RETURN ( nRowSubscript * ArrayName:Columns ) + nColumnSubscript
    ENDIF
THROW ArgumentException { "a one-dimensional array has no columns"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/adel/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION ADel(ArrayName AS ARRAY, nElementNumber AS LONG, nDeleteType := 2 AS LONG) AS DWORD
    IF ! ArrayName IS __FoxArray VAR foxArray
        XSharp.RT.Functions.ADel(ArrayName, (DWORD) nElementNumber )
        RETURN 1
    ENDIF
    IF ! foxArray:MultiDimensional
        foxArray:Delete((LONG) nElementNumber)
    ELSE
        IF nDeleteType == 2
            foxArray:DeleteColumn( (LONG) nElementNumber)
        ELSE
            foxArray:DeleteRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 1

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asubscript/*" />
FUNCTION ASubScript(ArrayName AS __FoxArray, nElementNumber AS DWORD, nSubscript := 1 AS DWORD) AS DWORD
    IF nSubscript == 0 .OR. nSubscript > 2
		THROW ArgumentOutOfRangeException { nameof(nSubscript), nSubscript, "'nSubscript' number is out of range" }
	ELSEIF nElementNumber == 0 .OR. nElementNumber >  ArrayName:Count
		THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
	ENDIF

	IF ArrayName:MultiDimensional

		IF nSubscript == 1

			// calculate the row

			// doesn't compile because GetRow() is a internal method
			RETURN (DWORD) ArrayName:GetRow((LONG) nElementNumber)

		ELSE
			// calculate the column
			RETURN (DWORD) ArrayName:GetColumn((LONG) nElementNumber)

		ENDIF

	ELSE

		IF nSubscript == 2
			THROW ArgumentException { "a one-dimensional array has no columns"}
		ENDIF

		RETURN nElementNumber

    ENDIF

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/ains/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION AIns(ArrayName AS ARRAY, nElementNumber AS DWORD, nInsertType := 1 AS DWORD) AS DWORD
    IF ! ArrayName IS __FoxArray VAR foxArray
        XSharp.RT.Functions.AIns(ArrayName, nElementNumber)
        RETURN 1
    ENDIF
    IF !foxArray:MultiDimensional
        IF nInsertType > 1
			THROW ArgumentException { "a one-dimensional array has no columns"}
		ELSEIF nElementNumber == 0 .OR. nElementNumber > (DWORD) ArrayName:Count
			THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
		ENDIF

		foxArray:Insert((LONG) nElementNumber)
    ELSE
        IF nInsertType > 2
			THROW ArgumentOutOfRangeException { nameof(nInsertType), nInsertType, "'nInsertType' number is out of range" }
		ENDIF
        IF nInsertType == 2
            IF nElementNumber == 0 .OR. nElementNumber > (DWORD) foxArray:Columns
				THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
			ENDIF

			foxArray:InsertColumn( (LONG) nElementNumber)
        ELSE
            IF nElementNumber == 0 .OR. nElementNumber > (DWORD) foxArray:Rows
				THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
			ENDIF

			foxArray:InsertRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 1

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asize/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION ASize(ArrayName AS ARRAY, nSize AS DWORD) AS ARRAY
    IF ! ArrayName IS __FoxArray VAR foxArray
        RETURN XSharp.RT.Functions.ASize(ArrayName, nSize)
    ENDIF
    foxArray:Resize((LONG) nSize)
    RETURN foxArray

/// <inheritdoc cref="ShowArray" />
FUNCTION ShowFoxArray ( aTest AS __FoxArray , cPrefix := "" AS STRING ) AS VOID
    LOCAL i, j AS DWORD

	IF cPrefix:Length == 0
		cPrefix := "a"
	ENDIF

	IF aTest:MultiDimensional
		FOR i := 1 TO ALen ( aTest , 1 )
			FOR j := 1 TO ALen ( aTest , 2 )
				 QOut(cPrefix + "[" + AsString(AElement ( aTest , i , j )) + "] [" + i:ToString() + "," + j:ToString() + "] = " + AsString ( aTest [i,j] ) + ;
					 " " + GetElementValueType ( aTest[i,j] ))
			NEXT
		NEXT
	ELSE
		FOR i := 1 TO ALen ( aTest , 0 )
			QOut( cPrefix + "[" + i:ToString() + "] = " + AsString ( aTest [i] ) + " " + GetElementValueType ( aTest[i] ))
		NEXT
	ENDIF

	LOCAL FUNCTION GetElementValueType( uValue AS USUAL ) AS STRING
	    IF IsNil ( uValue )
		    RETURN "(Nil)"
	    ELSE
		    RETURN "(" + ValType ( uValue ) + ")"
	    ENDIF

        END FUNCTION

RETURN

END FUNCTION

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING XSharp.Internal

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
FUNCTION ALen(a AS __FoxArray, nArrayAttribute AS LONG) AS DWORD
    SWITCH nArrayAttribute
    CASE 1
        RETURN (DWORD) a:Rows
    CASE 2
        IF a:MultiDimensional
            RETURN (DWORD) a:Columns
        ELSE
            RETURN 0
        ENDIF
    CASE 0
            RETURN (DWORD) a:Count
    OTHERWISE
        THROW ArgumentOutOfRangeException { nameof(nArrayAttribute),nArrayAttribute, "'nArrayAttribute' number is out of range (expected 0, 1 or 2)"}
    END SWITCH

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION ALen(a AS ARRAY) AS DWORD
    IF a IS __FoxArray VAR foxArray
        RETURN ALen(foxArray, 0)
    ELSE
        RETURN XSharp.RT.Functions.ALen(a)
    ENDIF

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD) AS USUAL
   IF ( nRowSubscript > 0 .AND. nRowSubscript <= ArrayName:Rows )
      RETURN nRowSubscript
   ENDIF
   THROW ArgumentOutOfRangeException { nameof(nRowSubscript),nRowSubscript, "'nRowSubscript' number is out of range"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD, nColumnSubscript AS DWORD) AS USUAL
    IF ArrayName:MultiDimensional
        IF nRowSubscript == 0 .OR. nRowSubscript >  ArrayName:Rows
           THROW ArgumentOutOfRangeException { nameof(nRowSubscript), nRowSubscript, "'nRowSubscript' number is out of range" }
        ELSEIF nColumnSubscript == 0 .OR. nColumnSubscript > ArrayName:Columns
           THROW ArgumentOutOfRangeException { nameof(nColumnSubscript), nColumnSubscript, "'nColumnSubscript' number is out of range" }
        ENDIF
        nRowSubscript --
        RETURN ( nRowSubscript * ArrayName:Columns ) + nColumnSubscript
    ENDIF
THROW ArgumentException { "a one-dimensional array has no columns"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/adel/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION ADel(ArrayName AS ARRAY, nElementNumber AS LONG, nDeleteType := 2 AS LONG) AS DWORD
    IF ! ArrayName IS __FoxArray VAR foxArray
        XSharp.RT.Functions.ADel(ArrayName, (DWORD) nElementNumber )
        RETURN 1
    ENDIF
    IF ! foxArray:MultiDimensional
        foxArray:Delete((LONG) nElementNumber)
    ELSE
        IF nDeleteType == 2
            foxArray:DeleteColumn( (LONG) nElementNumber)
        ELSE
            foxArray:DeleteRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 1

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asubscript/*" />
FUNCTION ASubScript(ArrayName AS __FoxArray, nElementNumber AS DWORD, nSubscript := 1 AS DWORD) AS DWORD
    IF nSubscript == 0 .OR. nSubscript > 2
		THROW ArgumentOutOfRangeException { nameof(nSubscript), nSubscript, "'nSubscript' number is out of range" }
	ELSEIF nElementNumber == 0 .OR. nElementNumber >  ArrayName:Count
		THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
	ENDIF

	IF ArrayName:MultiDimensional

		IF nSubscript == 1

			// calculate the row

			// doesn't compile because GetRow() is a internal method
			RETURN (DWORD) ArrayName:GetRow((LONG) nElementNumber)

		ELSE
			// calculate the column
			RETURN (DWORD) ArrayName:GetColumn((LONG) nElementNumber)

		ENDIF

	ELSE

		IF nSubscript == 2
			THROW ArgumentException { "a one-dimensional array has no columns"}
		ENDIF

		RETURN nElementNumber

    ENDIF

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/ains/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION AIns(ArrayName AS ARRAY, nElementNumber AS DWORD, nInsertType := 1 AS DWORD) AS DWORD
    IF ! ArrayName IS __FoxArray VAR foxArray
        XSharp.RT.Functions.AIns(ArrayName, nElementNumber)
        RETURN 1
    ENDIF
    IF !foxArray:MultiDimensional
        IF nInsertType > 1
			THROW ArgumentException { "a one-dimensional array has no columns"}
		ELSEIF nElementNumber == 0 .OR. nElementNumber > (DWORD) ArrayName:Count
			THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
		ENDIF

		foxArray:Insert((LONG) nElementNumber)
    ELSE
        IF nInsertType > 2
			THROW ArgumentOutOfRangeException { nameof(nInsertType), nInsertType, "'nInsertType' number is out of range" }
		ENDIF
        IF nInsertType == 2
            IF nElementNumber == 0 .OR. nElementNumber > (DWORD) foxArray:Columns
				THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
			ENDIF

			foxArray:InsertColumn( (LONG) nElementNumber)
        ELSE
            IF nElementNumber == 0 .OR. nElementNumber > (DWORD) foxArray:Rows
				THROW ArgumentOutOfRangeException { nameof(nElementNumber), nElementNumber, "'nElementNumber' number is out of range" }
			ENDIF

			foxArray:InsertRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 1

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asize/*" />
/// <remarks>The parameter to this function is a 'General Array'. The function decides at runtime if the array is a FoxPro array or a 'General' Array</remarks>
FUNCTION ASize(ArrayName AS ARRAY, nSize AS DWORD) AS ARRAY
    IF ! ArrayName IS __FoxArray VAR foxArray
        RETURN XSharp.RT.Functions.ASize(ArrayName, nSize)
    ENDIF
    foxArray:Resize((LONG) nSize)
    RETURN foxArray

/// <inheritdoc cref="ShowArray" />
FUNCTION ShowFoxArray ( aTest AS __FoxArray , cPrefix := "" AS STRING ) AS VOID
    LOCAL i, j AS DWORD

	IF cPrefix:Length == 0
		cPrefix := "a"
	ENDIF

	IF aTest:MultiDimensional
		FOR i := 1 TO ALen ( aTest , 1 )
			FOR j := 1 TO ALen ( aTest , 2 )
				 QOut(cPrefix + "[" + AsString(AElement ( aTest , i , j )) + "] [" + i:ToString() + "," + j:ToString() + "] = " + AsString ( aTest [i,j] ) + ;
					 " " + GetElementValueType ( aTest[i,j] ))
			NEXT
		NEXT
	ELSE
		FOR i := 1 TO ALen ( aTest , 0 )
			QOut( cPrefix + "[" + i:ToString() + "] = " + AsString ( aTest [i] ) + " " + GetElementValueType ( aTest[i] ))
		NEXT
	ENDIF

	LOCAL FUNCTION GetElementValueType( uValue AS USUAL ) AS STRING
	    IF IsNil ( uValue )
		    RETURN "(Nil)"
	    ELSE
		    RETURN "(" + ValType ( uValue ) + ")"
	    ENDIF

        END FUNCTION

RETURN

END FUNCTION