Re: Equivalent of VBA With structure

2020-02-05 Thread freeflow
@zevv, @cictycide. Thanks to both of you for your prompt offers of help. I've 
posted an example of the issues for both of you.


Re: Equivalent of VBA With structure

2020-02-01 Thread freeflow
Sadly, having spent a little while scattering With's around some of my code it 
appears that there are issues. Consequently I'm reverting back to var x = y 
type statements


Re: Equivalent of VBA With structure

2020-02-01 Thread freeflow
Before and after with

before


proc vmJumpIfTrue(self: Computer) =
if self.s.processor.memory1 != 0:
self.s.processor.programCounter = self.s.processor.memory2
else:
self.s.processor.programCounter = self.s.processor.programCounter + 
3


Run

after


proc vmJumpIfTrue(self: Computer) =
with self.s.processor:
if memory1 != 0:
programCounter = memory2
else:
programCounter = programCounter + 3


Run

Very, very nice a clean.


Re: Equivalent of VBA With structure

2020-02-01 Thread freeflow
Stefan thanks for the prompt response. As ever, sometimes you just miss the key 
tag for searching. The With package seems to do the trick and hasremoved a huge 
amount of repetitive noise in object methods. I also tested Cascade but I 
experienced problems.

I also followed up on inc but like += it didn't work. I'm presuming that this 
is because 'programCounter' is defined as an object property rather than a 
field.


Equivalent of VBA With structure

2020-02-01 Thread freeflow
I'm having fun learning nim by converting Advent of Code solutions I wrote in 
VBA.

In VBA you can shortcut long qualifiers using the With statement.


Private Sub VmEquals()

With s.Processor

.Memory3 = IIf(.Memory1 = .Memory2, 1, 0)
.ProgramCounter = .ProgramCounter + 4

End With

End Sub


Run

In nim I eventually got to


proc vmEquals(self: Computer) =
var my = self.s.processor
my.memory3 = if my.memory1 == my.memory2: 1 else: 0
my.programCounter = my.programCounter + 4


Run

My question is (having come up blank in searches), is there a more idiomatic 
way in nim that avoids having to declare an intermediate variable.


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
Aha: success


for myKey, myValue in  readFile(day02PathAndName).split(',').pairs():
result[myKey.int64]=myValue.parseInt

Run


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
It might be more productive if I advise you that I spent several days perusing 
the nim documentation before I admitted defeat and asked a question here. 
@Solitude's comments highlighted something that is not adequately referenced 
when you read the for loop section of the manual.


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
I'll have to wait until my knowledge of nim improves before I can that. In the 
meantime I'm using


let mySeq:seq[string]=readFile(day02PathAndName).split(',')
for myKey, myValue in  mySeq:
result[myKey.int64]=myValue.parseint.int64

Run


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread freeflow
On further reading it seems there is a split proc and a split iterator. The 
former returns a sequence of substrings. The code I have seems to be using the 
iterator version. How would I indicate to nim to use the proc rather than the 
iterator version of split?


Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-12 Thread freeflow
I'm currently having a bash at using nim by converting my efforts for Advent of 
Code from VBA to nim. Unfortunately I've got stuck when trying to iterate over 
the input from a file and push that input into an OrderedTable.


proc GetDay02Program(): OrderedTable[int64,int64]  =
for myKey, myValue in  readFile(day02PathAndName).split(','):
result[myKey.int64]=myValue.parseint.int64

Run

'''

In the code above the myKey variable is flagged and the error message is 'wrong 
number of variables'. I'm a bit perplexed as the reading I've done indicates 
that my for statement is as expected.

I'd appreciate being enlighteded as to why iI'm getting the error.


Windows installation

2017-10-20 Thread freeflow
Hi

Just tried installing Nim following the directions from here

[https://nim-lang.org/install_windows.html](https://nim-lang.org/install_windows.html)

You _CAN_ do better than this.

For example why are you not linking to

[https://sourceforge.net/projects/mingw-w64](https://sourceforge.net/projects/mingw-w64)/

rather than

[https://nim-lang.org/download/mingw64-6.3.0.7z](https://nim-lang.org/download/mingw64-6.3.0.7z)