How do I use a variable in a command [message #365477] |
Wed, 21 March 2018 17:54 |
Thomas
Messages: 7 Registered: January 2012
Karma: 0
|
Junior Member |
|
|
On the C64 I have an ML Routine that displays a directory.
The format for the command is SYS850,"$:*"
I need to insert a variable into the $ string. So that in a program I
can display filenames that start with a letter.
For example, I want to display all file names that start with I. so
10 A$="I":sys850,"$:"+A$+"*"
will not work.
Does anyone know a way to do this?
TIA
|
|
|
Re: How do I use a variable in a command [message #365551 is a reply to message #365477] |
Fri, 23 March 2018 03:49 |
Anssi Saari
Messages: 327 Registered: January 2012
Karma: 0
|
Senior Member |
|
|
Thomas <thomas.Xfggtf@m.invalid> writes:
> On the C64 I have an ML Routine that displays a directory.
> The format for the command is SYS850,"$:*"
> I need to insert a variable into the $ string. So that in a program I
> can display filenames that start with a letter.
>
> For example, I want to display all file names that start with I. so
>
> 10 A$="I":sys850,"$:"+A$+"*"
>
> will not work.
> Does anyone know a way to do this?
What about putting the whole argument into A$, does that work? So
for example just
10 A$="$:I*":sys850,A$
But really, in stock C64 basic SYS doesn't take parameters so
I suppose you have something non-stock running? So maybe you can look
into how that works to figure out how to do what you want?
|
|
|
Re: How do I use a variable in a command [message #365706 is a reply to message #365477] |
Mon, 26 March 2018 14:00 |
|
Originally posted by: Herr Doktor
It's been a long time. I'm assuming that this is your ML routine or
at least not a system routine. Does the routine know how to parse such
a command?
On Wed, 21 Mar 2018 14:54:09 -0700, Thomas <thomas.Xfggtf@m.invalid>
wrote:
> On the C64 I have an ML Routine that displays a directory.
> The format for the command is SYS850,"$:*"
> I need to insert a variable into the $ string. So that in a program I
> can display filenames that start with a letter.
>
> For example, I want to display all file names that start with I. so
>
> 10 A$="I":sys850,"$:"+A$+"*"
>
> will not work.
> Does anyone know a way to do this?
>
> TIA
|
|
|
Re: How do I use a variable in a command [message #366179 is a reply to message #365551] |
Mon, 09 April 2018 04:32 |
Pekka Takala
Messages: 73 Registered: March 2012
Karma: 0
|
Member |
|
|
On 23.03.2018 09:49, Anssi Saari wrote:
> Thomas <thomas.Xfggtf@m.invalid> writes:
>
>> On the C64 I have an ML Routine that displays a directory.
>> The format for the command is SYS850,"$:*"
>> I need to insert a variable into the $ string. So that in a program I
>> can display filenames that start with a letter.
>>
>> For example, I want to display all file names that start with I. so
>>
>> 10 A$="I":sys850,"$:"+A$+"*"
>>
>> will not work.
>> Does anyone know a way to do this?
>
> What about putting the whole argument into A$, does that work? So
> for example just
>
> 10 A$="$:I*":sys850,A$
>
> But really, in stock C64 basic SYS doesn't take parameters so
> I suppose you have something non-stock running? So maybe you can look
> into how that works to figure out how to do what you want?
>
If I needed something like this, I would just check how Print reads its
parameters. The comma is easily gone over, but string reading is hard.
Another way to accomplish this is that you have the routine, and use a
for loop to decode the string.
Like this:
10 a$="I":b$="$:"+a$+"*"
20 r=len(b$):poke679,r:forl=1tor:poke679+l,asc(mid$(b$,l,1)):ne xt
30 sys850
Assuming that your routine knows that your string length is at 679 and
actual string is from 680. The restriction for area is the length of the
area. Of course your string can reside under rom memory or wherever
else, if you turn off the roms temporarily before reading the string.
This is only a example, there is millions of other ways to accomplish this.
|
|
|