Why the frick won't this work? 
Author Message
 Why the frick won't this work?

I'm having a lot of problems with a long script in RealBasic 2.1a24. Here's
part of it that I can't get past:

for i = 0 to 7
  c = asc(mid(d,i+1,1))
  for j = 0 to 7
    if c > ((2^(7-j))-1) then <<-- ')' expected
      c = (c-(2^(7-j)))
      charBmp(j,i) = true
      if BoldStyle then
        charBmp(j+1,i) = true
      end if
    end if
  next j
next i

Help!!!



Fri, 12 Sep 2003 09:29:54 GMT  
 Why the frick won't this work?
On Sun, 25 Mar 2001 17:29:54 -0800, "Jonathyn Bet'nct"

Quote:

>I'm having a lot of problems with a long script in RealBasic 2.1a24. Here's
>part of it that I can't get past:

>for i = 0 to 7
>  c = asc(mid(d,i+1,1))
>  for j = 0 to 7
>    if c > ((2^(7-j))-1) then <<-- ')' expected

(snip)
It's not much help, but it looks like RealBasic is broken :-((

Works in QB4.5                        Sorry!

Peter



Fri, 12 Sep 2003 09:53:16 GMT  
 Why the frick won't this work?
I have traced the problem down to one thing:

2^(7-j)

RealBasic doesn't seem to be able to do this!

I replaced it with Select Case, but I still can't figure out why RealBasic
can't evaluate this expression.

Possibly because it's an alpha release (2.1 alpha 24)??

I downloaded version 3.1 from the RealBasic site; does it work with the 2.x
serial number?



Fri, 12 Sep 2003 15:57:45 GMT  
 Why the frick won't this work?
The code looks Ok - maybe there is a problem with to many nested
brackets.  Try breaking down the statements using temporary variables.

It is a common misconception that complex statements work faster than
multiple simple statements - the compiler has to use temporary
variables - or at least most compiler listings that I've seen
certainly do.

On Sun, 25 Mar 2001 17:29:54 -0800, "Jonathyn Bet'nct"

Quote:

>I'm having a lot of problems with a long script in RealBasic 2.1a24. Here's
>part of it that I can't get past:

>for i = 0 to 7
>  c = asc(mid(d,i+1,1))
>  for j = 0 to 7
>    if c > ((2^(7-j))-1) then <<-- ')' expected
>      c = (c-(2^(7-j)))
>      charBmp(j,i) = true
>      if BoldStyle then
>        charBmp(j+1,i) = true
>      end if
>    end if
>  next j
>next i

>Help!!!



Fri, 12 Sep 2003 21:15:08 GMT  
 Why the frick won't this work?


Quote:
> I have traced the problem down to one thing:

> 2^(7-j)

Beware this may be very slow! Most BASIC interpreters process powers using
*floating* point calculations. Typically it's impemented as

FUNCTION power#(base#, exponent#)
  power# = EXP(LOG(base#) * exponent#)
END FUNCTION

and typically, EXP() and LOG() are CPU time expensive operations!

Quote:
> RealBasic doesn't seem to be able to do this!

> I replaced it with Select Case, but I still can't figure out why RealBasic
> can't evaluate this expression.

I would recommend looking for a *shift* operation in RealBasic like "<<" and
">>" in ANSI C/C++/Java. Some basic dialects such as BlitzBASIC offer SHL
and SHR, so you can write

1 SHL 7-j
(C/C++ syntax: 1 << 7-j)

or even

128 SHR j
(128 >> j)

I hope that somebody in this NG which has more detailed knowledge about
RealBasic than me could provide you the needed help.

Due lack of SHL/SHR in QB, i often use a DIM powerOf2%() array variable with
precalculated binary powers in my projects.

                Andreas



Sat, 13 Sep 2003 00:45:35 GMT  
 Why the frick won't this work?
Actually, I've just figured this all out.

RealBasic doesn't HAVE a ^ operator. Apparently, this is the correct syntax:

pow(2,(7-j))

I'm using a Select Case now anyway, so it doesn't need to do floating-point
stuff anymore.

How do I call a method in either a module or a class? I tried DIM s AS
sabine (sabine is the name of the class), but then s.PlotString8Bit "Hello
World",5,5,... (PlotString8Bit is a method) doesn't work. (It might be that
PlotString8Bit makes calls to PlotSabine [without using any name before it],
but the error happens before PlotString8Bit is even executed.)



Sat, 13 Sep 2003 10:16:37 GMT  
 Why the frick won't this work?
Are you sure that line 2 is correct in RealBasic?

In QB (et all) it would be a numerical ascii value of a String
  c = asc(mid$(d$,i+1,1))
-------------^--^--------
(d on its own might be ok if defined elsewhere as a string, but MID$ is
a normal BASIC reserved word in most dialects (except ZX's!!)

Apart from that I am interested in the piece of code!
What exactly is it that you are attempting to do?
Convert from one font to another, or create one from binary data?


net.com> writes

Quote:
>The code looks Ok - maybe there is a problem with to many nested
>brackets.  Try breaking down the statements using temporary variables.

>On Sun, 25 Mar 2001 17:29:54 -0800, "Jonathyn Bet'nct"

>>I'm having a lot of problems with a long script in RealBasic 2.1a24. Here's
>>part of it that I can't get past:

>>for i = 0 to 7
>>  c = asc(mid(d,i+1,1))
>>  for j = 0 to 7
>>    if c > ((2^(7-j))-1) then <<-- ')' expected
>>      c = (c-(2^(7-j)))
>>      charBmp(j,i) = true
>>      if BoldStyle then
>>        charBmp(j+1,i) = true
>>      end if
>>    end if
>>  next j
>>next i

>>Help!!!

--
Ken Otter


Sat, 13 Sep 2003 01:05:13 GMT  
 Why the frick won't this work?
On Mon, 26 Mar 2001 18:16:37 -0800, "Jonathyn Bet'nct"

Quote:

>Actually, I've just figured this all out.

>RealBasic doesn't HAVE a ^ operator.

AHAH!       It was broken ;-)

Peter



Sat, 13 Sep 2003 19:25:00 GMT  
 Why the frick won't this work?

Quote:
> Are you sure that line 2 is correct in RealBasic?

> In QB (et all) it would be a numerical ascii value of a String
>   c = asc(mid$(d$,i+1,1))
> -------------^--^--------
> (d on its own might be ok if defined elsewhere as a string, but MID$ is
> a normal BASIC reserved word in most dialects (except ZX's!!)

Yes, MID() without the $ is correct in RealBasic.

The problem is, POW() instead of ^ is correct too!

Quote:
> Apart from that I am interested in the piece of code!
> What exactly is it that you are attempting to do?
> Convert from one font to another, or create one from binary data?

Create one from binary data. It's a 10-bit (1024 character) 8x8 font.


Sun, 14 Sep 2003 08:03:41 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Two Q's [Closing a file][why won't work]

2. Why won't this work?

3. Why won't this work?

4. Q: Why won't this work

5. Why won't INSTR() work!!???

6. Why won't AllowZeroLength work?

7. Why won't this work?

8. Why won't this work

9. Why won't this work?

10. Why won't this work right

11. Why won't this work?

12. why won't call Absoulute work??

 

 
Powered by phpBB® Forum Software