Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Commodore » Commodore 8-bit » How do I use a variable in a command
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How do I use a variable in a command [message #365477] Wed, 21 March 2018 17:54 Go to next message
Thomas is currently offline  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 Go to previous messageGo to next message
Anssi Saari is currently offline  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 Go to previous messageGo to next message
Anonymous
Karma:
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 Go to previous message
Pekka Takala is currently offline  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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Official FAQ comp.binaries.cbm (semimonthly posting)
Next Topic: Next FCUG meeting - Sunday, April 15
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Mar 28 20:11:56 EDT 2024

Total time taken to generate the page: 0.06093 seconds