Need another approach for program

Post

Posted
Rating:
#1 (In Topic #1320)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 I am in need of adding to a project. What happens with this program is that it reads an instruction file. It recursively executes what is in the file. This is working nice but needs a new feature. This sub would be defined as follows…

MakeTmr(Cmpr as string, TimeInt as integer, CompareType as string, CompareValue as string, TShell as string, FShell as string)

Cmpr is a name of a shell script that will return a value. This is run when the timer triggers.
TimeInt is the delay for the timer in milliseconds   (it will execute the Cmpr script every TimeInt)
CompareType is the way comparison is done (not relevant for this)
CompareValue is what the result is compared to (not relevant for this)
TShell is another shell script that is run if the condition is true
FShell is another shell script that is run if the condition is false or if not present will reset the timer delay and repeat

The timers will be created as needed. so there could be 2 of these running, none running or 50 of them running. I can create the timers on the fly as needed but the issue is when they go off, I can't tell which one is triggered so the correct shell scripts can execute. I have buttons made this way but I can control the name and tag of the buttons and use them to figure out what to do. The timer has no name or tag when I create it so I have no way of telling what to run when it triggers nor any of the information from when it was created. I am considering using Settings= to store information just never execute the settings.save so nothing is written to disk and setting are only used in the program then lost. Since more than one copy of the program can be running at a time this should keep information to the individual running programs without cross contamination. But I still can't tell which information to grab for each timer because I can't differentiate them from each other yet.

I could use some ideas on how to make this happen.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 wow, did I stump everybody? cool….   

I had an idea but not sure it can be done. Is it possible to wrap a control like the timer control in Gambas? The purpose would be to attach and expose the name and tag properties for a timer so I can detect which one is triggered and the tag to tell me what should be run.

So any info anywhere on how to do this?
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
I don't know if I fully understand your request, but have a look at the attached program.

Attachment
Online now: Yes Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
You could just add .Tag to Timer.class

Simply save this as Timer.class in your project .src folder.  then hTimer.Tag will be present

Code (gambas)

  1. ' Gambas class file
  2.  
  3.  
  4. Property Tag As Variant Use $vTag
  5.  
  6.  


Then all timers can trigger the same event and you can use Last.Tag to get the timer info.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’

BruceSteers said

You could just add .Tag to Timer.class

Simply save this as Timer.class in your project .src folder.  then hTimer.Tag will be present

Code (gambas)

  1. ' Gambas class file
  2.  
  3.  
  4. Property Tag As Variant Use $vTag
  5.  
  6.  


Then all timers can trigger the same event and you can use Last.Tag to get the timer info.

You are on the right track for what I need. I tried to put this in the main class up in the beginning but the tag property is not added and the export word causes an error. "unexpected export" so I do not think I have the quite right but yes adding the tag to the timer would solve the issue entirely. I know I need to put this into its own class but the export still fouls me up.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’

cogier said

I don't know if I fully understand your request, but have a look at the attached program.

Timers-0.0.1.tar.gz

Off topic on that reply. I am looking to create multiple timers programatically. each with different times and each needs to be able to be identified when it triggers so proper code can execute. There can be 2 timers running or 102 timers running concurrently. If the name and tag properties were available it would work perfect. However they are not.
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’
No save that text as a separate file called Timer.class

Then it auto inherits Timer.class and adds the Tag property to all timers.

Check this s post out…
Gambas One - Gambas ONE

In the first comment I explain it all and show how to also show Tag in the IDE property list <EMOJI seq="1f60e" tseq="1f60e">😎</EMOJI>
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 got things working. That is a great thing to be able to add properties. I notice that in the example you set the tag property to $vtag,  is that a constant or something? If I added a name property also, what would it be set to?
Online now: No Back to the top

Post

Posted
Rating:
#9
Guru
BruceSteers is in the usergroup ‘Guru’
 It's a naming convention for variables

$ because it is a global Private variable
v because it's a Variant type
Tag is the name
So $vTag

Following the convention (it's Benoits not mine) you would use
$sName for a string type property called Name

But you can use whatever you like

The Use keyword just makes the property use that variable so you don't need the property read and write methods
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’
In my IDE (I'm not sure if it's Benoits code or mine) if I type the following…

Property Name As String

And with the cursor at the end of the line I press LeftAlt-Shift-Return and it automatically adds Use $sName to the line  :)
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
I tried the left alt shift return thing and it did not do what you thought. It created 2 subs for the variable.
Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
I tried the left alt shift return thing also and it did horrible things to the code folding.

I have a code snippet "pru" that inserts a proper Property line here. It is

Code (gambas)

  1. Property $\{1:Name} As $\{2:Type} Use $$\{3:VarName}

<COLOR color="#FF0000">Everyone should know how to use snippets!</COLOR> If not check here: /ide/idesnippets - Gambas Documentation

b

Online now: No Back to the top

Post

Posted
Rating:
#13
Guru
BruceSteers is in the usergroup ‘Guru’
Oops sorry it must be my code.
I found the function that auto prints the properties Read/Write methods and made some mods :)

If i type
Property Name As String

Pressing LAlt-Shift-Return does this…

Code (gambas)

  1. Property Name As String Use $sName
  2.  

Pressing LAlt-Return does all this…  (minus my comments)

Code (gambas)

  1.  
  2. Private $sName As String  ' this line is printed under the Property definition
  3.  
  4. ' these lines are printed at the bottom of the page
  5.  
  6.   Return $sName
  7.  
  8.  
  9. Private Sub Name_Write(Value As String)
  10.  
  11.   $sName = Value
  12.  
  13.  
  14.  

Hehe  :)

Step 1: Start compiling and installing gambas from source not packages.
Step 2: Realize the IDE is written in gambas and is an editable project you can load into the gambas IDE.
Step 3: Study the code till your eyes hurt.  walk through it like a human debugger on step mode.
Step 4: Make your IDE do all kinds of things that you personally want it to without having to hassle Benoit  :)

God I love gambas :)

But apologies for the misguided key code suggestion. I though the lalt-shift one was Bens code, i guess not.
Online now: No Back to the top

Post

Posted
Rating:
#14
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
you are just an amazing source of information.
Online now: No Back to the top
1 guest and 0 members have just viewed this.