Welcome to %s forums

BrainModular Users Forum

Login Register

Screen Resolution Script

I need help on a Patch
Post Reply
dmitriyc
Member
Posts: 84
Contact:

Unread post by dmitriyc » 24 Nov 2018, 17:14

Hey all.

Was wondering if there was a script or something to get my current screen resolution and preferably spit it out as a numerical output?

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 26 Nov 2018, 20:12

not currently, but maybe a script guru can create one for U ;-)

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 26 Nov 2018, 23:55

maybe try this one:

(paste all in empty script and press compile and init, then 'get rez' button)

Code: Select all

//////////////////////////////:
//////////////////////////
// Extract rez from usine log           
/////////////////////////                                                          
// declaration                                                            
var refresh,textOut : Tparameter;     
var Xout, Yout : Tparameter;
     
var st   : TStringList;       
                                                                        
// initialisation : create parameters
procedure init;
var i : integer;                         
begin  
  refresh := CreateParam('get_rez',ptButton);                              
  SetIsOutPut(refresh,false);  
  
  textOut := CreateParam('text',ptTextField);
  SetIsInPut(textOut,false);      
                         
  Xout := CreateParam('X',ptdataField);
  SetIsInPut(Xout,false);     
  Yout := CreateParam('Y',ptdataField);
  SetIsInPut(Yout,false);  
  
end; 
              
// read                          
procedure ReadTextFile;      
var all : string; 
var line : string;
var position :  integer;   

begin
  st.create;                      
  st.clear;     

  st.loadfromFile(GetApplicationPath + 'LogUsine.log');  
  all := st.GetCommaText;                                                                                                                                                                     
  position :=  pos('Resolution',all);    
                                                     
  if(position>0) then begin  
   position := position+11; 
   SetStringValue(textOut, copy(all, position, 9)); 
   line  := copy (all, position, 4);  
   SetValue(Xout, strtoint(line));                     
   line  := copy (all, position+5, 4);  
   SetValue(Yout, strtoint(line)); 
  end;
  
 // itrace(position);
               
  st.free;         
end;        
 
// Callback
procedure callBack(n:integer);
begin   
  if n=0
  then 
  ReadTextFile;
end;

dmitriyc
Member
Posts: 84
Contact:

Unread post by dmitriyc » 27 Nov 2018, 18:14

23fx you are a genius! This is perfect. Exactly what I was thinking! Taking the log that Hollyhock makes and reading the string text directly from it! You are the man!

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 27 Nov 2018, 22:33

cool if usefull :)

User avatar
rlgsbt
Member
Posts: 187
Location: Marseille
Contact:

Unread post by rlgsbt » 28 Nov 2018, 07:51

GREAT ! thanks 23fx

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 28 Nov 2018, 12:19

note that can only work if resolution is set before launching usine, as log is created here,
will not work if changing res while usine is already launched, but maybe possible with sdk im not sure, ill try to have a look.

dmitriyc
Member
Posts: 84
Contact:

Unread post by dmitriyc » 19 Mar 2021, 03:58

Hmm...Doesn't seem to want to work anymore. I tried revisiting an old project and got an error on line 6 column 21. Can't make heads or tails of the code. Please help with update?

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

Unread post by senso » 19 Mar 2021, 19:53

this code works on:

Code: Select all

//////////////////////////////
//////////////////////////

/////////////////////////                                                          
// declaration                                                            
var refresh,textOut: Tparameter;     
var Xout, Yout : Tparameter;
     
var st   : TStringList;       
                                                                        
// initialisation create parameters
procedure init;
var i : integer;                         
begin  
  refresh := CreateParam('get_rez',ptButton);                              
  SetIsOutPut (refresh,false);  
  
  textOut := CreateParam('text',ptTextField);
  SetIsInPut(textOut,false);       
                         
  Xout := CreateParam('X',ptdataField);
  SetIsInPut( Xout,false);     
  Yout := CreateParam('Y',ptdataField);
  SetIsInPut(Yout,false);  
  
end; 
              
// read                          
procedure ReadTextFile;      
var all : string; 
var line : string;
var position : integer;   

begin
  st.create;                      
  st.clear;     

  st.loadfromFile(GetApplicationPath + 'LogUsine.log');  
  all := st.GetCommaText;                                                                                                                                                                     
  position :=  pos('Resolution',all);    
                                                     
  if (position>0) then 
  begin
   position := position+11; 
   SetStringValue(textOut, copy(all, position, 9)); 
   line  := copy (all, position, 4);  
   SetValue(Xout, strtoint(line));                     
   line  := copy (all, position+5, 4);  
   SetValue(Yout, strtoint(line)); 
  end;
  
              
  st.free;         
end;        
 
// Callback
procedure callBack(n : integer);
begin   
  if n=0
  then  ReadTextFile;
end;

dmitriyc
Member
Posts: 84
Contact:

Unread post by dmitriyc » 31 Mar 2021, 23:17

Thank you very much Senso! Very slight correction to your code:

st.loadfromFile(GetApplicationPath + 'LogUsine.log');

should be

st.loadfromFile(GetApplicationPath + '/LogUsine.log');

the format was a bit off and was spitting back an error.

Quick follow up question: is there any way to just simply print the GetApplicationPath?

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

Unread post by senso » 01 Apr 2021, 09:37

what do you mean by "print"?

dmitriyc
Member
Posts: 84
Contact:

Unread post by dmitriyc » 14 Apr 2021, 23:28

i would like to use the PC path that usine is on as a string text to call up and execute .bat files. So instead of resolution, I get "C:/Program Files/Usine Hollyhock/". Then I am able to add the .bat file that is in one of the folders and execute that way by calling up the path and then inserting the command. Hope that helps...

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

Unread post by senso » 16 Apr 2021, 20:50

not sure to understand,maybe you could take a look on
https://www.brainmodular.com/manuals/hh ... usine-path

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests