Is there any way to call a sub or function with a number, but to have the compiler treat that number as a different type?
To try and explain more clearly, I store a value in the internal EEPROM which records the pointer to the next free location in an external EPROM.
In my main program I have a Word variable which stores this value during normal program operation but to 'proof' the program against power-cuts, each time I write something to the external EEPROM I update the stored value in EEPROM.
The issue I have is that I want a 'ClearLog' sub which will reset various things in the log 'header', including setting the write pointer to zero. However, if I do EE.Write(Joint_Pointer, 0) this will only write a byte. Is there a way - other than declaring a temporary Word variable - I can send 0 as a Word rather than a byte?
Calling subs / functions with as a different variable type?
Moderators: David Barker, Jerry Messina
-
- Posts: 219
- Joined: Wed Sep 11, 2013 1:27 pm
- Location: Chesterfield
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Calling subs / functions with as a different variable ty
You could cast it to a different type
or use the word write routine directly
Code: Select all
ee.write(joint_pointer, word(0))
Code: Select all
ee.writeword(joint_pointer, 0)
-
- Posts: 219
- Joined: Wed Sep 11, 2013 1:27 pm
- Location: Chesterfield
Re: Calling subs / functions with as a different variable ty
Thanks, Jerry, Word(0) is what I was looking for - didn't know you could do this. I've used .AsWord for variables but wasn't aware of this.