Saltar para o conteúdo principal
Versão: 20 R5 BETA

De QodlyScript à linguagem 4D

4D developers use the Qodly Studio documentation to learn how to design their Qodly forms in Qodly Studio.

Code examples are provided in QodlyScript, but since QodlyScript inherits from the 4D Language, you won't be lost. Converting QodlyScript code to 4D language is easy, it only requires some adaptations.

Nomes de variáveis

QodlyScript only support local variables, so variables in QodlyScript examples are not prefixed with $. In the 4D code, make sure to prefix variable names with $ so that they are identifed as local variables by 4D.

Símbolos e palavras-chave

Some basic symbols, operators, and keywords differ in QodlyScript and must be adapted to the 4D Language. Eles estão listados abaixo:

QodlyScriptLínguagem 4DComentário
,;separador de argumentos
=:=operador de atribuição
===operador de comparação
declare#Declare
switchCase of
constructorClass constructor
extendsClass extends
endEnd for, End For each, End if, End case, End use, End while
forEachFor each
stringTextvar type
numberRealvar type

Some other items have a different case (ex: this vs This) but can be pasted directly in 4D code.

Nomes de comandos e constantes

QodlyScript command and constant names are written in camel case without spaces. In addition, QodlyScript constant names start with a k letter. You might need to adapt these QodlyScript items to the 4D Language.

  • Normalmente, você só precisará converter os nomes. For example, newCollection in QodlyScript is New collection in 4D Language.
  • However, some commands have been renamed for a better compliance, for example atan and sqrt are QodlyScript names for Arctan and Square root commands in 4D Language.

Exemplo

  • Código QodlyScript:
 declare(entitySelection : 4D.EntitySelection)  
var dataClass : 4D.DataClass
var entity, duplicate : 4D.Entity
var status : object
dataClass=entitySelection.getDataClass()
forEach(entity,entitySelection)
duplicate=dataClass.new()
duplicate.fromObject(entity.toObject())
duplicate[dataClass.getInfo().primaryKey]=null
status=duplicate.save()
end
  • Código 4D equivalente no linguajem:
 #DECLARE ( $entitySelection : 4D.EntitySelection )  
var $dataClass : 4D.DataClass
var $entity; $duplicate : 4D.Entity
var $status : Object
$dataClass:=$entitySelection.getDataClass()
For each($entity;$entitySelection)
$duplicate:=$dataClass.new()
$duplicate.fromObject($entity.toObject())
$duplicate[$dataClass.getInfo().primaryKey]:=Null
$status:=$duplicate.save()
End for each