Forum

Please note that you can subscribe to the individual forums. A subscription for news only covers the news.

Notifications
Clear all

Suggestion: Allow Variables Within Variable Names, i.e. Arrays  

   RSS

0

I don't know how you store variable and flag names at runtime so I don't know if this is actually even possible, but I thought I'd make the suggestion.

I am trying to, among other things, create a scheduling system to allow the user to specify future events. I could obviously use the program as-is to do this by specifying a finite series of event "slots" and duplicating the procedures, i.e.:

[procedure-checkevent1]
if=!zzToday=!event1date
setflag=eventtoday
set!=!eventtoday,!event1time
set$=$eventtoday,$event1
case=first
when=event1flag
setflag=eventflag
case=end

[procedure-checkevent2]
if={!zzToday}={!event2date}
setflag=eventtoday
set!=!eventtoday,!event2time
set$=$eventtoday,$event2
case=first
when=event2flag
setflag=eventflag
case=end

[report-eventstart]
title={$eventstart}
if=!zzTime>=!eventtoday,eventtoday
procedure=eventstart

[procedure-eventstart]
case=first
when=eventflag
procedure=dosomething
case=end

And so on. I was wondering, however, if it was possible to do something like this:

[procedure-checkevent]
if=!zzToday=!event{#eventcheck}date
set#=#event,#eventcheck

[report-eventstart]
title={$event{#eventcheck}}
if=#event>0,!zzTime>=!event{#event}time
procedure=eventstart

[procedure-eventstart]
case=first
when=event{#event}flag
procedure=dosomething
case=end

I would like to be able to stick variables into variable (and flag) names the same way I can stick them into messages. This allows me to avoid having to create a large, limited number of the same procedure and instead I just need a number to identify the event, all the necessary information for the user has already entered into the program and saved into the status file. Whenever the program needs to check for a matching event, I can just loop through one procedure to find one rather than needing to go through twenty or more procedures that all need individually updated if anything changes in the future.

As I write this I realize I'm essentially asking for an array. I understand this is likely an incredibly rare use-case but I thought I'd mention it anyway just in case it might be a plausible addition, since I have several potential uses for it.

Alternate, standalone syntax (?):

Setting the array values:
set@=$array,index,text
set@=$eventname,23,Test event
set@=!eventtime,23,12:00
set@=!eventtime,#eventworking,12:00

Setting other variables to the array values:
get@=$array,$index,$name
get@=$eventname,23,$event
get@=!eventtime,#eventcheck,!event

Also, I realize I've been on here several times and it may seem like all I'm doing is complaining, so I want to make it clear that this program is amazing and I appreciate all the work you've put into it.

4 Answers
0

Sometimes I have been missing arrays myself. But once arrays are there, the next thing that will be asked for is loop instructions. And I have once and for all decided that this is too much for this program.

I have in the past have success with the ability for the sub to ask for jobs that needs to be done. It can provide the ability to specify future events.

Something like this:

;******************************************************************
;* Housework Report
;******************************************************************

[Report-Housework]
Title=I need to do some housework, {$zzMaster}.
PreStatus=Normal
Input$=$task,What needs to be done
question=Ask-housework

[question-Ask-housework]
Phrase=Is this what needs to be done: {$task}?
?Yes, Sir, it is=*
job=Extra-housework
?No, Sir, the silly sissy made a mistake=*
message=Well, then it'd better try again!

[job-Extra-housework]
title={$task}
respit=30:00
RemindInterval=2d
MustStart=1
Estimate=00:10
NewStatus=Housework
DeleteAllowed=1

 

I don't know if this will be sufficient for your purpose. Bot arrays and loops will probably never happen.

Sven

 

This post was modified 2 weeks ago by Sven B.
0

The example I gave was probably not the best. I use pre-scheduled events to handle disabling certain aspects of the program due to the situation, like disabling random events later in the day because the user has to get up early the next day, or for cleaning up the report menu by only displaying things on days they're needed. I already have a working system for it, I was just exploring options for doing it entirely from the program itself; right now it's handled by manually editing part of the script whenever an event is scheduled.

I don't think a loop function is necessary, as I can create those in the program as-is using flags. On a similar note, if "proper" arrays aren't on the table is there any chance of the construction of variable names? If I can type #event{#eventnumber} to get to #event23, I can handle everything else from within the script.

0

It's not so much that you don't need loops, but I am sure that it will come up. And with reason. I feel that it will make scripting more complicated than I think it should be.

I will think about the variable names. I have the same concerns about that.

You can do a lot with flags. Some of the things you mention, can be done with variable and an If or Notif statement. They are very effective for enabling and disabling stuff,

Sven

 

 

0

Yeah, I am pushing the scope of the program somewhat. The issue isn't checking the variables, the issue is getting the variables set to the right thing at the right time, which in this case might be seven weeks away, only for something to suddenly need to happen much earlier. I can do it right now but I run into having to hardcode a limit in the script, as well as some repetitive code, and this is for a use that will probably end with a max of about 30 entries.

The other use could end up in the hundreds of entries, and needs to retain information over time, unlike the event use which can delete the information as soon as it's used. I already have a system in place to handle this, but this addition would optimize the code massively, considering the current implementation is 1,000+ lines at only 75-ish entries since each entry has to be manually checked and the variables set in a massive case switch.

I appreciate your consideration of this new feature, and even if you choose not to implement it I appreciate all the work that has been done on this program.