Announcement

Collapse
No announcement yet.

A NEWBIE QUESTION NEED ASAP!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guest's Avatar
    Guest replied
    FUNCTION Trim$(inText$)
    FUNCTION = ltrim$(rtrim$(inText$))
    END FUNCTION

    I actually started working on a compatibility INCLUDE file
    so I could compile my PB35 PBCgiLib in PB3.2 and QB7.1.

    It was included with PBCgiLib on my website. http://projects.dosos.com/



    ------------------
    Amos

    Leave a comment:


  • Lance Edmonds
    replied
    Brian, the compiler version was the crucial missing piece of information. Had you noted that in your very first post, the response would not have been so great because the TRIM$() issue could have bee identified immediately!

    That is, TRIM$() was introduced in PB3.5, not PB3.2.

    Anyway, glad to see you got there in the end.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Well guys I just got back! Well I really appreciate everyone's time
    and effort helping me. Just for your info I am just using the
    power basic 3.20 version. I just tried Lee's code and it works
    perfectly. I really appreciate everyone's help. I would of never
    expected this much response. THANK YOU guys. Hopefully I'll be back
    again sometime. It always amazes me how knowledgable you guys are!
    Thanks Again!

    ------------------

    Leave a comment:


  • Lee Bergeron
    replied
    This code will work:

    DIM FF AS LONG
    FF = FREEFILE
    OPEN "c:\windows\desktop\myfile.txt" FOR OUTPUT AS #FF
    FOR L& = 0 TO 9999
    TempString$=USING$("####",L&)
    REPLACE ANY " " WITH "0" IN TempString$
    PRINT #FF, TempString$
    Next
    CLOSE #FF


    ------------------

    Leave a comment:


  • Clay Clear
    replied
    Ian,

    Never thought about FirstBasic.

    However, in his text description (not the error number) of the
    error, what he described is the compiler error for when the
    compiler finds a string operand where a numeric one should be. However,
    if he IS using FirstBasic, then I have no clue as to the error
    codes it generates. Never messed with it.

    Regards,

    Just a sec, before posting any arguments to this posting - I've
    been up for about 48 hours straight, and my memory may very well
    be faulty at this point. So, I'm going to go wade through the
    earlier postings in this thread, to see if I recall his error
    description correctly.

    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    [This message has been edited by Clay Clear (edited September 07, 2001).]

    Leave a comment:


  • Ian Cairns
    replied
    Clay, He might be using FirstBasic. However, error 420 comes up if a function is not defined or if it is not a PowerBasic function.

    regards,

    ------------------
    [email protected]

    Leave a comment:


  • Clay Clear
    replied
    Thanks, Don & Ian! Ian might be on the right track, that maybe
    Brian has an older version of the compiler. One thing that casts
    doubts on that theory, though, is that he's a "newbie", so he probably
    just recently purchased the compiler, which'd mean he'd have version
    3.5. I think the problem is typoes, especially with all those "()".

    Tom,

    Thanks! That's BEAUTIFUL! That's the kind of "tricks & tips for
    programming" that I *love* learning about! That'll pave the way
    for me to figure out more "elegant" code in other kinds of
    statements.

    Regards,


    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    Leave a comment:


  • Tom Hanlin
    replied
    Code:
        TempString$ = RIGHT$("000" + FORMAT$(L%), 4)
    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Don Ewald
    replied
    Greeting Clay!

    I found no problem with your code that you haven't discovered yourself.

    Code:
    DIM FF AS INTEGER
    FF = FREEFILE
    
    OPEN "c:\myfile.txt" FOR OUTPUT AS #FF
    DIM TempString AS STRING
    
    FOR L% = 0 TO 9999
        TempString$ = STRING$(4 - LEN(TRIM$(STR$(L%))), "0") + TRIM$(STR$(L%))
        PRINT #FF, TempString$
    NEXT
    
    CLOSE #FF
    ...looks and executes just fine. I've created a zip file that contains the source, executable and the finished file. It can be found at:

    http://reonis.d2g.com/brian.zip


    ------------------
    Don Ewald
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Ian Cairns
    replied
    If using a version prior to 3.5, you have to use LTRIM$(),
    Just change the offending line to:

    Tempstring = STRING$(4 - LEN(LTRIM$(STR$(L&)), "0") + LTRIM$ (STR$(L&))

    regards,

    ------------------
    [email protected]

    Leave a comment:


  • Clay Clear
    replied
    Brian,

    I couldn't find any "obvious" errors in the code that I posted,
    other than that one typo that I already corrected in an earlier posting.
    So, I'm going to have to refer the matter to the more experienced
    programmers on this BBS. Sorry I couldn't help you!

    Any other members got any ideas?


    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    Leave a comment:


  • Clay Clear
    replied
    OK, then I'll post this last message for you until you get back.

    I'm going to print out this whole thread to a hardcopy, so I can
    study the code I posted in much greater detail. If I can't find
    a problem with it that I can identify as being a problem, then
    I'll have to refer the matter to the more experienced programmers.
    But, if you're still here and get this message before you leave,
    please answer this question(s):

    Are you compiling and running the program in your Compiler Editor?
    (in other words, are you compiling it to memory?)
    If you are, then I can't help you any further, as I've never done
    such a thing, which means that I'm not familiar with the
    compiler's/editor's idiosyncracies in such a case. If that is the case,
    then you should provide Tom Hanlin or Lance Edmonds with the
    exact details of how/what you are doing with the program, etc.,
    and see if they have any insights.

    OK, I'm going to post this reply, then get to work reading the
    hardcopy that I'll make immediately afterwards.

    I hope you enjoy your out-of-town trip!

    Cordially,

    ADDENDUM: just a note - I still think the problem is being caused
    by either a typo in the code I posted, or in your source file.
    It is also possible that I posted some code that is actually bad code,
    as I've been up since 3:00AM, Thursday.

    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    [This message has been edited by Clay Clear (edited September 07, 2001).]

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Also I'm leaving town for the weekend so I won't be back until
    sunday to check for your update. So I'll reply when i get back.
    Have a good weekend.

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    I'm sorry i didnt post something thing sooner I fell asleep. I'm
    still getting the same error at the same place even after making
    the changes. Im sorry for bothering you so much. I wish I knew more
    about programing. Thanks for your time and effort.

    ------------------

    Leave a comment:


  • Clay Clear
    replied
    Brian,

    I am off to do some heavy programming. If you post a need for
    more help, I'll be back on this BBS at appr. 1:30AM - 2:00AM, Central Time, USA,
    to check it out. Sorry if you need help sooner than that, but
    if I don't occupy my mind SOON, I'm going to fall asleep <grin>.

    Cordially,

    P.S. If you get your code to work, PLEASE post that in this
    topic, so I know. In that case, I can devote my energies to
    other pursuits. Thanks!

    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    [This message has been edited by Clay Clear (edited September 06, 2001).]

    Leave a comment:


  • Clay Clear
    replied
    Brian,

    I spotted the error right away, and it's my fault because the
    second code I posted WAS missing a ")". Sorry about that.

    Change the line to:

    Code:
        TempString = STRING$(4 - LEN(TRIM$(STR$(L&))), "0") + TRIM$(STR$(L&))
    Also, you might want to replace:

    Code:
        DIM FF AS LONG
    with:

    Code:
        DIM FF AS INTEGER
    Also, replace all L&'s with L%. I just found out in a different
    topic that I had started that, in the DOS world, integers(%)
    are faster than longs (&). It's in the 32-bit programming
    world that longs are faster than integers. This isn't critical,
    though - it won't cause your program to "bomb", the change will
    just make it run a bit faster.

    I'll be back on this BBS in about 5-10 minutes - gotta go check
    my e-mail. Hope this posting fixes your problems! Let me know!

    Regards,


    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    Leave a comment:


  • Guest's Avatar
    Guest replied
    DIM FF AS LONG
    FF = FREEFILE
    OPEN "c:\windows\desktop\myfile.txt" FOR OUTPUT AS #FF
    DIM TempString AS STRING
    FOR L& = 0 TO 9999
    Tempstring = STRING$ (4 - LEN(TRIM$(STR$(L&)), "0") + TRIM$ (STR$(L&))
    PRINT #FF, TempString
    Next
    CLOSE #FF

    This is exactly how i have it typed the error seems to be coming from
    (4 - LEN(TRIM$(STR$(L&)),

    Right at the very end of the "))"
    THANK YOU

    ------------------

    Leave a comment:


  • Clay Clear
    replied
    Brian,

    I think I'll be up all night, again, so I'll continue to help you
    through the night, if necessary.

    Can you please post a verbatim listing of the code you're entering
    into your compiler? That's the only way I can really find the
    error.

    That's something you should note about this BBS - when you have a
    problem with a piece of code, the people who help you usually
    appreciate you also posting the source code where the error
    occurs, as this greatly speeds up, and makes easier, the
    debugging. Just a friendly note.

    Regards,


    ------------------
    Clay C. Clear

    mailto:[email protected][email protected]</A>

    Clay Clear's Software

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Well I am still getting the same error again. Im not sure exactly why

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    OOPS Sorry disregard the last post


    ------------------

    Leave a comment:

Working...
X