Powerbasic Question 
Author Message
 Powerbasic Question

Can anyone tell me why the syntax error on the attached program??
I am trying to find the location of the tild (~) in an input field, and
then strip off the left and right data to two different fields.
anyone have any ideas??

[ NEWSGR.BAS < 1K ]
OPEN "HEAD1" FOR OUTPUT AS #1
DO
    INPUT "Enter FIRST Header   ", HdrL$
    LET A#=1
    B# = LEN(HdrL$)
    ARRAY SCAN HdrL$(1) FOR 100,(=~),A#    <---- SYNTAX ERROR ?????
    PRINT #1, B#, HdrL$
    INPUT "Add another entry"; r$
LOOP WHILE UCASE$(r$) = "Y"
CLOSE #1



Thu, 08 Jul 1999 03:00:00 GMT  
 Powerbasic Question

Quote:

>Can anyone tell me why the syntax error on the attached program??
>I am trying to find the location of the tild (~) in an input field, and
>then strip off the left and right data to two different fields.
>anyone have any ideas??

Easy one! The returned element number from ARRAY SCAN has to be a signed
INTEGER (%) not a DOUBLE.

ARRAY SCAN A$(), ="HELLO", TO X%

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _) |  Don Schullian
 | |_)  / _ \ \____\/  \|  _)   | |   |    Gramou 33
 |____//_/ \_\(____/\__/|_|     |_|   |  Papagou, 15669
 ___________________________________  |      Greece
  =================================== |  ++30-1-654-6200

   -----------======### DOWNLOAD ###=========------------
            Nutz 'n Boltz for powerbasic v3.2  
              A library of everyday goodies
   DOWNLOAD N-B-V2??.ZIP FROM YOUR FAVORITE SITE TODAY!



Fri, 09 Jul 1999 03:00:00 GMT  
 Powerbasic Question

Quote:

>Date: Sun, 19 Jan 1997 22:25:20 -0800

>Subject: Powerbasic Question
>Can anyone tell me why the syntax error on the attached program??
>I am trying to find the location of the tild (~) in an input field, and
>then strip off the left and right data to two different fields.
>anyone have any ideas??
>OPEN "HEAD1" FOR OUTPUT AS #1
>DO
>    INPUT "Enter FIRST Header   ", HdrL$
>    LET A#=1
>    B# = LEN(HdrL$)
>    ARRAY SCAN HdrL$(1) FOR 100,(=~),A#    <---- SYNTAX ERROR ?????
>    PRINT #1, B#, HdrL$
>    INPUT "Add another entry"; r$
>LOOP WHILE UCASE$(r$) = "Y"
>CLOSE #1

 HdrL$ is a string variable  in the INPUT line,
therefore you cannot treat it as an array element and use ARRAY SCAN.

To split it at a tilde , use INSTR LEFT$ and MID$

ie
Ptr% =INSTR(HdrL$,"~")
First$ = LEFT$(HdrL$, Ptr% -1)
Second$ = MID$(HrdL$,Ptr%+1)



Sat, 10 Jul 1999 03:00:00 GMT  
 Powerbasic Question



Quote:
> Can anyone tell me why the syntax error on the attached program??
> I am trying to find the location of the tild (~) in an input field, and
> then strip off the left and right data to two different fields.
> anyone have any ideas??
> OPEN "HEAD1" FOR OUTPUT AS #1
> DO
>     INPUT "Enter FIRST Header   ", HdrL$
>     LET A#=1
>     B# = LEN(HdrL$)
>     ARRAY SCAN HdrL$(1) FOR 100,(=~),A#    <---- SYNTAX ERROR ?????
>     PRINT #1, B#, HdrL$
>     INPUT "Add another entry"; r$
> LOOP WHILE UCASE$(r$) = "Y"
> CLOSE #1

How about (I know I'll{*filter*}this up, but it'll probably work with a little
modification):

OPEN "HEAD1" FOR OUTPUT AS #1
DO
 INPUT "Enter First Header  ", Headr$
 b = LEN(Headr$)
 k = INSTR(Headr$, "~")
 ua$ = LEFT$(Headr$, (k - 1))
 ub$ = MID$(Headr$, (k + 1))
 u$ = ua$ + ub$
 PRINT #1, b, u$
 INPUT "Add another entry"; n$
LOOP WHILE UCASE$(n$) = "Y"
CLOSE #1

That'll get the ~ out. That makes one string without the ~ in it. If you
want the left and right halves to be separate, then try this:

OPEN "HEAD1" FOR OUTPUT AS #1
DO
 INPUT "Enter First Header  ", Headr$
 b = LEN(Headr$)
 k = INSTR(Headr$, "~")
 ua$ = LEFT$(Headr$, (k - 1))
 ub$ = MID$(Headr$, (k + 1))
 PRINT #1, b, ua$, ub$
 INPUT "Add another entry"; n$
LOOP WHILE UCASE$(n$) = "Y"
CLOSE #1

I'm not sure if that's how you want the output, cause it looks strange to
me. Just change the line that saves it to the file to make it formatted the
way you want.

--
Dennis Moran (aka Coolio)

http://www.*-*-*.com/



Wed, 21 Jul 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. powerbasic question

2. firstbasic, powerbasic question

3. Mode 13h in PowerBasic Question

4. Question about the PowerBASIC website

5. PowerBasic file format question

6. tough question for powerbasic

7. PowerBasic 6.0 Question

8. ** (PowerBASIC) data-loading question

9. QB/PowerBasic-specific question

10. PowerBASIC specific questions

11. Stupid PowerBASIC 3.1 question.

 

 
Powered by phpBB® Forum Software