Welcome to %s forums

BrainModular Users Forum

Login Register

Script that outlets the date of the current day (year, month, day)

I need help on a Patch
Post Reply
creal
Member
Posts: 96
Contact:

Script that outlets the date of the current day (year, month, day)

Unread post by creal » 11 Feb 2021, 09:29

Hello,

I saw some scripting functions (here: https://www.brainmodular.com/manuals/hh4/en/scripting ) about the current date and I'm wondering if anyone already has scripted a patch with 3 outlets (year, month, day), be it strings or integers, please?

creal.

creal
Member
Posts: 96
Contact:

Unread post by creal » 14 Feb 2021, 10:10

Hello,

I tried to make a script but I'm really a noob even if years ago I learnt several languages on a basic level. Unfortunately, I just don't have the time to dive into.

I attached the script as well as a screenshot of date and time functions, taken from the official script references of Usine, available here: https://www.brainmodular.com/manuals/hh4/en/scripting

If someone has the time to tell me what's wrong with my code, I would be grateful.

Thanks,

creal.
Attachments
date and time functions.png
decode date.pat
(9.93 KiB) Downloaded 240 times

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 15 Feb 2021, 09:53

hello,
No chance to compile.
A script should have an 'INIT' and a 'PROCESS' procedure

Here is the correct script, I hop it will help.

Code: Select all

//////////////////////////
// Decode date 
/////////////////////////
// declaration   


var year,month,day : Tparameter;   

// decode                                   
procedure Init;   
begin                    
 year:=CreateParam('year',ptDataField,pioOutput);
 year.MinMaxNoLimit(true);
 month:=CreateParam('month',ptDataField,pioOutput);                    
 month.MinMaxNoLimit(true);
 day:=CreateParam('day',ptDataField,pioOutput);
 day.MinMaxNoLimit(true);               
end;  
        
//PROCESS                            
PROCEDURE PROCESS();
var y,m,d : uInt16;
BEGIN   
  DecodeDate(Date,y,m,d); 
  year.asinteger(y);
  month.asinteger(m);
  day.asinteger(d);
  
END;    

creal
Member
Posts: 96
Contact:

Unread post by creal » 15 Feb 2021, 11:57

Hello,

Thank you very much. Now I think I understand how a simple script works. It works perfectly well.

Here is the final patch for people who need it.

creal
Attachments
decode date working.pat
(14.8 KiB) Downloaded 239 times

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 15 Feb 2021, 12:29

tanks++++

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 75 guests